Skip to content

Commit 8ae65e5

Browse files
fixed up my screwup, the material compiler IR construction now can unroll texture scale chains again.
1 parent 39cb993 commit 8ae65e5

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

include/nbl/ext/MitsubaLoader/SContext.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace MitsubaLoader
6161
return imageCacheKey + "?view";
6262
}
6363

64-
static std::string derivMapCacheKey(const CElementBSDF::BumpMap& _bump)
64+
static std::string derivMapCacheKey(const CElementTexture* bitmap, bool wasNormal)
6565
{
6666
using namespace std::string_literals;
6767
static const char* wrap[5]
@@ -73,18 +73,17 @@ namespace MitsubaLoader
7373
"?one"
7474
};
7575

76-
const auto* bitmap = _bump.texture;
7776
std::string key = bitmap->bitmap.filename.svalue + "?deriv"s;
78-
key += _bump.wasNormal ? "n"s:"h"s;
77+
key += wasNormal ? "?n"s:"?h"s;
7978
key += wrap[bitmap->bitmap.wrapModeU];
8079
key += wrap[bitmap->bitmap.wrapModeV];
8180

8281
return key;
8382
}
8483

85-
static std::string derivMapViewCacheKey(const CElementBSDF::BumpMap& _bump)
84+
static std::string derivMapViewCacheKey(const CElementTexture* bitmap, bool wasNormal)
8685
{
87-
return imageViewCacheKey(derivMapCacheKey(_bump));
86+
return imageViewCacheKey(derivMapCacheKey(bitmap,wasNormal));
8887
}
8988

9089
static std::string blendWeightViewCacheKey(const CElementTexture* bitmap)

src/nbl/ext/MitsubaLoader/CMitsubaLoader.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,12 +1271,13 @@ auto CMitsubaLoader::genBSDFtreeTraversal(SContext& ctx, const CElementBSDF* _bs
12711271
// TODO check and restore if dummy (image and sampler)
12721272
auto bumpmap = std::get<0>(bm)->getCreationParameters().image;
12731273
auto sampler = std::get<1>(bm);
1274-
const std::string key = ctx.derivMapCacheKey(bsdf->bumpmap);
1274+
const bool wasNormal = bsdf->bumpmap.wasNormal;
1275+
const std::string key = ctx.derivMapCacheKey(bumpmap_element,wasNormal);
12751276

12761277
if (!getBuiltinAsset<asset::ICPUImage, asset::IAsset::ET_IMAGE>(key.c_str(), m_assetMgr))
12771278
{
12781279
// TODO: @Crisspl retrieve the normalization factor from the deriv map filter, then adjust the scale accordingly!
1279-
auto derivmap = createDerivMap(bumpmap.get(),sampler.get(),bsdf->bumpmap.wasNormal);
1280+
auto derivmap = createDerivMap(bumpmap.get(),sampler.get(),wasNormal);
12801281
asset::SAssetBundle imgBundle(nullptr,{ derivmap });
12811282
ctx.override_->insertAssetIntoCache(std::move(imgBundle), key, ctx.inner, 0u);
12821283
auto derivmap_view = createImageView(std::move(derivmap));

src/nbl/ext/MitsubaLoader/CMitsubaMaterialCompilerFrontend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace MitsubaLoader
1818
const CElementTexture* texture = nullptr;
1919
float scale = 1.f;
2020
std::tie(texture, scale) = getTexture_common(_bump.texture);
21-
std::string key = m_loaderContext->derivMapCacheKey(_bump);
21+
std::string key = m_loaderContext->derivMapCacheKey(texture,_bump.wasNormal);
2222
if (texture->type != CElementTexture::BITMAP)
2323
return { nullptr, nullptr, 0.f };
2424

0 commit comments

Comments
 (0)