@@ -157,7 +157,6 @@ struct GGXCommon<T,IsBSDF,false NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScala
157157 return G2_over_G1;
158158 }
159159
160- vector <scalar_type, 2 > A; // TODO: remove?
161160 scalar_type a2;
162161 scalar_type one_minus_a2;
163162};
@@ -242,7 +241,6 @@ struct GGXCommon<T,IsBSDF,true NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar
242241 return G2_over_G1;
243242 }
244243
245- vector <scalar_type, 2 > A;
246244 scalar_type ax2;
247245 scalar_type ay2;
248246 scalar_type a2;
@@ -255,9 +253,9 @@ struct GGXGenerateH
255253 using vector2_type = vector <T, 2 >;
256254 using vector3_type = vector <T, 3 >;
257255
258- static vector3_type __call (const vector2_type A, const vector3_type localV, const vector2_type u)
256+ vector3_type __call (const vector3_type localV, const vector2_type u)
259257 {
260- vector3_type V = nbl::hlsl::normalize<vector3_type>(vector3_type (A.x* localV.x, A.y* localV.y, localV.z));//stretch view vector so that we're sampling as if roughness=1.0
258+ vector3_type V = nbl::hlsl::normalize<vector3_type>(vector3_type (ax * localV.x, ay * localV.y, localV.z));//stretch view vector so that we're sampling as if roughness=1.0
261259
262260 scalar_type lensq = V.x*V.x + V.y*V.y;
263261 vector3_type T1 = lensq > 0.0 ? vector3_type (-V.y, V.x, 0.0 ) * rsqrt<scalar_type>(lensq) : vector3_type (1.0 ,0.0 ,0.0 );
@@ -274,15 +272,19 @@ struct GGXGenerateH
274272 //tested, seems -t1*t1-t2*t2>-1.0
275273 vector3_type H = t1*T1 + t2*T2 + sqrt<scalar_type>(1.0 -t1*t1-t2*t2)*V;
276274 //unstretch
277- return nbl::hlsl::normalize<vector3_type>(vector3_type (A.x *H.x, A.y *H.y, H.z));
275+ return nbl::hlsl::normalize<vector3_type>(vector3_type (ax *H.x, ay *H.y, H.z));
278276 }
277+
278+ scalar_type ax;
279+ scalar_type ay;
279280};
280281}
281282
282283
283- template<typename T, bool IsAnisotropic , MicrofacetTransformTypes reflect_refract NBL_PRIMARY_REQUIRES (concepts::FloatingPointScalar<T>)
284+ template<typename T, bool _IsAnisotropic , MicrofacetTransformTypes reflect_refract NBL_PRIMARY_REQUIRES (concepts::FloatingPointScalar<T>)
284285struct GGX
285286{
287+ NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = _IsAnisotropic;
286288 NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = reflect_refract != MTT_REFLECT;
287289
288290 using scalar_type = T;
@@ -319,46 +321,46 @@ struct GGX
319321 enable_if_t<C::value && !IsAnisotropic, dg1_query_type> createDG1Query (NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
320322 {
321323 dg1_query_type dg1_query;
322- dg1_query.ndf = __base .template D<MicrofacetCache>(cache);
324+ dg1_query.ndf = __ndf_base .template D<MicrofacetCache>(cache);
323325 scalar_type clampedNdotV = interaction.getNdotV (_clamp);
324- dg1_query.G1_over_2NdotV = __base .G1_wo_numerator (clampedNdotV, interaction.getNdotV2 ());
326+ dg1_query.G1_over_2NdotV = __ndf_base .G1_wo_numerator (clampedNdotV, interaction.getNdotV2 ());
325327 return dg1_query;
326328 }
327329 template<class LS, class Interaction, typename C=bool_constant<!IsAnisotropic> NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction>)
328330 enable_if_t<C::value && !IsAnisotropic, g2g1_query_type> createG2G1Query (NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
329331 {
330332 g2g1_query_type g2_query;
331- g2_query.devsh_l = __base .devsh_part (_sample.getNdotL2 ());
332- g2_query.devsh_v = __base .devsh_part (interaction.getNdotV2 ());
333+ g2_query.devsh_l = __ndf_base .devsh_part (_sample.getNdotL2 ());
334+ g2_query.devsh_v = __ndf_base .devsh_part (interaction.getNdotV2 ());
333335 return g2_query;
334336 }
335337 template<class Interaction, class MicrofacetCache, typename C=bool_constant<IsAnisotropic> NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
336338 enable_if_t<C::value && IsAnisotropic, dg1_query_type> createDG1Query (NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
337339 {
338340 dg1_query_type dg1_query;
339- dg1_query.ndf = __base .template D<MicrofacetCache>(cache);
341+ dg1_query.ndf = __ndf_base .template D<MicrofacetCache>(cache);
340342 scalar_type clampedNdotV = interaction.getNdotV (_clamp);
341- dg1_query.G1_over_2NdotV = __base .G1_wo_numerator (clampedNdotV, interaction.getTdotV2 (), interaction.getBdotV2 (), interaction.getNdotV2 ());
343+ dg1_query.G1_over_2NdotV = __ndf_base .G1_wo_numerator (clampedNdotV, interaction.getTdotV2 (), interaction.getBdotV2 (), interaction.getNdotV2 ());
342344 return dg1_query;
343345 }
344346 template<class LS, class Interaction, typename C=bool_constant<IsAnisotropic> NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction>)
345347 enable_if_t<C::value && IsAnisotropic, g2g1_query_type> createG2G1Query (NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
346348 {
347349 g2g1_query_type g2_query;
348- g2_query.devsh_l = __base .devsh_part (_sample.getTdotL2 (), _sample.getBdotL2 (), _sample.getNdotL2 ());
349- g2_query.devsh_v = __base .devsh_part (interaction.getTdotV2 (), interaction.getBdotV2 (), interaction.getNdotV2 ());
350+ g2_query.devsh_l = __ndf_base .devsh_part (_sample.getTdotL2 (), _sample.getBdotL2 (), _sample.getNdotL2 ());
351+ g2_query.devsh_v = __ndf_base .devsh_part (interaction.getTdotV2 (), interaction.getBdotV2 (), interaction.getNdotV2 ());
350352 return g2_query;
351353 }
352354
353- vector <T, 3 > generateH (const vector3_type localV, const vector2_type u)
355+ vector3_type generateH (const vector3_type localV, const vector2_type u)
354356 {
355- return impl::GGXGenerateH<scalar_type>:: __call (__base.A, localV, u);
357+ return __generate_base. __call (localV, u);
356358 }
357359
358360 template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
359361 enable_if_t<C::value && !IsBSDF, quant_type> D (NBL_CONST_REF_ARG (quant_query_type) quant_query, NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
360362 {
361- scalar_type d = __base .template D<MicrofacetCache>(cache);
363+ scalar_type d = __ndf_base .template D<MicrofacetCache>(cache);
362364 quant_type dmq;
363365 dmq.microfacetMeasure = d;
364366 dmq.projectedLightMeasure = d * _sample.getNdotL (BxDFClampMode::BCM_MAX);
@@ -367,7 +369,7 @@ struct GGX
367369 template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
368370 enable_if_t<C::value && IsBSDF, quant_type> D (NBL_CONST_REF_ARG (quant_query_type) quant_query, NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
369371 {
370- scalar_type d = __base .template D<MicrofacetCache>(cache);
372+ scalar_type d = __ndf_base .template D<MicrofacetCache>(cache);
371373 quant_type dmq;
372374 dmq.microfacetMeasure = d; // note: microfacetMeasure/2NdotV
373375
@@ -419,7 +421,8 @@ struct GGX
419421 return base_type::template G2_over_G1<g2g1_query_type, LS, Interaction, MicrofacetCache>(query, _sample, interaction, cache);
420422 }
421423
422- base_type __base;
424+ base_type __ndf_base;
425+ impl::GGXGenerateH<scalar_type> __generate_base;
423426};
424427
425428namespace impl
0 commit comments