@@ -46,6 +46,7 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
4646// TODO: use std::source_info
4747#define ASSERT_VALUE (WHAT,VALUE,MSG ) if (WHAT!=VALUE) return logFail(" %s:%d test doesn't match expected value. %s" ,__FILE__,__LINE__,MSG)
4848
49+ using spectral_var_t = CFrontendIR::CSpectralVariable;
4950 // simple white furnace testing materials
5051 {
5152 // transmission
@@ -69,9 +70,7 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
6970 });
7071 auto view = ICPUImageView::create ({.image =image,.viewType =ICPUImageView::ET_2D,.format =EF_R16_SFLOAT});
7172
72- using spectral_var_t = CFrontendIR::CSpectralVariable;
7373 spectral_var_t ::SCreationParams<1 > params = {};
74- params.knots .uvSlot () = 0 ;
7574 params.knots .params [0 ].scale = 4 .5f ;
7675 params.knots .params [0 ].view = view;
7776
@@ -105,12 +104,68 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
105104 ASSERT_VALUE (forest->addMaterial (layerH,logger),true ," Add Material" );
106105 }
107106
108- // cook torrance GGX
109- // cook torrance GGX with Fresnel
107+ // diffuse
108+
109+ // twosided diffuse
110+
111+ // diffuse transmissive
112+ }
113+
114+ // emitter without IES profile
115+
116+ // emitter with IES profile
117+
118+ // anisotropic cook torrance GGX with Conductor Fresnel
119+ {
120+ const auto layerH = forest->_new <CFrontendIR::CLayer>();
121+ auto * layer = forest->deref (layerH);
122+ layer->debugInfo = forest->_new <CNodePool::CDebugInfo>(" Anisotropic Aluminium" );
123+
124+ const auto mulH = forest->_new <CFrontendIR::CMul>();
125+ auto * mul = forest->deref (mulH);
126+ // BxDF always goes in left hand side of Mul
127+ {
128+ const auto ctH = forest->_new <CFrontendIR::CCookTorrance>();
129+ auto * ct = forest->deref (ctH);
130+ ct->debugInfo = forest->_new <CNodePool::CDebugInfo>(" First Anisotropic GGX" );
131+ ct->ndParams .getRougness ()[0 ].scale = 0 .2f ;
132+ ct->ndParams .getRougness ()[1 ].scale = 0 .01f ;
133+ mul->lhs = ctH;
134+ }
135+ // other multipliers in not-left subtrees
136+ {
137+ const auto frH = forest->_new <CFrontendIR::CFresnel>();
138+ auto * fr = forest->deref (frH);
139+ fr->debugInfo = forest->_new <CNodePool::CDebugInfo>(" Aluminium Fresnel" );
140+ {
141+ spectral_var_t ::SCreationParams<3 > params = {};
142+ params.getSemantics () = spectral_var_t ::Semantics::Fixed3_SRGB;
143+ params.knots .params [0 ].scale = 1 .3404f ;
144+ params.knots .params [1 ].scale = 0 .95151f ;
145+ params.knots .params [2 ].scale = 0 .68603f ;
146+ fr->orientedRealEta = forest->_new <spectral_var_t >(std::move (params));
147+ }
148+ {
149+ spectral_var_t ::SCreationParams<3 > params = {};
150+ params.getSemantics () = spectral_var_t ::Semantics::Fixed3_SRGB;
151+ params.knots .params [0 ].scale = 7 .3509f ;
152+ params.knots .params [1 ].scale = 6 .4542f ;
153+ params.knots .params [2 ].scale = 5 .6351f ;
154+ fr->orientedImagEta = forest->_new <spectral_var_t >(std::move (params));
155+ }
156+ mul->rhs = frH;
157+ }
158+ layer->brdfTop = mulH;
159+
160+ // test that our bad subtree checks by swapping lhs with rhs
161+ std::swap (mul->lhs ,mul->rhs );
162+ ASSERT_VALUE (forest->addMaterial (layerH,logger),false ," Contributor not in left subtree check failed" );
163+
164+ // should work now
165+ std::swap (mul->lhs ,mul->rhs );
166+ ASSERT_VALUE (forest->addMaterial (layerH,logger),true ," Contributor in left subtree check failed" );
110167 }
111168
112- // diffuse
113- // conductor (smooth and rough)
114169 // thindielectric
115170 // dielectric
116171 // diffuse transmitter
0 commit comments