-
Notifications
You must be signed in to change notification settings - Fork 69
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
Open
karimsayedre
wants to merge
39
commits into
master
Choose a base branch
from
sampler-concepts
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.
+1,733
−419
Open
Changes from 1 commit
Commits
Show all changes
39 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 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
4 files
| +54 −0 | 75_HLSLSamplingTests/CMakeLists.txt | |
| +78 −0 | 75_HLSLSamplingTests/app_resources/test_compile.comp.hlsl | |
| +121 −0 | 75_HLSLSamplingTests/main.cpp | |
| +1 −0 | CMakeLists.txt |
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,170 @@ | ||
| #ifndef _NBL_BUILTIN_HLSL_SAMPLING_CONCEPTS_INCLUDED_ | ||
| #define _NBL_BUILTIN_HLSL_SAMPLING_CONCEPTS_INCLUDED_ | ||
|
|
||
| #include <nbl/builtin/hlsl/concepts.hlsl> | ||
|
|
||
| namespace nbl | ||
| { | ||
| namespace hlsl | ||
| { | ||
| namespace sampling | ||
| { | ||
| namespace concepts | ||
| { | ||
|
|
||
| // ============================================================================ | ||
devshgraphicsprogramming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // BasicSampler | ||
| // | ||
| // The simplest sampler: maps domain -> codomain. | ||
| // | ||
| // Required types: | ||
| // domain_type - the input space (e.g. float for 1D, float2 for 2D) | ||
| // codomain_type - the output space (e.g. float3 for directions) | ||
| // | ||
| // Required methods: | ||
| // codomain_type generate(domain_type u) | ||
| // ============================================================================ | ||
|
|
||
| #define NBL_CONCEPT_NAME BasicSampler | ||
| #define NBL_CONCEPT_TPLT_PRM_KINDS (typename) | ||
| #define NBL_CONCEPT_TPLT_PRM_NAMES (T) | ||
| #define NBL_CONCEPT_PARAM_0 (sampler, T) | ||
| #define NBL_CONCEPT_PARAM_1 (u, typename T::domain_type) | ||
| NBL_CONCEPT_BEGIN(2) | ||
| #define sampler NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0 | ||
| #define u NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1 | ||
| NBL_CONCEPT_END( | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::domain_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::codomain_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((sampler.generate(u)), ::nbl::hlsl::is_same_v, typename T::codomain_type)) | ||
| ); | ||
| #undef u | ||
| #undef sampler | ||
| #include <nbl/builtin/hlsl/concepts/__end.hlsl> | ||
|
|
||
| // ============================================================================ | ||
| // TractableSampler | ||
| // | ||
| // A sampler whose density can be computed analytically in the forward | ||
| // (sampling) direction. The generate method returns the sample bundled | ||
| // with its density to avoid redundant computation. | ||
| // | ||
| // Required types: | ||
| // domain_type - the input space | ||
| // codomain_type - the output space | ||
| // density_type - the density type (typically scalar) | ||
devshgraphicsprogramming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // sample_type - bundled return of generate, should be one of: | ||
| // codomain_and_rcpPdf<codomain_type, density_type> (preferred) | ||
| // codomain_and_pdf<codomain_type, density_type> | ||
| // | ||
| // Required methods: | ||
| // sample_type generate(domain_type u) - sample + density | ||
| // density_type forwardPdf(domain_type u) - density only | ||
| // ============================================================================ | ||
|
|
||
| #define NBL_CONCEPT_NAME TractableSampler | ||
| #define NBL_CONCEPT_TPLT_PRM_KINDS (typename) | ||
| #define NBL_CONCEPT_TPLT_PRM_NAMES (T) | ||
| #define NBL_CONCEPT_PARAM_0 (sampler, T) | ||
| #define NBL_CONCEPT_PARAM_1 (u, typename T::domain_type) | ||
| NBL_CONCEPT_BEGIN(2) | ||
| #define sampler NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0 | ||
| #define u NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1 | ||
| NBL_CONCEPT_END( | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::domain_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::codomain_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::density_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::sample_type)) | ||
devshgraphicsprogramming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((sampler.generate(u)), ::nbl::hlsl::is_same_v, typename T::sample_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((sampler.forwardPdf(u)), ::nbl::hlsl::is_same_v, typename T::density_type)) | ||
| ); | ||
| #undef u | ||
| #undef sampler | ||
| #include <nbl/builtin/hlsl/concepts/__end.hlsl> | ||
|
|
||
| // ============================================================================ | ||
| // BackwardDensitySampler | ||
devshgraphicsprogramming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // | ||
| // Extends TractableSampler with the ability to evaluate the PDF given | ||
| // a codomain value (i.e. without knowing the original domain input). | ||
| // | ||
| // Required methods (in addition to TractableSampler): | ||
devshgraphicsprogramming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // density_type backwardPdf(codomain_type v) | ||
| // ============================================================================ | ||
|
|
||
| #define NBL_CONCEPT_NAME BackwardDensitySampler | ||
| #define NBL_CONCEPT_TPLT_PRM_KINDS (typename) | ||
| #define NBL_CONCEPT_TPLT_PRM_NAMES (T) | ||
| #define NBL_CONCEPT_PARAM_0 (sampler, T) | ||
devshgraphicsprogramming marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #define NBL_CONCEPT_PARAM_1 (u, typename T::domain_type) | ||
| #define NBL_CONCEPT_PARAM_2 (v, typename T::codomain_type) | ||
| NBL_CONCEPT_BEGIN(3) | ||
| #define sampler NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0 | ||
| #define u NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1 | ||
| #define v NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2 | ||
| NBL_CONCEPT_END( | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::domain_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::codomain_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::density_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::sample_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((sampler.generate(u)), ::nbl::hlsl::is_same_v, typename T::sample_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((sampler.forwardPdf(u)), ::nbl::hlsl::is_same_v, typename T::density_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((sampler.backwardPdf(v)), ::nbl::hlsl::is_same_v, typename T::density_type)) | ||
| ); | ||
| #undef v | ||
| #undef u | ||
| #undef sampler | ||
| #include <nbl/builtin/hlsl/concepts/__end.hlsl> | ||
|
|
||
| // ============================================================================ | ||
| // BijectiveSampler | ||
| // | ||
| // The mapping domain <-> codomain is bijective (1:1), so it can be | ||
| // inverted. Extends BackwardDensitySampler with invertGenerate. | ||
| // | ||
| // Because the mapping is bijective, the Jacobian of the inverse is | ||
| // the reciprocal of the Jacobian of the forward mapping: | ||
| // backwardPdf(v) == 1.0 / forwardPdf(invertGenerate(v).value) | ||
| // | ||
| // Required types (in addition to BackwardDensitySampler): | ||
| // inverse_sample_type - bundled return of invertGenerate, should be | ||
| // one of: | ||
| // domain_and_rcpPdf<domain_type, density_type> (preferred) | ||
| // domain_and_pdf<domain_type, density_type> | ||
| // | ||
| // Required methods (in addition to BackwardDensitySampler): | ||
| // inverse_sample_type invertGenerate(codomain_type v) | ||
| // ============================================================================ | ||
|
|
||
| #define NBL_CONCEPT_NAME BijectiveSampler | ||
| #define NBL_CONCEPT_TPLT_PRM_KINDS (typename) | ||
| #define NBL_CONCEPT_TPLT_PRM_NAMES (T) | ||
| #define NBL_CONCEPT_PARAM_0 (sampler, T) | ||
| #define NBL_CONCEPT_PARAM_1 (u, typename T::domain_type) | ||
| #define NBL_CONCEPT_PARAM_2 (v, typename T::codomain_type) | ||
| NBL_CONCEPT_BEGIN(3) | ||
| #define sampler NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0 | ||
| #define u NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1 | ||
| #define v NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2 | ||
| NBL_CONCEPT_END( | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::domain_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::codomain_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::density_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::sample_type)) | ||
| ((NBL_CONCEPT_REQ_TYPE)(T::inverse_sample_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((sampler.generate(u)), ::nbl::hlsl::is_same_v, typename T::sample_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((sampler.forwardPdf(u)), ::nbl::hlsl::is_same_v, typename T::density_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((sampler.backwardPdf(v)), ::nbl::hlsl::is_same_v, typename T::density_type)) | ||
| ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((sampler.invertGenerate(v)), ::nbl::hlsl::is_same_v, typename T::inverse_sample_type)) | ||
| ); | ||
| #undef v | ||
| #undef u | ||
| #undef sampler | ||
| #include <nbl/builtin/hlsl/concepts/__end.hlsl> | ||
|
|
||
| } // namespace concepts | ||
| } // namespace sampling | ||
| } // namespace hlsl | ||
| } // namespace nbl | ||
|
|
||
| #endif // _NBL_BUILTIN_HLSL_SAMPLING_CONCEPTS_INCLUDED_ | ||
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.