@@ -75,16 +75,16 @@ struct SGGXG2XQuery
7575 scalar_type devsh_l;
7676};
7777
78- template<typename T, bool IsBSDF , bool IsAnisotropic=false NBL_STRUCT_CONSTRAINABLE>
78+ template<typename T, bool SupportsTransmission , bool IsAnisotropic=false NBL_STRUCT_CONSTRAINABLE>
7979struct GGXCommon;
8080
81- template<typename T, bool IsBSDF >
81+ template<typename T, bool SupportsTransmission >
8282NBL_PARTIAL_REQ_TOP (concepts::FloatingPointScalar<T>)
83- struct GGXCommon<T,IsBSDF ,false NBL_PARTIAL_REQ_BOT (concepts::FloatingPointScalar<T>) >
83+ struct GGXCommon<T,SupportsTransmission ,false NBL_PARTIAL_REQ_BOT (concepts::FloatingPointScalar<T>) >
8484{
8585 using scalar_type = T;
8686
87- NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = IsBSDF ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_MAX;
87+ NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = SupportsTransmission ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_MAX;
8888
8989 // trowbridge-reitz
9090 template<class MicrofacetCache NBL_FUNC_REQUIRES (ReadableIsotropicMicrofacetCache<MicrofacetCache>)
@@ -158,13 +158,13 @@ struct GGXCommon<T,IsBSDF,false NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScala
158158 scalar_type one_minus_a2;
159159};
160160
161- template<typename T, bool IsBSDF >
161+ template<typename T, bool SupportsTransmission >
162162NBL_PARTIAL_REQ_TOP (concepts::FloatingPointScalar<T>)
163- struct GGXCommon<T,IsBSDF ,true NBL_PARTIAL_REQ_BOT (concepts::FloatingPointScalar<T>) >
163+ struct GGXCommon<T,SupportsTransmission ,true NBL_PARTIAL_REQ_BOT (concepts::FloatingPointScalar<T>) >
164164{
165165 using scalar_type = T;
166166
167- NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = IsBSDF ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_MAX;
167+ NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = SupportsTransmission ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_MAX;
168168
169169 template<class MicrofacetCache NBL_FUNC_REQUIRES (AnisotropicMicrofacetCache<MicrofacetCache>)
170170 scalar_type D (NBL_CONST_REF_ARG (MicrofacetCache) cache)
@@ -278,26 +278,8 @@ struct GGXGenerateH
278278template<typename T, bool _IsAnisotropic, MicrofacetTransformTypes reflect_refract NBL_PRIMARY_REQUIRES (concepts::FloatingPointScalar<T>)
279279struct GGX
280280{
281- NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = _IsAnisotropic;
282- NBL_CONSTEXPR_STATIC_INLINE MicrofacetTransformTypes NDFSurfaceType = reflect_refract;
283- NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = reflect_refract != MTT_REFLECT;
284-
285- using this_t = GGX<T, _IsAnisotropic, reflect_refract>;
286- using scalar_type = T;
287- using base_type = impl::GGXCommon<T,IsBSDF,IsAnisotropic>;
288- using quant_type = SDualMeasureQuant<scalar_type>;
289- using vector2_type = vector <T, 2 >;
290- using vector3_type = vector <T, 3 >;
291-
292- using dg1_query_type = impl::SGGXDG1Query<scalar_type>;
293- using g2g1_query_type = impl::SGGXG2XQuery<scalar_type>;
294- using quant_query_type = impl::NDFQuantQuery<scalar_type>;
295-
296- NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = IsBSDF ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_NONE;
297- template<class Interaction>
298- NBL_CONSTEXPR_STATIC_INLINE bool RequiredInteraction = IsAnisotropic ? surface_interactions::Anisotropic <Interaction> : surface_interactions::Isotropic<Interaction>;
299- template<class MicrofacetCache>
300- NBL_CONSTEXPR_STATIC_INLINE bool RequiredMicrofacetCache = IsAnisotropic ? AnisotropicMicrofacetCache<MicrofacetCache> : ReadableIsotropicMicrofacetCache<MicrofacetCache>;
281+ NDF_CONSTEXPR_DECLS (_IsAnisotropic,reflect_refract);
282+ NDF_TYPE_ALIASES (SINGLE_ARG (GGX<T,IsAnisotropic,SupportedPaths>), SINGLE_ARG (impl::GGXCommon<T,SupportsTransmission,IsAnisotropic>), impl::SGGXDG1Query, impl::SGGXG2XQuery);
301283
302284 template<typename C=bool_constant<!IsAnisotropic> >
303285 static enable_if_t<C::value && !IsAnisotropic, this_t> create (scalar_type A)
@@ -321,18 +303,15 @@ struct GGX
321303 return retval;
322304 }
323305
324- template<class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES (RequiredMicrofacetCache<MicrofacetCache>)
325- enable_if_t<C::value && !IsBSDF, quant_query_type> createQuantQuery (NBL_CONST_REF_ARG (MicrofacetCache) cache, scalar_type orientedEta)
326- {
327- quant_query_type dummy; // brdfs don't make use of this
328- return dummy;
329- }
330- template<class MicrofacetCache, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES (RequiredMicrofacetCache<MicrofacetCache>)
331- enable_if_t<C::value && IsBSDF, quant_query_type> createQuantQuery (NBL_CONST_REF_ARG (MicrofacetCache) cache, scalar_type orientedEta)
306+ template<class MicrofacetCache NBL_FUNC_REQUIRES (RequiredMicrofacetCache<MicrofacetCache>)
307+ quant_query_type createQuantQuery (NBL_CONST_REF_ARG (MicrofacetCache) cache, scalar_type orientedEta)
332308 {
333- quant_query_type quant_query;
334- quant_query.VdotHLdotH = cache.getVdotHLdotH ();
335- quant_query.VdotH_etaLdotH = cache.getVdotH () + orientedEta * cache.getLdotH ();
309+ quant_query_type quant_query; // only has members for refraction
310+ if (SupportsTransmission)
311+ {
312+ quant_query.VdotHLdotH = cache.getVdotHLdotH ();
313+ quant_query.VdotH_etaLdotH = cache.getVdotH () + orientedEta * cache.getLdotH ();
314+ }
336315 return quant_query;
337316 }
338317 template<class Interaction, class MicrofacetCache, typename C=bool_constant<!IsAnisotropic> NBL_FUNC_REQUIRES (RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
@@ -375,17 +354,17 @@ struct GGX
375354 return __generate_base.__call (localV, u);
376355 }
377356
378- template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<!IsBSDF > NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
379- 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)
357+ template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<!SupportsTransmission > NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
358+ enable_if_t<C::value && !SupportsTransmission , 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)
380359 {
381360 scalar_type d = __ndf_base.template D<MicrofacetCache>(cache);
382361 quant_type dmq;
383362 dmq.microfacetMeasure = d;
384363 dmq.projectedLightMeasure = d * _sample.getNdotL (BxDFClampMode::BCM_MAX);
385364 return dmq;
386365 }
387- template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<IsBSDF > NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
388- 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)
366+ template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<SupportsTransmission > NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>)
367+ enable_if_t<C::value && SupportsTransmission , 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)
389368 {
390369 scalar_type d = __ndf_base.template D<MicrofacetCache>(cache);
391370 quant_type dmq;
@@ -401,17 +380,17 @@ struct GGX
401380 return dmq;
402381 }
403382
404- template<class LS, class Interaction, typename C=bool_constant<!IsBSDF > NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction>)
405- enable_if_t<C::value && !IsBSDF , quant_type> DG1 (NBL_CONST_REF_ARG (dg1_query_type) query, NBL_CONST_REF_ARG (quant_query_type) quant_query, NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
383+ template<class LS, class Interaction, typename C=bool_constant<!SupportsTransmission > NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction>)
384+ enable_if_t<C::value && !SupportsTransmission , quant_type> DG1 (NBL_CONST_REF_ARG (dg1_query_type) query, NBL_CONST_REF_ARG (quant_query_type) quant_query, NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
406385 {
407386 scalar_type dg1 = base_type::template DG1<dg1_query_type>(query);
408387 quant_type dmq;
409388 dmq.microfacetMeasure = dg1;
410389 dmq.projectedLightMeasure = dg1;// TODO: figure this out * _sample.getNdotL(BxDFClampMode::BCM_MAX);
411390 return dmq;
412391 }
413- template<class LS, class Interaction, typename C=bool_constant<IsBSDF > NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction>)
414- enable_if_t<C::value && IsBSDF , quant_type> DG1 (NBL_CONST_REF_ARG (dg1_query_type) query, NBL_CONST_REF_ARG (quant_query_type) quant_query, NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
392+ template<class LS, class Interaction, typename C=bool_constant<SupportsTransmission > NBL_FUNC_REQUIRES (LightSample<LS> && RequiredInteraction<Interaction>)
393+ enable_if_t<C::value && SupportsTransmission , quant_type> DG1 (NBL_CONST_REF_ARG (dg1_query_type) query, NBL_CONST_REF_ARG (quant_query_type) quant_query, NBL_CONST_REF_ARG (LS) _sample, NBL_CONST_REF_ARG (Interaction) interaction)
415394 {
416395 scalar_type dg1 = base_type::template DG1<dg1_query_type>(query);
417396 quant_type dmq;
0 commit comments