-
Notifications
You must be signed in to change notification settings - Fork 67
Iridescent fresnel, bxdfs #918
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
keptsecret
wants to merge
29
commits into
master
Choose a base branch
from
iridescence_bxdf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+790
−268
Open
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
4b3224a
initial iridescent fresnel, only single channel ior
keptsecret 9c71906
iridescent fresnel does rgb IOR, use in brdf
keptsecret 0f51306
some bug fixes
keptsecret f205d4e
replace loop for vector operations in fresnel
keptsecret f6daa6f
added iridescent btdf
keptsecret 09402ea
added unit tests
keptsecret a77c337
merge bxdfs, fix conflicts
keptsecret aa0f6e8
latest example
keptsecret d2cb193
moved colorspace transform mats into struct functions
keptsecret 33fc955
some more colorspace utility
keptsecret 0f6c7a2
merge latest bxdf_fixes, fix conflicts
keptsecret d8b6773
restore encode/decode matrices
keptsecret 65239d9
colorspace specific dominant wavelengths (still missing ACES), use gl…
keptsecret 9a8b77e
update iridescent fresnel to match fresnel concept
keptsecret 702ec8d
Merge branch 'master' into iridescence_bxdf
keptsecret 76ad0ed
minor typo fixes
keptsecret 53c930f
minor fixes to cook torrance, ndf infinity, move util functions into …
keptsecret 23de8ed
changes to angle adding usage
keptsecret ff9e03f
better orthonormality for H
keptsecret 18b3922
minor change to ggx clamp
keptsecret a5d8f5c
Merge branch 'master' into iridescence_bxdf
keptsecret f3dd05c
minor changes to create complex_t in angle_adding
keptsecret 68d3614
refactor out common section of cook torrance generate
keptsecret aebfecf
added luma contribution hint, getPrefixThroughputWeights to interacti…
keptsecret b53fa1b
cook torrance bsdf can use spectral fresnel, uses interaction.getPref…
keptsecret 946b050
thin smooth dielectric use luma coeff from interaction
keptsecret 1a2f561
split iridescent fresnel by SupportsTransmission, adjusted fresnel co…
keptsecret 4b8a06b
fix edge cases for iridescent fresnel
keptsecret 5782a49
removed redundant weight in interaction
keptsecret File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule examples_tests
updated
8 files
268 changes: 129 additions & 139 deletions
268
include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -188,11 +188,14 @@ NBL_CONCEPT_END( | |
| ((NBL_CONCEPT_REQ_TYPE)(T::ray_dir_info_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::scalar_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::vector3_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::spectral_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getV()), ::nbl::hlsl::is_same_v, typename T::ray_dir_info_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getN()), ::nbl::hlsl::is_same_v, typename T::vector3_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getNdotV(clampMode)), ::nbl::hlsl::is_same_v, typename T::scalar_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getNdotV2()), ::nbl::hlsl::is_same_v, typename T::scalar_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getPathOrigin()), ::nbl::hlsl::is_same_v, PathOrigin)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getLuminosityContributionHint()), ::nbl::hlsl::is_same_v, typename T::spectral_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((iso.getPrefixThroughputWeights()), ::nbl::hlsl::is_same_v, typename T::spectral_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(normV,normN)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(ray_dir_info::Basic, typename T::ray_dir_info_type)) | ||
| ); | ||
|
|
@@ -202,21 +205,25 @@ NBL_CONCEPT_END( | |
| #undef iso | ||
| #include <nbl/builtin/hlsl/concepts/__end.hlsl> | ||
|
|
||
| template<class RayDirInfo NBL_PRIMARY_REQUIRES(ray_dir_info::Basic<RayDirInfo>) | ||
| template<class RayDirInfo, class Spectrum NBL_PRIMARY_REQUIRES(ray_dir_info::Basic<RayDirInfo> && concepts::FloatingPointLikeVectorial<Spectrum>) | ||
| struct SIsotropic | ||
| { | ||
| using this_t = SIsotropic<RayDirInfo, Spectrum>; | ||
| using ray_dir_info_type = RayDirInfo; | ||
| using scalar_type = typename RayDirInfo::scalar_type; | ||
| using vector3_type = typename RayDirInfo::vector3_type; | ||
| using spectral_type = vector3_type; | ||
|
|
||
| // WARNING: Changed since GLSL, now arguments need to be normalized! | ||
| static SIsotropic<RayDirInfo> create(NBL_CONST_REF_ARG(RayDirInfo) normalizedV, const vector3_type normalizedN) | ||
| static this_t create(NBL_CONST_REF_ARG(RayDirInfo) normalizedV, const vector3_type normalizedN) | ||
| { | ||
| SIsotropic<RayDirInfo> retval; | ||
| this_t retval; | ||
| retval.V = normalizedV; | ||
| retval.N = normalizedN; | ||
| retval.NdotV = nbl::hlsl::dot<vector3_type>(retval.N, retval.V.getDirection()); | ||
| retval.NdotV2 = retval.NdotV * retval.NdotV; | ||
| retval.luminosityContributionHint = hlsl::promote<spectral_type>(1.0); | ||
| retval.throughputWeights = hlsl::promote<spectral_type>(1.0); | ||
|
|
||
| return retval; | ||
| } | ||
|
|
@@ -230,11 +237,20 @@ struct SIsotropic | |
| scalar_type getNdotV2() NBL_CONST_MEMBER_FUNC { return NdotV2; } | ||
|
|
||
| PathOrigin getPathOrigin() NBL_CONST_MEMBER_FUNC { return PathOrigin::PO_SENSOR; } | ||
| spectral_type getLuminosityContributionHint() NBL_CONST_MEMBER_FUNC { return luminosityContributionHint; } | ||
| spectral_type getPrefixThroughputWeights() NBL_CONST_MEMBER_FUNC | ||
| { | ||
| spectral_type prefixThroughputWeights = luminosityContributionHint * throughputWeights; | ||
| return prefixThroughputWeights / math::lpNorm<spectral_type,1>(prefixThroughputWeights); | ||
| } | ||
|
|
||
| RayDirInfo V; | ||
| vector3_type N; | ||
| scalar_type NdotV; | ||
| scalar_type NdotV2; | ||
|
|
||
| spectral_type luminosityContributionHint; | ||
| spectral_type throughputWeights; // product of all quotients so far | ||
|
||
| }; | ||
|
|
||
| #define NBL_CONCEPT_NAME Anisotropic | ||
|
|
@@ -278,6 +294,7 @@ struct SAnisotropic | |
| using scalar_type = typename ray_dir_info_type::scalar_type; | ||
| using vector3_type = typename ray_dir_info_type::vector3_type; | ||
| using matrix3x3_type = matrix<scalar_type, 3, 3>; | ||
| using spectral_type = typename isotropic_interaction_type::spectral_type; | ||
|
|
||
| // WARNING: Changed since GLSL, now arguments need to be normalized! | ||
| static this_t create( | ||
|
|
@@ -319,6 +336,8 @@ struct SAnisotropic | |
| scalar_type getNdotV(BxDFClampMode _clamp = BxDFClampMode::BCM_NONE) NBL_CONST_MEMBER_FUNC { return isotropic.getNdotV(_clamp); } | ||
| scalar_type getNdotV2() NBL_CONST_MEMBER_FUNC { return isotropic.getNdotV2(); } | ||
| PathOrigin getPathOrigin() NBL_CONST_MEMBER_FUNC { return isotropic.getPathOrigin(); } | ||
| spectral_type getLuminosityContributionHint() NBL_CONST_MEMBER_FUNC { return isotropic.getLuminosityContributionHint(); } | ||
| spectral_type getPrefixThroughputWeights() NBL_CONST_MEMBER_FUNC { return isotropic.getPrefixThroughputWeights(); } | ||
|
|
||
| vector3_type getT() NBL_CONST_MEMBER_FUNC { return T; } | ||
| vector3_type getB() NBL_CONST_MEMBER_FUNC { return B; } | ||
|
|
@@ -345,7 +364,7 @@ struct SAnisotropic | |
| #define NBL_CONCEPT_TPLT_PRM_KINDS (typename) | ||
| #define NBL_CONCEPT_TPLT_PRM_NAMES (T) | ||
| #define NBL_CONCEPT_PARAM_0 (_sample, T) | ||
| #define NBL_CONCEPT_PARAM_1 (inter, surface_interactions::SIsotropic<typename T::ray_dir_info_type>) | ||
| #define NBL_CONCEPT_PARAM_1 (inter, surface_interactions::SIsotropic<typename T::ray_dir_info_type, typename T::vector3_type>) | ||
| #define NBL_CONCEPT_PARAM_2 (rdirinfo, typename T::ray_dir_info_type) | ||
| #define NBL_CONCEPT_PARAM_3 (pV, typename T::vector3_type) | ||
| #define NBL_CONCEPT_PARAM_4 (frame, typename T::matrix3x3_type) | ||
|
|
@@ -376,7 +395,7 @@ NBL_CONCEPT_END( | |
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(rdirinfo,pV)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(rdirinfo,pV,pV,pV)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(rdirinfo,pV,pV,pNdotL)), ::nbl::hlsl::is_same_v, T)) | ||
| // ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SIsotropic<typename T::ray_dir_info_type> >(pV,inter)), ::nbl::hlsl::is_same_v, T)) // NOTE: temporarily commented out due to dxc bug https://github.com/microsoft/DirectXShaderCompiler/issues/7154 | ||
| // ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SIsotropic<typename T::ray_dir_info_type, typename T::vector3_type> >(pV,inter)), ::nbl::hlsl::is_same_v, T)) // NOTE: temporarily commented out due to dxc bug https://github.com/microsoft/DirectXShaderCompiler/issues/7154 | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((_sample.getTangentSpaceL()), ::nbl::hlsl::is_same_v, typename T::vector3_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createInvalid()), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(ray_dir_info::Basic, typename T::ray_dir_info_type)) | ||
|
|
@@ -525,7 +544,7 @@ NBL_CONCEPT_END( | |
| #define NBL_CONCEPT_TPLT_PRM_KINDS (typename) | ||
| #define NBL_CONCEPT_TPLT_PRM_NAMES (T) | ||
| #define NBL_CONCEPT_PARAM_0 (cache, T) | ||
| #define NBL_CONCEPT_PARAM_1 (iso, surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> >) | ||
| #define NBL_CONCEPT_PARAM_1 (iso, surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type >) | ||
| #define NBL_CONCEPT_PARAM_2 (pNdotV, typename T::scalar_type) | ||
| #define NBL_CONCEPT_PARAM_3 (_sample, SLightSample<ray_dir_info::SBasic<typename T::scalar_type> >) | ||
| #define NBL_CONCEPT_PARAM_4 (V, typename T::vector3_type) | ||
|
|
@@ -540,9 +559,9 @@ NBL_CONCEPT_BEGIN(6) | |
| NBL_CONCEPT_END( | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createForReflection(pNdotV,pNdotV,pNdotV,pNdotV)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createForReflection(pNdotV,pNdotV,pNdotV)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template createForReflection<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(iso,_sample)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template createForReflection<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(iso,_sample)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(V,V,V,eta,V)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(iso,_sample,eta,V)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(iso,_sample,eta,V)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(ReadableIsotropicMicrofacetCache, T)) | ||
| ); | ||
| #undef eta | ||
|
|
@@ -698,7 +717,7 @@ struct SIsotropicMicrofacetCache | |
| #define NBL_CONCEPT_TPLT_PRM_KINDS (typename) | ||
| #define NBL_CONCEPT_TPLT_PRM_NAMES (T) | ||
| #define NBL_CONCEPT_PARAM_0 (cache, T) | ||
| #define NBL_CONCEPT_PARAM_1 (aniso, surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> > >) | ||
| #define NBL_CONCEPT_PARAM_1 (aniso, surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type > >) | ||
| #define NBL_CONCEPT_PARAM_2 (pNdotL, typename T::scalar_type) | ||
| #define NBL_CONCEPT_PARAM_3 (_sample, SLightSample<ray_dir_info::SBasic<typename T::scalar_type> >) | ||
| #define NBL_CONCEPT_PARAM_4 (V, typename T::vector3_type) | ||
|
|
@@ -724,9 +743,9 @@ NBL_CONCEPT_END( | |
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createForReflection(V,V)), ::nbl::hlsl::is_same_v, T)) | ||
| // ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(V,V,b0,rcp_eta)), ::nbl::hlsl::is_same_v, T)) // TODO: refuses to compile when arg4 is rcp_eta for some reason, eta is fine | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createForReflection(V,V,pNdotL)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template createForReflection<surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> > >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(aniso,_sample)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template createForReflection<surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type > >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(aniso,_sample)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::create(V,V,V,V,V,eta,V)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type> > >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(aniso,_sample,eta)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::template create<surface_interactions::SAnisotropic<surface_interactions::SIsotropic<ray_dir_info::SBasic<typename T::scalar_type>, typename T::vector3_type > >,SLightSample<ray_dir_info::SBasic<typename T::scalar_type> > >(aniso,_sample,eta)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((T::createPartial(pNdotL,pNdotL,pNdotL,b0,rcp_eta)), ::nbl::hlsl::is_same_v, T)) | ||
| ((NBL_CONCEPT_REQ_EXPR)(cache.fillTangents(V,V,V))) | ||
| ((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(CreatableIsotropicMicrofacetCache, typename T::isocache_type)) | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'd only have
getLuminosityContributionHint