@@ -157,7 +157,6 @@ struct GGXCommon<T,IsBSDF,false NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScala
157
157
return G2_over_G1;
158
158
}
159
159
160
- vector <scalar_type, 2 > A; // TODO: remove?
161
160
scalar_type a2;
162
161
scalar_type one_minus_a2;
163
162
};
@@ -242,7 +241,6 @@ struct GGXCommon<T,IsBSDF,true NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar
242
241
return G2_over_G1;
243
242
}
244
243
245
- vector <scalar_type, 2 > A;
246
244
scalar_type ax2;
247
245
scalar_type ay2;
248
246
scalar_type a2;
@@ -255,9 +253,9 @@ struct GGXGenerateH
255
253
using vector2_type = vector <T, 2 >;
256
254
using vector3_type = vector <T, 3 >;
257
255
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)
259
257
{
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
261
259
262
260
scalar_type lensq = V.x*V.x + V.y*V.y;
263
261
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
274
272
//tested, seems -t1*t1-t2*t2>-1.0
275
273
vector3_type H = t1*T1 + t2*T2 + sqrt<scalar_type>(1.0 -t1*t1-t2*t2)*V;
276
274
//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));
278
276
}
277
+
278
+ scalar_type ax;
279
+ scalar_type ay;
279
280
};
280
281
}
281
282
282
283
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>)
284
285
struct GGX
285
286
{
287
+ NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = _IsAnisotropic;
286
288
NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = reflect_refract != MTT_REFLECT;
287
289
288
290
using scalar_type = T;
@@ -319,46 +321,46 @@ struct GGX
319
321
enable_if_t<C::value && !IsAnisotropic, dg1_query_type> createDG1Query (NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
320
322
{
321
323
dg1_query_type dg1_query;
322
- dg1_query.ndf = __base .template D<MicrofacetCache>(cache);
324
+ dg1_query.ndf = __ndf_base .template D<MicrofacetCache>(cache);
323
325
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 ());
325
327
return dg1_query;
326
328
}
327
329
template<class LS, class Interaction, typename C=bool_constant<!IsAnisotropic> NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction>)
328
330
enable_if_t<C::value && !IsAnisotropic, g2g1_query_type> createG2G1Query (NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
329
331
{
330
332
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 ());
333
335
return g2_query;
334
336
}
335
337
template<class Interaction, class MicrofacetCache, typename C=bool_constant<IsAnisotropic> NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
336
338
enable_if_t<C::value && IsAnisotropic, dg1_query_type> createDG1Query (NBL_CONST_REF_ARG (Interaction) interaction, NBL_CONST_REF_ARG (MicrofacetCache) cache)
337
339
{
338
340
dg1_query_type dg1_query;
339
- dg1_query.ndf = __base .template D<MicrofacetCache>(cache);
341
+ dg1_query.ndf = __ndf_base .template D<MicrofacetCache>(cache);
340
342
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 ());
342
344
return dg1_query;
343
345
}
344
346
template<class LS, class Interaction, typename C=bool_constant<IsAnisotropic> NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction>)
345
347
enable_if_t<C::value && IsAnisotropic, g2g1_query_type> createG2G1Query (NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
346
348
{
347
349
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 ());
350
352
return g2_query;
351
353
}
352
354
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)
354
356
{
355
- return impl::GGXGenerateH<scalar_type>:: __call (__base.A, localV, u);
357
+ return __generate_base. __call (localV, u);
356
358
}
357
359
358
360
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
359
361
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)
360
362
{
361
- scalar_type d = __base .template D<MicrofacetCache>(cache);
363
+ scalar_type d = __ndf_base .template D<MicrofacetCache>(cache);
362
364
quant_type dmq;
363
365
dmq.microfacetMeasure = d;
364
366
dmq.projectedLightMeasure = d * _sample.getNdotL (BxDFClampMode::BCM_MAX);
@@ -367,7 +369,7 @@ struct GGX
367
369
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
368
370
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)
369
371
{
370
- scalar_type d = __base .template D<MicrofacetCache>(cache);
372
+ scalar_type d = __ndf_base .template D<MicrofacetCache>(cache);
371
373
quant_type dmq;
372
374
dmq.microfacetMeasure = d; // note: microfacetMeasure/2NdotV
373
375
@@ -419,7 +421,8 @@ struct GGX
419
421
return base_type::template G2_over_G1<g2g1_query_type, LS, Interaction, MicrofacetCache>(query, _sample, interaction, cache);
420
422
}
421
423
422
- base_type __base;
424
+ base_type __ndf_base;
425
+ impl::GGXGenerateH<scalar_type> __generate_base;
423
426
};
424
427
425
428
namespace impl
0 commit comments