-
Notifications
You must be signed in to change notification settings - Fork 71
Created concepts for samplers, added quotient_and_pdf variants to satisfy the concepts #1001
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
Merged
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
f71610b
Created concepts for samplers, added quotient_and_pdf variants to sat…
karimsayedre 0e0b0ad
revert bad formatting for hlsl sampling headers
karimsayedre 3574d83
Separate warp sample types from quotient_and_pdf, add sample density …
karimsayedre 168ca4d
merge master, fix conflicts
keptsecret f1493ed
changes to linear, bilinear, box muller for pdf and backward pdf
keptsecret 5933fe0
changes to solid angle method name, simplified a lot of code in spher…
keptsecret 3ac7b83
removed redundant/unused variables from spherical triangle sample
keptsecret 4ed1cbc
spherical rectangle stores origin, extent, basis and takes observer i…
keptsecret 65ef4b3
added compressed spherical rectangle, comments for info of implementa…
keptsecret 7fc8281
minor fixes to spherical rectangle stuff
keptsecret 855dac4
spherical rectangle constructor for same rectangle and observer
keptsecret 468031f
spherical rectangle create only from compressed, minor fix for spheri…
keptsecret 0f143a0
reduced duplicate methods to only ones matching (close to) concept in…
keptsecret fb0e8a5
spherical rect generate don't divide by extents, let user do that
keptsecret ab5ee78
store only needed members from tri
keptsecret 17c85ba
forward/backward pdfs for spherical triangle/rectangle, projected sph…
keptsecret d95cfa7
copied over fixed linear sampling because merge fucked up, added forw…
keptsecret 0bb7b39
add forward pdf, generate inverse to bilinear
keptsecret 89f6d5f
uniform hemi/sphere samplign make static methods private, added metho…
keptsecret e07ebc1
cosine hemi/sphere sampling make static methods private, added method…
keptsecret c4e63b3
box muller transform add forward pdf, generate wasn't merged from pt …
keptsecret c064b29
`approx_compare` uses abs then relative comparison, better sampler co…
karimsayedre d254d7a
Merge branch 'master' into sampler-concepts
karimsayedre 5bc073f
Merge branch 'master' into sampler-concepts
karimsayedre d2114f8
fixes after merge
karimsayedre 4f390b4
Merge remote-tracking branch 'origin/sampling_refactor_for_pt' into s…
karimsayedre 743575f
update `examples_tests`
karimsayedre 4d266ec
All samplers now conform to concepts
karimsayedre 86fa3f6
Added alias table and cumulative prbability builders and samplers
karimsayedre 6c79011
Merge branch 'master' into sampler-concepts
karimsayedre 254404b
update examples_tests
karimsayedre 2fa32a7
Merge branch 'master' into sampler-concepts
karimsayedre c61a63c
Merge branch 'master' into sampler-concepts
karimsayedre b720bc0
Merge branch 'master' into sampler-concepts
karimsayedre 1fb987a
addressing comments in concepts.hlsl
karimsayedre fc7e174
address comments in concepts.hlsl
karimsayedre 38f73af
Merge branch 'master' into sampler-concepts
devshgraphicsprogramming 04d5a30
Merge branch 'master' into sampler-concepts
karimsayedre edc3c3e
addressed more comments
karimsayedre b52f3c4
addressed more comments
karimsayedre 9b4ee22
update examples_tests
karimsayedre 3b7b596
Merge branch 'master' into sampler-concepts
karimsayedre a07e433
changed forwardPdf/Weight signature to take L, better core::to_string…
karimsayedre 1b46ed9
update examples_tests
karimsayedre d7ad2ce
Merge branch 'master' into sampler-concepts
karimsayedre 05bbf01
forwardPdf should take domain, not codomain
karimsayedre 12f7bc3
Advance DXC pointer for sampler branch
AnastaZIuk 3974d53
Add missing polar mapping builtin
AnastaZIuk c3a443a
Promote NSC channel 3974d536dea859059096bc266ce58b8104e8a097
github-actions[bot] f05e193
Advance DXC pointer for sampler branch
AnastaZIuk 4ccb763
Promote NSC channel f05e1937e8c41d6c15d5bc8c570c2e8edc8d7a96
github-actions[bot] f96d020
Clamp spherical triangle BC interpolation
AnastaZIuk 4bc53ca
addressed the rest of the comments
karimsayedre 6e32a90
Merge branch 'sampler-concepts' of github.com:Devsh-Graphics-Programm…
karimsayedre 4b2e1eb
Merge branch 'master' into sampler-concepts
karimsayedre 77f1565
remove polar_mapping.hlsl resource duplicate
karimsayedre 551c8b8
projected spherical rectangle, reverted projectedSolidAngle sign changes
karimsayedre ea6a2c8
Merge branch 'master' into sampler-concepts
karimsayedre 6ee9227
SphericalRectangle: generate() returns 3D direction, reduce register …
karimsayedre 2f5f692
add a new `create()` that takes r0 and extents, also use * rsqrt inst…
karimsayedre ebddd2c
Merge branch 'master' into sampler-concepts
karimsayedre 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Submodule examples_tests
updated
67 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,87 @@ | ||
| // 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_FAST_ACOS_INCLUDED_ | ||
| #define _NBL_BUILTIN_HLSL_MATH_FAST_ACOS_INCLUDED_ | ||
|
|
||
| #include "nbl/builtin/hlsl/cpp_compat.hlsl" | ||
| #include "nbl/builtin/hlsl/numbers.hlsl" | ||
| #include "nbl/builtin/hlsl/tgmath.hlsl" | ||
| #include "nbl/builtin/hlsl/concepts.hlsl" | ||
|
|
||
| namespace nbl | ||
| { | ||
| namespace hlsl | ||
| { | ||
| namespace math | ||
| { | ||
| // https://www.desmos.com/calculator/a59pbwgwof | ||
| // a comparison between fast acos methods | ||
|
|
||
| // Attempt 1: Polynomial approximation of acos(x) for x in [-1,1] | ||
| // Based on an odd cubic fit: acos(x) ~ (a * x^2 + b) * x + pi/2 | ||
| // Max absolute error: ~9.8e-2 rad | ||
| // Very fast: no sqrt, no branches | ||
| template<typename T NBL_STRUCT_CONSTRAINABLE> | ||
| struct fast_acos_cubic | ||
| { | ||
| static T __call(const T val) | ||
| { | ||
| return (T(-0.621565443625098) * val * val - T(0.837561827808302)) * val + numbers::pi<T> / T(2.0); | ||
| } | ||
| }; | ||
|
|
||
| // Attempt 2: Abramowitz & Stegun formula 4.4.45 (adapted for full [-1,1] range) | ||
| // acos(x) ~ sqrt(1-x) * (a0 + a1*x + a2*x^2 + a3*x^3) for x in [0,1] | ||
| // For x in [-1,0]: acos(x) = pi - acos(-x) | ||
| // Max absolute error: ~6.3e-5 rad | ||
| template<typename T NBL_STRUCT_CONSTRAINABLE> | ||
| struct fast_acos_stegun_poly3 | ||
| { | ||
| static T __call(const T val) | ||
| { | ||
| const T ax = abs<T>(val); | ||
| const T s = sqrt<T>(T(1.0) - ax); | ||
| const T poly = ((T(-0.019771840941) * ax + T(0.075701735421)) * ax - T(0.212644584569)) * ax + T(1.570771931669); // not pi/2, free constant for better fit | ||
| const T result = s * poly; | ||
| return hlsl::select(val < T(0.0), numbers::pi<T> - result, result); | ||
| } | ||
| }; | ||
|
|
||
| // Attempt 3: Degree-4 polynomial, good accuracy/cost tradeoff | ||
| // Fitted as: acos(x) ~ sqrt(1-x) * (a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4) for x in [0,1] | ||
| // Max absolute error: ~8.6e-6 rad | ||
| template<typename T NBL_STRUCT_CONSTRAINABLE> | ||
| struct fast_acos_stegun_poly4 | ||
| { | ||
| static T __call(const T val) | ||
| { | ||
| const T ax = abs<T>(val); | ||
| const T s = sqrt<T>(T(1.0) - ax); | ||
| const T poly = (((T(0.0102831457) * ax - T(0.0387865708)) * ax + T(0.0864014439)) * ax - T(0.2144371342)) * ax + numbers::pi<T> / T(2.0); | ||
| const T result = s * poly; | ||
| return hlsl::select(val < T(0.0), numbers::pi<T> - result, result); | ||
| } | ||
| }; | ||
|
|
||
| // Attempt 4: Degree-5 polynomial for best accuracy | ||
| // Fitted as: acos(x) ~ sqrt(1-x) * (a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4 + a5*x^5) for x in [0,1] | ||
| // Max absolute error: ~1.1e-6 rad | ||
| template<typename T NBL_STRUCT_CONSTRAINABLE> | ||
| struct fast_acos_stegun_poly5 | ||
| { | ||
| static T __call(const T val) | ||
| { | ||
| const T ax = abs<T>(val); | ||
| const T s = sqrt<T>(T(1.0) - ax); | ||
| const T poly = ((((T(-0.0051108043) * ax + T(0.0211860706)) * ax - T(0.0464796661)) * ax + T(0.0883884911)) * ax - T(0.2145725267)) * ax + numbers::pi<T> / T(2.0); | ||
| const T result = s * poly; | ||
| return hlsl::select(val < T(0.0), numbers::pi<T> - result, result); | ||
| } | ||
| }; | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| #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
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.
Uh oh!
There was an error while loading. Please reload this page.