-
Notifications
You must be signed in to change notification settings - Fork 66
Bxdf fixes cook torrance #930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
5218545
f7525af
c50db68
c49bedb
319c954
4eeacf1
e7bc784
72226bb
f34b348
ad13044
d8d2116
238b08e
8bc707f
9fb28cf
4cb8a0a
392dc31
02de86e
4a7f532
80c4f67
6233bd1
ce5fbac
47e814b
c983975
0f2ee0b
b5f02e6
a111415
9655049
a1743d2
e6d663b
340cee3
a3733b1
3e3589b
4bdf199
4faecc3
407da2f
638b8b5
c587820
d438360
5f49f11
627074b
3896231
91b39d5
2a3cda3
c9f9366
fd128e6
882375e
b22d570
c0586f5
9eeb248
26c76e4
58e2a0b
2a08728
b993e47
f3cb6ff
7389c9a
ec5913b
bccdb0b
1e9e407
dab51c3
53ab934
804014f
260f7a3
fd54ac4
5caf006
7508b82
2b4a9c1
d3fa872
5765e87
23763e2
069f499
22c4918
dcc2464
7aa071b
97e5ce3
6272281
b55bdef
444b656
971e140
6a0e28d
f93772e
3519866
2a7cf4b
79aea6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,21 +16,6 @@ namespace bxdf | |
namespace ndf | ||
{ | ||
|
||
namespace impl | ||
{ | ||
template<typename T> | ||
struct NDFQuantQuery | ||
{ | ||
using scalar_type = T; | ||
|
||
scalar_type getVdotHLdotH() NBL_CONST_MEMBER_FUNC { return VdotHLdotH; } | ||
scalar_type getVdotH_etaLdotH() NBL_CONST_MEMBER_FUNC { return VdotH_etaLdotH; } | ||
|
||
scalar_type VdotHLdotH; | ||
scalar_type VdotH_etaLdotH; | ||
}; | ||
} | ||
|
||
namespace dummy_impl | ||
{ | ||
using sample_t = SLightSample<ray_dir_info::SBasic<float> >; | ||
|
@@ -76,6 +61,29 @@ NBL_CONCEPT_END( | |
#undef ndf | ||
#include <nbl/builtin/hlsl/concepts/__end.hlsl> | ||
|
||
|
||
#define NDF_CONSTEXPR_DECLS(ANISO,REFLECT_REFRACT) NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = ANISO;\ | ||
NBL_CONSTEXPR_STATIC_INLINE MicrofacetTransformTypes SupportedPaths = REFLECT_REFRACT;\ | ||
NBL_CONSTEXPR_STATIC_INLINE bool SupportsTransmission = REFLECT_REFRACT != MTT_REFLECT;\ | ||
NBL_CONSTEXPR_STATIC_INLINE BxDFClampMode _clamp = SupportsTransmission ? BxDFClampMode::BCM_ABS : BxDFClampMode::BCM_NONE;\ | ||
template<class Interaction>\ | ||
NBL_CONSTEXPR_STATIC_INLINE bool RequiredInteraction = IsAnisotropic ? surface_interactions::Anisotropic<Interaction> : surface_interactions::Isotropic<Interaction>;\ | ||
template<class MicrofacetCache>\ | ||
NBL_CONSTEXPR_STATIC_INLINE bool RequiredMicrofacetCache = IsAnisotropic ? AnisotropicMicrofacetCache<MicrofacetCache> : ReadableIsotropicMicrofacetCache<MicrofacetCache>;\ | ||
|
||
// help avoid preprocessor splitting template declarations by comma | ||
#define SINGLE_ARG(...) __VA_ARGS__ | ||
|
||
|
||
#define NDF_TYPE_ALIASES(N,BASE,DG1_QUERY,G2_QUERY,QUANT_QUERY) using this_t = N;\ | ||
using scalar_type = T;\ | ||
using base_type = BASE;\ | ||
using quant_type = SDualMeasureQuant<scalar_type>;\ | ||
using vector2_type = vector<T, 2>;\ | ||
using vector3_type = vector<T, 3>;\ | ||
using dg1_query_type = DG1_QUERY;\ | ||
using g2g1_query_type = G2_QUERY;\ | ||
using quant_query_type = QUANT_QUERY;\ | ||
|
||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,24 +298,8 @@ struct BeckmannGenerateH | |
template<typename T, bool _IsAnisotropic, MicrofacetTransformTypes reflect_refract NBL_PRIMARY_REQUIRES(concepts::FloatingPointScalar<T>) | ||
struct Beckmann | ||
{ | ||
using this_t = Beckmann<T, _IsAnisotropic, reflect_refract>; | ||
using scalar_type = T; | ||
using base_type = impl::BeckmannCommon<T,_IsAnisotropic>; | ||
using quant_type = SDualMeasureQuant<scalar_type>; | ||
using vector2_type = vector<T, 2>; | ||
using vector3_type = vector<T, 3>; | ||
|
||
using dg1_query_type = impl::SBeckmannDG1Query<scalar_type>; | ||
using g2g1_query_type = impl::SBeckmannG2overG1Query<scalar_type>; | ||
using quant_query_type = impl::NDFQuantQuery<scalar_type>; | ||
|
||
NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = _IsAnisotropic; | ||
NBL_CONSTEXPR_STATIC_INLINE MicrofacetTransformTypes NDFSurfaceType = reflect_refract; | ||
NBL_CONSTEXPR_STATIC_INLINE bool IsBSDF = reflect_refract != MTT_REFLECT; | ||
template<class Interaction> | ||
NBL_CONSTEXPR_STATIC_INLINE bool RequiredInteraction = IsAnisotropic ? surface_interactions::Anisotropic<Interaction> : surface_interactions::Isotropic<Interaction>; | ||
template<class MicrofacetCache> | ||
NBL_CONSTEXPR_STATIC_INLINE bool RequiredMicrofacetCache = IsAnisotropic ? AnisotropicMicrofacetCache<MicrofacetCache> : ReadableIsotropicMicrofacetCache<MicrofacetCache>; | ||
NDF_CONSTEXPR_DECLS(_IsAnisotropic,reflect_refract); | ||
NDF_TYPE_ALIASES(SINGLE_ARG(Beckmann<T,IsAnisotropic,SupportedPaths>), SINGLE_ARG(impl::BeckmannCommon<T,IsAnisotropic>), impl::SBeckmannDG1Query<scalar_type>, impl::SBeckmannG2overG1Query<scalar_type>, DualMeasureQuantQuery<scalar_type>); | ||
|
||
|
||
template<typename C=bool_constant<!IsAnisotropic> > | ||
static enable_if_t<C::value && !IsAnisotropic, this_t> create(scalar_type A) | ||
|
@@ -338,18 +322,15 @@ struct Beckmann | |
return retval; | ||
} | ||
|
||
template<class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>) | ||
enable_if_t<C::value && !IsBSDF, quant_query_type> createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta) | ||
template<class MicrofacetCache NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>) | ||
quant_query_type createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta) | ||
{ | ||
quant_query_type dummy; // brdfs don't make use of this | ||
return dummy; | ||
} | ||
template<class MicrofacetCache, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES(RequiredMicrofacetCache<MicrofacetCache>) | ||
enable_if_t<C::value && IsBSDF, quant_query_type> createQuantQuery(NBL_CONST_REF_ARG(MicrofacetCache) cache, scalar_type orientedEta) | ||
{ | ||
quant_query_type quant_query; | ||
quant_query.VdotHLdotH = cache.getVdotHLdotH(); | ||
quant_query.VdotH_etaLdotH = cache.getVdotH() + orientedEta * cache.getLdotH(); | ||
quant_query_type quant_query; // only has members for refraction | ||
if (SupportsTransmission) | ||
{ | ||
quant_query.VdotHLdotH = cache.getVdotHLdotH(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a comment that even though in PBRT its There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or where the |
||
quant_query.VdotH_etaLdotH = cache.getVdotH() + orientedEta * cache.getLdotH(); | ||
} | ||
return quant_query; | ||
} | ||
template<class Interaction, class MicrofacetCache, typename C=bool_constant<!IsAnisotropic> NBL_FUNC_REQUIRES(RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>) | ||
|
@@ -390,27 +371,27 @@ struct Beckmann | |
return __generate_base.__call(localV, u); | ||
} | ||
|
||
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>) | ||
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) | ||
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<!SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>) | ||
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) | ||
{ | ||
scalar_type d = __ndf_base.template D<MicrofacetCache>(cache); | ||
return createDualMeasureQuantity<T>(d, interaction.getNdotV(BxDFClampMode::BCM_MAX), _sample.getNdotL(BxDFClampMode::BCM_MAX)); | ||
} | ||
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>) | ||
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) | ||
template<class LS, class Interaction, class MicrofacetCache, typename C=bool_constant<SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction> && RequiredMicrofacetCache<MicrofacetCache>) | ||
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) | ||
{ | ||
scalar_type d = __ndf_base.template D<MicrofacetCache>(cache); | ||
return createDualMeasureQuantity<T, reflect_refract>(d, interaction.getNdotV(BxDFClampMode::BCM_ABS), _sample.getNdotL(BxDFClampMode::BCM_ABS), quant_query.getVdotHLdotH(), quant_query.getVdotH_etaLdotH()); | ||
} | ||
|
||
template<class LS, class Interaction, typename C=bool_constant<!IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>) | ||
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) | ||
template<class LS, class Interaction, typename C=bool_constant<!SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>) | ||
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) | ||
{ | ||
scalar_type dg1 = base_type::template DG1<dg1_query_type>(query); | ||
return createDualMeasureQuantity<T>(dg1, interaction.getNdotV(BxDFClampMode::BCM_MAX), _sample.getNdotL(BxDFClampMode::BCM_MAX)); | ||
} | ||
template<class LS, class Interaction, typename C=bool_constant<IsBSDF> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>) | ||
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) | ||
template<class LS, class Interaction, typename C=bool_constant<SupportsTransmission> NBL_FUNC_REQUIRES(LightSample<LS> && RequiredInteraction<Interaction>) | ||
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) | ||
{ | ||
scalar_type dg1 = base_type::template DG1<dg1_query_type>(query); | ||
return createDualMeasureQuantity<T, reflect_refract>(dg1, interaction.getNdotV(BxDFClampMode::BCM_ABS), _sample.getNdotL(BxDFClampMode::BCM_ABS), quant_query.getVdotHLdotH(), quant_query.getVdotH_etaLdotH()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,18 @@ enum MicrofacetTransformTypes : uint16_t | |
MTT_REFLECT_REFRACT = 0b11 | ||
}; | ||
|
||
template<typename T> | ||
struct DualMeasureQuantQuery | ||
{ | ||
using scalar_type = T; | ||
|
||
scalar_type getVdotHLdotH() NBL_CONST_MEMBER_FUNC { return VdotHLdotH; } | ||
scalar_type getVdotH_etaLdotH() NBL_CONST_MEMBER_FUNC { return VdotH_etaLdotH; } | ||
|
||
scalar_type VdotHLdotH; | ||
scalar_type VdotH_etaLdotH; | ||
|
||
}; | ||
|
||
|
||
template<typename T> | ||
struct SDualMeasureQuant | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why make
static
and pass thef
if its your member?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it because the fresnel is already properly oriented? then give
f
a clear name likereorientedFresnel
and since its
static
you may as well make the__checkValid
into a standalone struct functor with a partial spec onIsBSDF
, that way you don't callimpl::check_TIR_helper
but you can callcache.isValid(reorientedFresnel.getRefractionOrientedEta())
directlyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually if you use
impl::checkValid<IsBSDF>::template __call()
hereNabla/include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl
Lines 350 to 351 in dcc2464
then there's no need to have an
impl::check_TIR_helper
at all