Skip to content

Commit 850536c

Browse files
implement BLEND_BSDF
1 parent 0c1e045 commit 850536c

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/nbl/ext/MitsubaLoader/CMitsubaLoader.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,19 @@ auto SContext::genMaterial(const CElementBSDF* bsdf, system::ISystem* debugFileW
10421042
}
10431043
case CElementBSDF::BLEND_BSDF:
10441044
{
1045-
assert(false); // unimplemented
1045+
const auto blendH = frontPool.emplace<frontend_ir_t::CLayer>();
1046+
auto* const blend = frontPool.deref(blendH);
1047+
const auto tH = createFactorNode(_bsdf->blendbsdf.weight,ECommonDebug::Weight);
1048+
const auto tComplementH = frontIR->createComplement(tH);
1049+
const auto loH = getChildFromCache(_bsdf->blendbsdf.bsdf[0]);
1050+
const auto hiH = getChildFromCache(_bsdf->blendbsdf.bsdf[1]);
1051+
const auto* const lo = frontPool.deref(loH);
1052+
const auto* const hi = frontPool.deref(hiH);
1053+
// I don't actually need to check if the child Expressions are non-empty, the CFrontendIR utilities nicely carry through NOOPs
1054+
blend->brdfTop = frontIR->createAdd(frontIR->createMul(lo->brdfTop,tComplementH),frontIR->createMul(hi->brdfTop,tH));
1055+
blend->btdf = frontIR->createAdd(frontIR->createMul(lo->btdf,tComplementH),frontIR->createMul(hi->btdf,tH));
1056+
blend->brdfBottom = frontIR->createAdd(frontIR->createMul(lo->brdfBottom,tComplementH),frontIR->createMul(hi->brdfBottom,tH));
1057+
newMaterialH = blendH;
10461058
break;
10471059
}
10481060
case CElementBSDF::TWO_SIDED:

0 commit comments

Comments
 (0)