-
Notifications
You must be signed in to change notification settings - Fork 67
Hlsl path tracer example #863
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
Closed
Closed
Changes from 41 commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
02d6d0f
initial example
keptsecret 129b50e
use bxdf creation params struct
keptsecret 74261dc
triangle and rectangle shapes
keptsecret ab3ae20
more sampling methods
keptsecret 355cfec
spherical rectangle
keptsecret ebf8fca
merge pcg fix from upstream
keptsecret 11180f4
fix aniso cache bug
keptsecret 4516051
init func to modify bxdf params directly
keptsecret d9a00c9
bug fixes
keptsecret ffe9029
fix sampling bugs #2
keptsecret cee192e
update to master
keptsecret b207312
fix rank type trait for matrix/vector
keptsecret 673f788
merge hlsl bxdfs, resolve conflict
keptsecret 69a257d
temporary fix for dxc bug issue 7154
keptsecret 866e6d7
some bug fixes again
keptsecret 85e955f
fix wrong template usage
keptsecret 3b167ab
merge changes from hlsl_bxdf
keptsecret 19e3a35
merge master/bxdf fixes, resolve conflicts
keptsecret 6b5bf06
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret 7b574da
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret 1c773d9
fix typo
keptsecret 326c885
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret 6132a4e
Merge branch 'revert-some-device-limits' into hlsl_path_tracer_example
keptsecret 0bd26c7
Merge branch 'master' into hlsl_path_tracer_example
keptsecret ebb1b15
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret 7cb977d
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret 67c525e
Merge branch 'master' into hlsl_path_tracer_example
keptsecret a8f209e
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret e8d2ed8
fixed some func usage to nbl ver
keptsecret c47f446
specify template args
keptsecret 642e46d
fix merge conflicts
keptsecret 1137b6b
update to latest example
keptsecret 5cd4e6c
merge math, fix conflict
keptsecret 7e8dd81
latest example
keptsecret f86dd0c
Merge remote-tracking branch 'origin/intrinsics_adjustments' into hls…
keptsecret b154638
fix use of static const in func
keptsecret 7892563
added more morton order stuff
keptsecret b21b789
latest example
keptsecret 1f461ff
merge master, fix conflicts
keptsecret df2321a
merge hlsl_bxdfs, fix conflicts
keptsecret 26adf95
latest example
keptsecret 0d80626
Merge branch 'hlsl_bxdfs' into hlsl_path_tracer_example
keptsecret 36910c6
latest example fixes
keptsecret 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 afc3485
merge bxdf, fix conflicts
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 55471ca
removed duplicate fresnel code, added creation params for iridescent
keptsecret 64be771
split out iridescent fresnel vars into base struct
keptsecret 8f9a114
renamed private funcs, replace enable_if usage with NBL_FUNC_REQUIRES
keptsecret 8a71f40
avoid promoting 1d fresnel to 3d just to dot product, added private f…
keptsecret dee1b61
init ndf quants, minor cook torrance fixes
keptsecret cd9b18b
primaries wavelengths for aces colorspaces (not sure they're correct)
keptsecret 0984c7e
fixes to angle adder, handle some edge cases
keptsecret 3d7ded6
Merge branch 'master' into iridescence_bxdf
keptsecret dbbb30a
merge master, fix conflicts
keptsecret 3ae69fa
updated example
keptsecret 1f9bf16
merge iridescent_bxdf, fix conflicts (hope it's merged to master soon)
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
26 files
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // Copyright (C) 2018-2023 - DevSH Graphics Programming Sp. z O.O. | ||
| // This file is part of the "Nabla Engine". | ||
| // For conditions of distribution and use, see copyright notice in nabla.h | ||
| #ifndef _NBL_BUILTIN_HLSL_MATH_MORTON_INCLUDED_ | ||
| #define _NBL_BUILTIN_HLSL_MATH_MORTON_INCLUDED_ | ||
|
|
||
| #include "nbl/builtin/hlsl/cpp_compat.hlsl" | ||
|
|
||
| namespace nbl | ||
| { | ||
| namespace hlsl | ||
| { | ||
| namespace math | ||
| { | ||
|
|
||
| namespace impl | ||
| { | ||
|
|
||
| template<typename T, uint32_t bitDepth> | ||
| struct MortonComponent; | ||
|
|
||
| template<typename T> | ||
| struct MortonComponent<T, 8u> | ||
| { | ||
| static T decode2d(T x) | ||
| { | ||
| x &= 0x55555555u; | ||
| x = (x ^ (x >> 1u)) & 0x33333333u; | ||
| x = (x ^ (x >> 2u)) & 0x0f0f0f0fu; | ||
| x = (x ^ (x >> 4u)) & 0x00ff00ffu; | ||
| return x; | ||
| } | ||
| }; | ||
|
|
||
| template<typename T> | ||
| struct MortonComponent<T, 32u> | ||
| { | ||
| static T decode2d(T x) | ||
| { | ||
| x &= 0x55555555u; | ||
| x = (x ^ (x >> 1u)) & 0x33333333u; | ||
| x = (x ^ (x >> 2u)) & 0x0f0f0f0fu; | ||
| x = (x ^ (x >> 4u)) & 0x00ff00ffu; | ||
| x = (x ^ (x >> 8u)) & 0x0000ffffu; | ||
| x = (x ^ (x >> 16u)); | ||
| return x; | ||
| } | ||
| }; | ||
|
|
||
| } | ||
|
|
||
| template<typename T, uint32_t bitDepth=sizeof(T)*8u> | ||
| struct Morton | ||
| { | ||
| using vector2_type = vector<T, 2>; | ||
| using component_type = impl::MortonComponent<T, bitDepth>; | ||
|
|
||
| static vector2_type decode2d(T x) | ||
| { | ||
| return vector2_type(component_type::decode2d(x), component_type::decode2d(x >> 1u)); | ||
| } | ||
| }; | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
devshgraphicsprogramming marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Copyright (C) 2018-2023 - DevSH Graphics Programming Sp. z O.O. | ||
| // This file is part of the "Nabla Engine". | ||
| // For conditions of distribution and use, see copyright notice in nabla.h | ||
|
|
||
| #ifndef _NBL_BUILTIN_HLSL_SAMPLING_BILINEAR_INCLUDED_ | ||
| #define _NBL_BUILTIN_HLSL_SAMPLING_BILINEAR_INCLUDED_ | ||
|
|
||
| #include <nbl/builtin/hlsl/cpp_compat.hlsl> | ||
| #include <nbl/builtin/hlsl/limits.hlsl> | ||
| #include <nbl/builtin/hlsl/sampling/linear.hlsl> | ||
|
|
||
| namespace nbl | ||
| { | ||
| namespace hlsl | ||
| { | ||
| namespace sampling | ||
| { | ||
|
|
||
| template<typename T> | ||
| struct Bilinear | ||
| { | ||
| using scalar_type = T; | ||
| using vector2_type = vector<T, 2>; | ||
| using vector3_type = vector<T, 3>; | ||
| using vector4_type = vector<T, 4>; | ||
|
|
||
| static Bilinear<T> create(NBL_CONST_REF_ARG(vector4_type) bilinearCoeffs) | ||
| { | ||
| Bilinear<T> retval; | ||
| retval.bilinearCoeffs = bilinearCoeffs; | ||
| return retval; | ||
| } | ||
|
|
||
| vector2_type generate(NBL_REF_ARG(scalar_type) rcpPdf, NBL_CONST_REF_ARG(vector2_type) _u) | ||
devshgraphicsprogramming marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| vector2_type u = _u; | ||
| const vector2_type twiceAreasUnderXCurve = vector2_type(bilinearCoeffs[0] + bilinearCoeffs[1], bilinearCoeffs[2] + bilinearCoeffs[3]); | ||
| Linear<scalar_type> lineary = Linear<scalar_type>::create(twiceAreasUnderXCurve); | ||
| u.y = lineary.generate(u.y); | ||
|
|
||
| const vector2_type ySliceEndPoints = vector2_type(nbl::hlsl::mix(bilinearCoeffs[0], bilinearCoeffs[2], u.y), nbl::hlsl::mix(bilinearCoeffs[1], bilinearCoeffs[3], u.y)); | ||
| Linear<scalar_type> linearx = Linear<scalar_type>::create(ySliceEndPoints); | ||
| u.x = linearx.generate(u.x); | ||
|
|
||
| rcpPdf = (twiceAreasUnderXCurve[0] + twiceAreasUnderXCurve[1]) / (4.0 * nbl::hlsl::mix(ySliceEndPoints[0], ySliceEndPoints[1], u.x)); | ||
|
|
||
| return u; | ||
| } | ||
|
|
||
| scalar_type pdf(NBL_CONST_REF_ARG(vector2_type) u) | ||
| { | ||
| return 4.0 * nbl::hlsl::mix(nbl::hlsl::mix(bilinearCoeffs[0], bilinearCoeffs[1], u.x), nbl::hlsl::mix(bilinearCoeffs[2], bilinearCoeffs[3], u.x), u.y) / (bilinearCoeffs[0] + bilinearCoeffs[1] + bilinearCoeffs[2] + bilinearCoeffs[3]); | ||
| } | ||
|
|
||
| vector4_type bilinearCoeffs; | ||
|
Member
Author
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. document which index/component maps to which vertex of the unit square |
||
| }; | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
27 changes: 27 additions & 0 deletions
27
include/nbl/builtin/hlsl/sampling/box_muller_transform.hlsl
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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright (C) 2018-2023 - DevSH Graphics Programming Sp. z O.O. | ||
| // This file is part of the "Nabla Engine". | ||
| // For conditions of distribution and use, see copyright notice in nabla.h | ||
|
|
||
| #ifndef _NBL_BUILTIN_HLSL_BOX_MULLER_TRANSFORM_INCLUDED_ | ||
| #define _NBL_BUILTIN_HLSL_BOX_MULLER_TRANSFORM_INCLUDED_ | ||
|
|
||
| #include "nbl/builtin/hlsl/math/functions.hlsl" | ||
| #include "nbl/builtin/hlsl/numbers.hlsl" | ||
|
|
||
| namespace nbl | ||
| { | ||
| namespace hlsl | ||
| { | ||
|
|
||
| template<typename T> | ||
| vector<T,2> boxMullerTransform(vector<T,2> xi, T stddev) | ||
| { | ||
| T sinPhi, cosPhi; | ||
| math::sincos<T>(2.0 * numbers::pi<float> * xi.y - numbers::pi<float>, sinPhi, cosPhi); | ||
| return vector<T,2>(cosPhi, sinPhi) * nbl::hlsl::sqrt(-2.0 * nbl::hlsl::log(xi.x)) * stddev; | ||
| } | ||
|
Comment on lines
+16
to
+22
Member
Author
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. turn into struct with |
||
|
|
||
| } | ||
| } | ||
|
|
||
| #endif | ||
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright (C) 2018-2023 - DevSH Graphics Programming Sp. z O.O. | ||
| // This file is part of the "Nabla Engine". | ||
| // For conditions of distribution and use, see copyright notice in nabla.h | ||
|
|
||
| #ifndef _NBL_BUILTIN_HLSL_SAMPLING_LINEAR_INCLUDED_ | ||
| #define _NBL_BUILTIN_HLSL_SAMPLING_LINEAR_INCLUDED_ | ||
|
|
||
| #include <nbl/builtin/hlsl/cpp_compat.hlsl> | ||
| #include <nbl/builtin/hlsl/limits.hlsl> | ||
|
|
||
| namespace nbl | ||
| { | ||
| namespace hlsl | ||
| { | ||
| namespace sampling | ||
| { | ||
|
|
||
| template<typename T> | ||
| struct Linear | ||
| { | ||
| using scalar_type = T; | ||
| using vector2_type = vector<T, 2>; | ||
|
|
||
| static Linear<T> create(NBL_CONST_REF_ARG(vector2_type) linearCoeffs) | ||
| { | ||
| Linear<T> retval; | ||
| retval.linearCoeffs = linearCoeffs; | ||
| return retval; | ||
| } | ||
|
|
||
| scalar_type generate(scalar_type u) | ||
| { | ||
| const scalar_type rcpDiff = 1.0 / (linearCoeffs[0] - linearCoeffs[1]); | ||
| const vector2_type squaredCoeffs = linearCoeffs * linearCoeffs; | ||
| return nbl::hlsl::abs(rcpDiff) < numeric_limits<scalar_type>::max ? (linearCoeffs[0] - nbl::hlsl::sqrt(nbl::hlsl::mix(squaredCoeffs[0], squaredCoeffs[1], u))) * rcpDiff : u; | ||
| } | ||
|
|
||
| vector2_type linearCoeffs; | ||
| }; | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif |
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.
should be templated on
Tinstead offloatand live insampling.hlsl(named same as the folder and namespace), do as part of #811P.S. for the constant you can use
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.
or you can put it in
sampling/basic.hlslThere 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.
mentioned in next PR