Skip to content

Hlsl bxdfs 3 #899

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

Open
wants to merge 208 commits into
base: master
Choose a base branch
from
Open

Hlsl bxdfs 3 #899

wants to merge 208 commits into from

Conversation

devshgraphicsprogramming
Copy link
Member

Description

Continuing #811 due to GH UI messing up diffs again

Testing

TODO list:

Comment on lines +100 to +101
using params_isotropic_t = OrenNayarParams<sample_type, isotropic_interaction_type, scalar_type>;
using params_anisotropic_t = OrenNayarParams<sample_type, anisotropic_interaction_type, scalar_type>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing again

@@ -596,7 +596,6 @@ struct beta_helper<T NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T>) >
// implementation from Numerical Recipes in C, 2nd ed.
static T __call(T v1, T v2)
{
// specialized for Cook Torrance BTDFs
assert(v1 >= 1.0 && v2 >= 1.0);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok you removed the comment, but not the assert :P

NBL_CONCEPT_END(
((NBL_CONCEPT_REQ_TYPE)(T::scalar_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getNdf()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getMaxNdotV()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already provided by the interaction

NBL_CONCEPT_END(
((NBL_CONCEPT_REQ_TYPE)(T::scalar_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getNdf()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getAbsNdotV()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provided by the interaction

#define query NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
NBL_CONCEPT_END(
((NBL_CONCEPT_REQ_TYPE)(T::scalar_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getTransmitted()), ::nbl::hlsl::is_same_v, bool))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provided by microfacet cache

Comment on lines 88 to 91
template<class Query NBL_FUNC_REQUIRES(beckmann_concepts::DG1BrdfQuery<Query>)
scalar_type DG1(NBL_REF_ARG(Query) query)
{
onePlusLambda_V = scalar_type(1.0) + lambda_V;
return ndf::microfacet_to_light_measure_transform<scalar_type,false,ndf::MTT_REFLECT>::__call(ndf / onePlusLambda_V, maxNdotV);
query.onePlusLambda_V = scalar_type(1.0) + query.getLambdaV();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're assuming there's a member to set, remove this line

{
onePlusLambda_V = scalar_type(1.0) + lambda_V;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing

return scalar_type(1.0) / (scalar_type(1.0) + L_v + L_l);
scalar_type lambda_V = LambdaC2(interaction.getNdotV2());
scalar_type lambda_L = LambdaC2(_sample.getNdotL2());
return scalar_type(1.0) / (scalar_type(1.0) + lambda_V + lambda_L);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do G1, Lambda, un terms of queries

{
scalar_type lambdaL = LambdaC2(NdotL2);
return lambdaV_plus_one * hlsl::mix(scalar_type(1.0)/(lambdaV_plus_one + lambdaL), hlsl::beta<scalar_type>(lambdaV_plus_one, scalar_type(1.0) + lambdaL), transmitted);
scalar_type lambda_L = LambdaC2(_sample.getNdotL2());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query.getLambdaL()

Comment on lines 205 to 214
scalar_type lambda_V = LambdaC2(interaction.getTdotV2(), interaction.getBdotV2(), interaction.getNdotV2());
scalar_type lambda_L = LambdaC2(_sample.getTdotL2(), _sample.getBdotL2(), _sample.getNdotL2());
return scalar_type(1.0) / (scalar_type(1.0) + lambda_V + lambda_L);
}

scalar_type G2_over_G1(bool transmitted, scalar_type TdotL2, scalar_type BdotL2, scalar_type NdotL2, scalar_type lambdaV_plus_one)
template<class Query, class LS NBL_FUNC_REQUIRES(beckmann_concepts::G2overG1Query<Query> && LightSample<LS>)
scalar_type G2_over_G1(NBL_CONST_REF_ARG(Query) query, NBL_CONST_REF_ARG(LS) _sample)
{
scalar_type lambdaL = LambdaC2(TdotL2, BdotL2, NdotL2);
return lambdaV_plus_one * hlsl::mix(scalar_type(1.0)/(lambdaV_plus_one + lambdaL), hlsl::beta<scalar_type>(lambdaV_plus_one, scalar_type(1.0) + lambdaL), transmitted);
scalar_type lambda_L = LambdaC2(_sample.getTdotL2(), _sample.getBdotL2(), _sample.getNdotL2());
return query.getOnePlusLambdaV() * hlsl::mix(scalar_type(1.0)/(query.getOnePlusLambdaV() + lambda_L), bxdf::beta<scalar_type>(query.getOnePlusLambdaV(), scalar_type(1.0) + lambda_L), query.getTransmitted());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lambda values need to come from queries

((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getNdf()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getG1over2NdotV()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getTransmitted()), ::nbl::hlsl::is_same_v, bool))
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((query.getOrientedEta()), ::nbl::hlsl::is_same_v, typename T::scalar_type))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write a comment about why NDF cares about stuff that has only things to do with Fresnel (its the geometrical differential refraction factor from transforming V into L )

Comment on lines 107 to 110
template<class LS, class Interaction NBL_FUNC_REQUIRES(LightSample<LS> && surface_interactions::Isotropic<Interaction>)
scalar_type correlated_wo_numerator(NBL_CONST_REF_ARG(LS) _sample, NBL_CONST_REF_ARG(Interaction) interaction, BxDFClampMode _clamp)
{
scalar_type Vterm = absNdotL * devsh_part(NdotV2);
scalar_type Lterm = absNdotV * devsh_part(NdotL2);
// numerator is 2 * NdotV * NdotL, we factor out 4 * NdotV * NdotL, hence 0.5
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert that the clamp mode is NOT unclamped

Comment on lines 212 to 224
if (transmitted)
{
if (NdotV < 1e-7 || NdotL < 1e-7)
return 0.0;
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_part(TdotV2, BdotV2, NdotV2) / NdotV + scalar_type(1.0));
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_part(TdotL2, BdotL2, NdotL2) / NdotL + scalar_type(1.0));
G2_over_G1 = hlsl::beta<scalar_type>(onePlusLambda_L, onePlusLambda_V) * onePlusLambda_V;
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_part(interaction.getTdotV2(), interaction.getBdotV2(), interaction.getNdotV2()) / NdotV + scalar_type(1.0));
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_part(_sample.getTdotL2(), _sample.getBdotL2(), _sample.getNdotL2()) / NdotL + scalar_type(1.0));
G2_over_G1 = bxdf::beta<scalar_type>(onePlusLambda_L, onePlusLambda_V) * onePlusLambda_V;
}
else
{
scalar_type devsh_v = devsh_part(TdotV2, BdotV2, NdotV2);
scalar_type devsh_v = devsh_part(interaction.getTdotV2(), interaction.getBdotV2(), interaction.getNdotV2());
G2_over_G1 = NdotL * (devsh_v + NdotV);
G2_over_G1 /= NdotV * devsh_part(TdotL2, BdotL2, NdotL2) + NdotL * devsh_v;
G2_over_G1 /= NdotV * devsh_part(_sample.getTdotL2(), _sample.getBdotL2(), _sample.getNdotL2()) + NdotL * devsh_v;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the devsh_v and devsh_l should come from the query

(this also covers the old #899 (comment) comment)

Comment on lines +210 to +211
scalar_type NdotV = interaction.getNdotV(_clamp);
scalar_type NdotL = _sample.getNdotL(_clamp);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert the clamp mode is not NONE

Comment on lines 106 to 107
NBL_PARTIAL_REQ_TOP(LightSample<LS> && surface_interactions::Isotropic<Interaction> && !surface_interactions::Anisotropic<Interaction> && CreatableIsotropicMicrofacetCache<MicrofacetCache> && !AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>)
struct SMicrofacetConfiguration<LS,Interaction,MicrofacetCache,Spectrum NBL_PARTIAL_REQ_BOT(LightSample<LS> && surface_interactions::Isotropic<Interaction> && !surface_interactions::Anisotropic<Interaction> && CreatableIsotropicMicrofacetCache<MicrofacetCache> && !AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>) >
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a prime site to do

#define COND LightSample<LS> && surface_interactions::Isotropic<Interaction> && !surface_interactions::Anisotropic<Interaction> && \
CreatableIsotropicMicrofacetCache<MicrofacetCache> && !AnisotropicMicrofacetCache<MicrofacetCache> && \
concepts::FloatingPointLikeVectorial<Spectrum>

template<...> NBL_PARTIAL_REQ_TOP(COND)
struct SMicrofacetConfiguration NBL_PARTIAL_REQ_BOTTOM(COND)
#undef COND
{

just to not trip up

Comment on lines 212 to 225
if (transmitted)
{
if (NdotV < 1e-7 || NdotL < 1e-7)
return 0.0;
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_part(TdotV2, BdotV2, NdotV2) / NdotV + scalar_type(1.0));
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_part(TdotL2, BdotL2, NdotL2) / NdotL + scalar_type(1.0));
G2_over_G1 = hlsl::beta<scalar_type>(onePlusLambda_L, onePlusLambda_V) * onePlusLambda_V;
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_part(interaction.getTdotV2(), interaction.getBdotV2(), interaction.getNdotV2()) / NdotV + scalar_type(1.0));
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_part(_sample.getTdotL2(), _sample.getBdotL2(), _sample.getNdotL2()) / NdotL + scalar_type(1.0));
G2_over_G1 = bxdf::beta<scalar_type>(onePlusLambda_L, onePlusLambda_V) * onePlusLambda_V;
}
else
{
scalar_type devsh_v = devsh_part(TdotV2, BdotV2, NdotV2);
scalar_type devsh_v = devsh_part(interaction.getTdotV2(), interaction.getBdotV2(), interaction.getNdotV2());
G2_over_G1 = NdotL * (devsh_v + NdotV);
G2_over_G1 /= NdotV * devsh_part(TdotL2, BdotL2, NdotL2) + NdotL * devsh_v;
G2_over_G1 /= NdotV * devsh_part(_sample.getTdotL2(), _sample.getBdotL2(), _sample.getNdotL2()) + NdotL * devsh_v;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again same comment as for isotropic

Comment on lines 105 to 149
template<class LS, class Interaction, class MicrofacetCache, class Spectrum>
NBL_PARTIAL_REQ_TOP(LightSample<LS> && surface_interactions::Isotropic<Interaction> && !surface_interactions::Anisotropic<Interaction> &&
CreatableIsotropicMicrofacetCache<MicrofacetCache> && !AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>)
struct SMicrofacetConfiguration<LS,Interaction,MicrofacetCache,Spectrum NBL_PARTIAL_REQ_BOT(LightSample<LS> && surface_interactions::Isotropic<Interaction> && !surface_interactions::Anisotropic<Interaction> &&
CreatableIsotropicMicrofacetCache<MicrofacetCache> && !AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>) >
{
NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = false;

using scalar_type = typename LS::scalar_type;
using ray_dir_info_type = typename LS::ray_dir_info_type;
using vector2_type = vector<scalar_type, 2>;
using vector3_type = vector<scalar_type, 3>;
using matrix3x3_type = matrix<scalar_type,3,3>;
using monochrome_type = vector<scalar_type, 1>;

using isotropic_interaction_type = Interaction;
using anisotropic_interaction_type = surface_interactions::SAnisotropic<isotropic_interaction_type>;
using sample_type = LS;
using spectral_type = Spectrum;
using quotient_pdf_type = sampling::quotient_and_pdf<spectral_type, scalar_type>;
using isocache_type = MicrofacetCache;
using anisocache_type = SAnisotropicMicrofacetCache<isocache_type>;
};

template<class LS, class Interaction, class MicrofacetCache, class Spectrum>
NBL_PARTIAL_REQ_TOP(LightSample<LS> && surface_interactions::Anisotropic<Interaction> && AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>)
struct SMicrofacetConfiguration<LS,Interaction,MicrofacetCache,Spectrum NBL_PARTIAL_REQ_BOT(LightSample<LS> && surface_interactions::Anisotropic<Interaction> && AnisotropicMicrofacetCache<MicrofacetCache> && concepts::FloatingPointLikeVectorial<Spectrum>) >
{
NBL_CONSTEXPR_STATIC_INLINE bool IsAnisotropic = true;

using scalar_type = typename LS::scalar_type;
using ray_dir_info_type = typename LS::ray_dir_info_type;
using vector2_type = vector<scalar_type, 2>;
using vector3_type = vector<scalar_type, 3>;
using matrix3x3_type = matrix<scalar_type,3,3>;
using monochrome_type = vector<scalar_type, 1>;

using isotropic_interaction_type = typename Interaction::isotropic_interaction_type;
using anisotropic_interaction_type = Interaction;
using sample_type = LS;
using spectral_type = Spectrum;
using quotient_pdf_type = sampling::quotient_and_pdf<spectral_type, scalar_type>;
using isocache_type = typename MicrofacetCache::isocache_type;
using anisocache_type = MicrofacetCache;
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could inherit from the basic config to save yourself some trouble

Comment on lines +18 to +61
#define NBL_CONCEPT_NAME BasicConfiguration
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
#define NBL_CONCEPT_PARAM_0 (conf, T)
NBL_CONCEPT_BEGIN(1)
#define conf NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
NBL_CONCEPT_END(
((NBL_CONCEPT_REQ_TYPE)(T::scalar_type))
((NBL_CONCEPT_REQ_TYPE)(T::vector2_type))
((NBL_CONCEPT_REQ_TYPE)(T::vector3_type))
((NBL_CONCEPT_REQ_TYPE)(T::ray_dir_info_type))
((NBL_CONCEPT_REQ_TYPE)(T::isotropic_interaction_type))
((NBL_CONCEPT_REQ_TYPE)(T::anisotropic_interaction_type))
((NBL_CONCEPT_REQ_TYPE)(T::sample_type))
((NBL_CONCEPT_REQ_TYPE)(T::spectral_type))
((NBL_CONCEPT_REQ_TYPE)(T::quotient_pdf_type))
);
#undef conf
#include <nbl/builtin/hlsl/concepts/__end.hlsl>

#define NBL_CONCEPT_NAME MicrofacetConfiguration
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)
#define NBL_CONCEPT_PARAM_0 (conf, T)
NBL_CONCEPT_BEGIN(1)
#define conf NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0
NBL_CONCEPT_END(
((NBL_CONCEPT_REQ_TYPE)(T::scalar_type))
((NBL_CONCEPT_REQ_TYPE)(T::vector2_type))
((NBL_CONCEPT_REQ_TYPE)(T::vector3_type))
((NBL_CONCEPT_REQ_TYPE)(T::monochrome_type))
((NBL_CONCEPT_REQ_TYPE)(T::matrix3x3_type))
((NBL_CONCEPT_REQ_TYPE)(T::ray_dir_info_type))
((NBL_CONCEPT_REQ_TYPE)(T::isotropic_interaction_type))
((NBL_CONCEPT_REQ_TYPE)(T::anisotropic_interaction_type))
((NBL_CONCEPT_REQ_TYPE)(T::sample_type))
((NBL_CONCEPT_REQ_TYPE)(T::spectral_type))
((NBL_CONCEPT_REQ_TYPE)(T::quotient_pdf_type))
((NBL_CONCEPT_REQ_TYPE)(T::isocache_type))
((NBL_CONCEPT_REQ_TYPE)(T::anisocache_type))
);
#undef conf
#include <nbl/builtin/hlsl/concepts/__end.hlsl>
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho the configurations shouldn't be open ended, write a TODO that you should just check is_base_of (but its not possible right now cause of DXC limitations)

Scalar getNdotL2() NBL_CONST_MEMBER_FUNC { return _sample.getNdotL2(); }
Scalar getVdotL() NBL_CONST_MEMBER_FUNC { return _sample.getVdotL(); }
Scalar getVdotL() NBL_CONST_MEMBER_FUNC { return cache.getVdotL(); }
Scalar getNdotH() NBL_CONST_MEMBER_FUNC { return cache.getNdotH(); }
Scalar getNdotH2() NBL_CONST_MEMBER_FUNC { return cache.getNdotH2(); }
Scalar getVdotH() NBL_CONST_MEMBER_FUNC { return cache.getVdotH(); }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameter structs are not needed

using scalar_type = T;

scalar_type getNdf() NBL_CONST_MEMBER_FUNC { return ndf; }
scalar_type getMaxNdotV() NBL_CONST_MEMBER_FUNC { return maxNdotV; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provided by the interaction

Comment on lines +115 to +127
};

template<typename T>
struct SBeckmannG2overG1Query
{
using scalar_type = T;

bool getTransmitted() NBL_CONST_MEMBER_FUNC { return transmitted; }
scalar_type getOnePlusLambdaV() NBL_CONST_MEMBER_FUNC { return onePlusLambda_V; }

bool transmitted;
scalar_type onePlusLambda_V;
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does DXC's clang allow you to define a struct inside of a method? then you wouldn't need to have them hanging out freeley and they'd perform the role of a lambda

Comment on lines 136 to 147
using scalar_type = typename Config::scalar_type;
using vector2_type = vector<scalar_type, 2>;
using vector3_type = vector<scalar_type, 3>;
using ray_dir_info_type = typename Config::ray_dir_info_type;

using isotropic_interaction_type = Iso;
using anisotropic_interaction_type = Aniso;
using sample_type = LS;
using spectral_type = Spectrum;
using isotropic_interaction_type = typename Config::isotropic_interaction_type;
using anisotropic_interaction_type = typename Config::anisotropic_interaction_type;
using sample_type = typename Config::sample_type;
using spectral_type = typename Config::spectral_type;
using quotient_pdf_type = sampling::quotient_and_pdf<spectral_type, scalar_type>;
using isocache_type = IsoCache;
using anisocache_type = AnisoCache;

using params_isotropic_t = BeckmannParams<LS, Iso, IsoCache, scalar_type>;
using params_anisotropic_t = BeckmannParams<LS, Aniso, AnisoCache, scalar_type>;
using isocache_type = typename Config::isocache_type;
using anisocache_type = typename Config::anisocache_type;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm lets maybe have a NBL_BXDF_ prefixed macro for this, seems every BRDF needs to do the aliasing

Comment on lines 153 to 160
static this_t create(scalar_type A, NBL_CONST_REF_ARG(spectral_type) ior0, NBL_CONST_REF_ARG(spectral_type) ior1)
{
this_t retval;
retval.A = vector2_type(A,A);
retval.ior0 = ior0;
retval.ior1 = ior1;
return retval;
}

// aniso
static this_t create(scalar_type ax, scalar_type ay, NBL_CONST_REF_ARG(spectral_type) ior0, NBL_CONST_REF_ARG(spectral_type) ior1)
{
this_t retval;
retval.A = vector2_type(ax,ay);
retval.A = A;
retval.ior0 = ior0;
retval.ior1 = ior1;
return retval;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure the create method is useful

Comment on lines +202 to +204
scalar_type a2 = A*A;
ndf::Beckmann<scalar_type, false> beckmann_ndf;
beckmann_ndf.a2 = a2;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you storing A as a member when you could store the parametrized NDF instead ?

btw seems that CookTorrance is a good idea as there's really not much difference between GGX and beckmann BRDF and BTDF

}

scalar_type A;
spectral_type ior0, ior1;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why store ior instead of oriented Etas ?

Comment on lines 88 to 135
Scalar getTdotL2() NBL_CONST_MEMBER_FUNC { return _sample.getTdotL2(); }
Scalar getBdotL2() NBL_CONST_MEMBER_FUNC { return _sample.getBdotL2(); }
Scalar getTdotV2() NBL_CONST_MEMBER_FUNC { return interaction.getTdotV2(); }
Scalar getBdotV2() NBL_CONST_MEMBER_FUNC { return interaction.getBdotV2(); }
Scalar getTdotH2() NBL_CONST_MEMBER_FUNC { return cache.getTdotH2(); }
Scalar getBdotH2() NBL_CONST_MEMBER_FUNC { return cache.getBdotH2(); }

LS _sample;
SI interaction;
MC cache;
BxDFClampMode _clamp;
};

template<class LS, class Iso, class Aniso, class IsoCache, class AnisoCache, class Spectrum NBL_PRIMARY_REQUIRES(LightSample<LS> && surface_interactions::Isotropic<Iso> && surface_interactions::Anisotropic<Aniso> && CreatableIsotropicMicrofacetCache<IsoCache> && AnisotropicMicrofacetCache<AnisoCache>)
struct SGGXBxDF
template<typename T>
struct SGGXDG1Query
{
using this_t = SGGXBxDF<LS, Iso, Aniso, IsoCache, AnisoCache, Spectrum>;
using scalar_type = typename LS::scalar_type;
using ray_dir_info_type = typename LS::ray_dir_info_type;
using scalar_type = T;

scalar_type getNdf() NBL_CONST_MEMBER_FUNC { return ndf; }
scalar_type getG1over2NdotV() NBL_CONST_MEMBER_FUNC { return G1_over_2NdotV; }

scalar_type ndf;
scalar_type G1_over_2NdotV;
};

template<class Config NBL_STRUCT_CONSTRAINABLE>
struct SGGXAnisotropicBxDF;

template<class Config NBL_PRIMARY_REQUIRES(config_concepts::MicrofacetConfiguration<Config>)
struct SGGXIsotropicBxDF
{
using this_t = SGGXIsotropicBxDF<Config>;
using scalar_type = typename Config::scalar_type;
using vector2_type = vector<scalar_type, 2>;
using vector3_type = vector<scalar_type, 3>;
using matrix2x3_type = matrix<scalar_type,3,2>;
using ray_dir_info_type = typename Config::ray_dir_info_type;

using isotropic_interaction_type = Iso;
using anisotropic_interaction_type = Aniso;
using sample_type = LS;
using spectral_type = Spectrum;
using isotropic_interaction_type = typename Config::isotropic_interaction_type;
using anisotropic_interaction_type = typename Config::anisotropic_interaction_type;
using sample_type = typename Config::sample_type;
using spectral_type = typename Config::spectral_type;
using quotient_pdf_type = sampling::quotient_and_pdf<spectral_type, scalar_type>;
using isocache_type = IsoCache;
using anisocache_type = AnisoCache;
using isocache_type = typename Config::isocache_type;
using anisocache_type = typename Config::anisocache_type;

using params_isotropic_t = GGXParams<LS, Iso, IsoCache, scalar_type>;
using params_anisotropic_t = GGXParams<LS, Aniso, AnisoCache, scalar_type>;
using params_isotropic_t = GGXParams<sample_type, isotropic_interaction_type, isocache_type, scalar_type>;
using params_anisotropic_t = GGXParams<sample_type, anisotropic_interaction_type, anisocache_type, scalar_type>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar insights as Beckmann

return quotient_pdf_type::create(hlsl::promote<spectral_type>(quo), _pdf);
}

scalar_type A;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not store the NDF instead of its parameters, also transmission should store orientedEtas

Cook Torrance brdf and bsdf would help a lot here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants