Skip to content

Commit 242afed

Browse files
author
devsh
committed
write test case for glass
1 parent 7b39336 commit 242afed

File tree

1 file changed

+57
-4
lines changed

1 file changed

+57
-4
lines changed

13_MaterialCompilerTest/main.cpp

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
145145
// The material compiler can't handle the BRDF vs. BTDF normalization and energy conservation for you.
146146
// Given a BRDF expression we simply can't tell if the missing energy was supposed
147147
// to be transferred to the BTDF or absorbed by the BRDF itself.
148-
// Hence the BTDF expression must contain the BRDF coating term.
148+
// Hence the BTDF expression must contain the BRDF coating term (how much energy is "taken" by the BRDF).
149149
const auto mulH = forest->_new<CFrontendIR::CMul>();
150150
auto* mul = forest->deref(mulH);
151151
// regular BRDF will normalize to 100% over a hemisphere, if we allow a BTDF term we must split it half/half
@@ -339,13 +339,66 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
339339
ASSERT_VALUE(forest->addMaterial(layerH,logger),true,"Contributor in left subtree check failed");
340340
}
341341

342-
// thindielectric
343342
// dielectric
343+
{
344+
const auto layerH = forest->_new<CFrontendIR::CLayer>();
345+
auto* layer = forest->deref(layerH);
346+
layer->debugInfo = forest->_new<CNodePool::CDebugInfo>("Glass");
347+
348+
const auto mulH = forest->_new<CFrontendIR::CMul>();
349+
auto* mul = forest->deref(mulH);
350+
// do fresnel first
351+
const auto fresnelH = forest->createNamedFresnel("ThF4");
352+
auto* fresnel = forest->deref(fresnelH);
353+
mul->rhs = fresnelH;
354+
// BxDF always goes in left hand side of Mul
355+
{
356+
const auto ctH = forest->_new<CFrontendIR::CCookTorrance>();
357+
auto* ct = forest->deref(ctH);
358+
ct->debugInfo = forest->_new<CNodePool::CDebugInfo>("First Isotropic GGX");
359+
ct->ndParams.getRougness()[0].scale = ct->ndParams.getRougness()[1].scale = 0.05f;
360+
// ignored for BRDFs, needed for BTDFs
361+
ct->orientedRealEta = fresnel->orientedRealEta;
362+
mul->lhs = ctH;
363+
}
364+
365+
// use same BxDF for all parts of a layer
366+
layer->brdfTop = mulH;
367+
layer->btdf = mulH;
368+
layer->brdfBottom = mulH;
369+
370+
{
371+
auto* imagEta = forest->deref(fresnel->orientedImagEta);
372+
imagEta->getParam(0)->scale = std::numeric_limits<float>::min();
373+
imagEta->getParam(1)->scale = -std::numeric_limits<float>::max();
374+
imagEta->getParam(2)->scale = 0.5f;
375+
ASSERT_VALUE(forest->addMaterial(layerH,logger),false,"Imaginary Fresnel disallowed");
376+
for (uint8_t i=0; i<3; i++)
377+
imagEta->getParam(i)->scale = 0.f;
378+
}
379+
380+
ASSERT_VALUE(forest->addMaterial(layerH,logger),true,"Dielectric");
381+
}
382+
383+
// thindielectric
384+
{
385+
//
386+
}
344387

345388
// rough plastic
389+
{
390+
//
391+
}
346392

347-
// coated diffuse transmitter leaf
348-
// with subsurface beer scattering
393+
// coated diffuse transmitter (twosided roughplastic)
394+
{
395+
//
396+
}
397+
398+
// same thing but with subsurface beer scattering
399+
{
400+
//
401+
}
349402

350403
smart_refctd_ptr<IFile> file;
351404
{

0 commit comments

Comments
 (0)