Skip to content

Commit c9f9366

Browse files
committed
added create methods to ndfs, cook torrance base; slight changes to cook torrance template
1 parent 2a3cda3 commit c9f9366

File tree

7 files changed

+138
-295
lines changed

7 files changed

+138
-295
lines changed

include/nbl/builtin/hlsl/bxdf/cook_torrance_base.hlsl

Lines changed: 85 additions & 287 deletions
Large diffs are not rendered by default.

include/nbl/builtin/hlsl/bxdf/ndf/beckmann.hlsl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ struct BeckmannGenerateH
280280
template<typename T, bool _IsAnisotropic, MicrofacetTransformTypes reflect_refract NBL_PRIMARY_REQUIRES(concepts::FloatingPointScalar<T>)
281281
struct Beckmann
282282
{
283+
using this_t = Beckmann<T, _IsAnisotropic, reflect_refract>;
283284
using scalar_type = T;
284285
using base_type = impl::BeckmannCommon<T,_IsAnisotropic>;
285286
using quant_type = SDualMeasureQuant<scalar_type>;
@@ -297,6 +298,27 @@ struct Beckmann
297298
template<class MicrofacetCache>
298299
NBL_CONSTEXPR_STATIC_INLINE bool RequiredMicrofacetCache = IsAnisotropic ? AnisotropicMicrofacetCache<MicrofacetCache> : ReadableIsotropicMicrofacetCache<MicrofacetCache>;
299300

301+
template<typename C=bool_constant<!IsAnisotropic> >
302+
enable_if_t<C::value && !IsAnisotropic, this_t> create(scalar_type A)
303+
{
304+
this_t retval;
305+
retval.__ndf_base.a2 = A*A;
306+
retval.__generate_base.ax = A;
307+
retval.__generate_base.ay = A;
308+
return retval;
309+
}
310+
template<typename C=bool_constant<IsAnisotropic> >
311+
enable_if_t<C::value && IsAnisotropic, this_t> create(scalar_type ax, scalar_type ay)
312+
{
313+
this_t retval;
314+
retval.__ndf_base.ax2 = ax*ax;
315+
retval.__ndf_base.ay2 = ay*ay;
316+
retval.__ndf_base.a2 = ax*ay;
317+
retval.__generate_base.ax = ax;
318+
retval.__generate_base.ay = ay;
319+
return retval;
320+
}
321+
300322
template<class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>)
301323
enable_if_t<C::value && !IsBSDF, quant_query_type> createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta)
302324
{

include/nbl/builtin/hlsl/bxdf/ndf/ggx.hlsl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ struct GGX
287287
NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = _IsAnisotropic;
288288
NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = reflect_refract != MTT_REFLECT;
289289

290+
using this_t = GGX<T, _IsAnisotropic, reflect_refract>;
290291
using scalar_type = T;
291292
using base_type = impl::GGXCommon<T,IsBSDF,IsAnisotropic>;
292293
using quant_type = SDualMeasureQuant<scalar_type>;
@@ -303,6 +304,28 @@ struct GGX
303304
template<class MicrofacetCache>
304305
NBL_CONSTEXPR_STATIC_INLINE bool RequiredMicrofacetCache = IsAnisotropic ? AnisotropicMicrofacetCache<MicrofacetCache> : ReadableIsotropicMicrofacetCache<MicrofacetCache>;
305306

307+
template<typename C=bool_constant<!IsAnisotropic> >
308+
enable_if_t<C::value && !IsAnisotropic, this_t> create(scalar_type A)
309+
{
310+
this_t retval;
311+
retval.__ndf_base.a2 = A*A;
312+
retval.__ndf_base.one_minus_a2 = scalar_type(1.0) - A*A;
313+
retval.__generate_base.ax = A;
314+
retval.__generate_base.ay = A;
315+
return retval;
316+
}
317+
template<typename C=bool_constant<IsAnisotropic> >
318+
enable_if_t<C::value && IsAnisotropic, this_t> create(scalar_type ax, scalar_type ay)
319+
{
320+
this_t retval;
321+
retval.__ndf_base.ax2 = ax*ax;
322+
retval.__ndf_base.ay2 = ay*ay;
323+
retval.__ndf_base.a2 = ax*ay;
324+
retval.__generate_base.ax = ax;
325+
retval.__generate_base.ay = ay;
326+
return retval;
327+
}
328+
306329
template<class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>)
307330
enable_if_t<C::value && !IsBSDF, quant_query_type> createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta)
308331
{

include/nbl/builtin/hlsl/bxdf/reflection/beckmann.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct SBeckmannIsotropic
9191
return __base.quotient_and_pdf(_sample, interaction.isotropic, cache.iso_cache);
9292
}
9393

94-
SCookTorrance<Config, ndf_type, fresnel_type, false> __base;
94+
SCookTorrance<Config, ndf_type, fresnel_type> __base;
9595
};
9696

9797
template<class Config NBL_PRIMARY_REQUIRES(config_concepts::MicrofacetConfiguration<Config>)
@@ -150,7 +150,7 @@ struct SBeckmannAnisotropic
150150
return __base.quotient_and_pdf(_sample, interaction, cache);
151151
}
152152

153-
SCookTorrance<Config, ndf_type, fresnel_type, false> __base;
153+
SCookTorrance<Config, ndf_type, fresnel_type> __base;
154154
};
155155

156156
}

include/nbl/builtin/hlsl/bxdf/reflection/ggx.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct SGGXIsotropic
9292
return __base.quotient_and_pdf(_sample, interaction.isotropic, cache.iso_cache);
9393
}
9494

95-
SCookTorrance<Config, ndf_type, fresnel_type, false> __base;
95+
SCookTorrance<Config, ndf_type, fresnel_type> __base;
9696
};
9797

9898
template<class Config NBL_PRIMARY_REQUIRES(config_concepts::MicrofacetConfiguration<Config>)
@@ -151,7 +151,7 @@ struct SGGXAnisotropic
151151
return __base.quotient_and_pdf(_sample, interaction, cache);
152152
}
153153

154-
SCookTorrance<Config, ndf_type, fresnel_type, false> __base;
154+
SCookTorrance<Config, ndf_type, fresnel_type> __base;
155155
};
156156

157157
}

include/nbl/builtin/hlsl/bxdf/transmission/beckmann.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct SBeckmannDielectricIsotropic
9797
return __base.quotient_and_pdf(_sample, interaction.isotropic, cache.iso_cache);
9898
}
9999

100-
SCookTorrance<Config, ndf_type, fresnel_type, true> __base;
100+
SCookTorrance<Config, ndf_type, fresnel_type> __base;
101101
};
102102

103103
template<class Config NBL_PRIMARY_REQUIRES(config_concepts::MicrofacetConfiguration<Config>)
@@ -168,7 +168,7 @@ struct SBeckmannDielectricAnisotropic
168168
return __base.quotient_and_pdf(_sample, interaction, cache);
169169
}
170170

171-
SCookTorrance<Config, ndf_type, fresnel_type, true> __base;
171+
SCookTorrance<Config, ndf_type, fresnel_type> __base;
172172
};
173173

174174
}

include/nbl/builtin/hlsl/bxdf/transmission/ggx.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct SGGXDielectricIsotropic
9898
return __base.quotient_and_pdf(_sample, interaction.isotropic, cache.iso_cache);
9999
}
100100

101-
SCookTorrance<Config, ndf_type, fresnel_type, true> __base;
101+
SCookTorrance<Config, ndf_type, fresnel_type> __base;
102102
};
103103

104104
template<class Config NBL_PRIMARY_REQUIRES(config_concepts::MicrofacetConfiguration<Config>)
@@ -169,7 +169,7 @@ struct SGGXDielectricAnisotropic
169169
return __base.quotient_and_pdf(_sample, interaction, cache);
170170
}
171171

172-
SCookTorrance<Config, ndf_type, fresnel_type, true> __base;
172+
SCookTorrance<Config, ndf_type, fresnel_type> __base;
173173
};
174174

175175
}

0 commit comments

Comments
 (0)