Created a new example to test the compilation and concepts of samplers#252
Created a new example to test the compilation and concepts of samplers#252karimsayedre wants to merge 20 commits intomasterfrom
Conversation
…hader permutation), configurable work group size in `ITester`
|
Everything looks good, although it would be nice to try the CDF and Alias table samples at several different PoT sizes from 8 to 128*1024^2 to find the perf crossover point across sizes Also do a 1 Reservoir sampling from size of 2 to 32 because that will likely be faster than CDF and Alias at really small sizes (same way linear search is vs binary and hashmap due to caching effects) |
|
Also see if you can address any of the open comments in the BxDF testing PR |
|
|
||
| pdf = rcpPdf > numeric_limits<scalar_type>::min ? (1.0 / rcpPdf) : numeric_limits<scalar_type>::max; | ||
| const scalar_type fwdPdf = pst.forwardPdf(pstCache); | ||
| pdf = fwdPdf < numeric_limits<scalar_type>::max ? fwdPdf : numeric_limits<scalar_type>::max; |
There was a problem hiding this comment.
this does nothing
| using value_type = T; | ||
| template<typename V, typename I> | ||
| void get(I i, NBL_REF_ARG(V) val) NBL_CONST_MEMBER_FUNC { val = V(data[i]); } | ||
| T operator[](uint32_t i) NBL_CONST_MEMBER_FUNC { return data[i]; } |
There was a problem hiding this comment.
what do you need operator[] for ?
|
|
||
| float32_t2 diff = input.u - output.inverted; | ||
| output.roundtripError = nbl::hlsl::length(diff); | ||
| output.jacobianProduct = (float32_t(1.0) / output.forwardPdf) * output.backwardPdf; |
There was a problem hiding this comment.
even if you're no longer 100% bijective in all cases, you can perturb input.u by epsillon and work out the Jacobian * forwardPdf and compare against 1
| sampling::Linear<float32_t>::cache_type cache; | ||
| output.generateInversed = _sampler.generateInverse(output.generated); | ||
| output.backwardPdf = _sampler.backwardPdf(output.generated); | ||
| } | ||
| output.roundtripError = abs(input.u - output.generateInversed); | ||
| output.jacobianProduct = (float32_t(1.0) / output.forwardPdf) * output.backwardPdf; |
There was a problem hiding this comment.
same as bilinear
| { | ||
| sampling::ProjectedSphere<float32_t>::cache_type cache; | ||
| output.inverted = sampler.generateInverse(output.generated); | ||
| output.backwardPdf = sampler.backwardPdf(output.generated); | ||
| } | ||
| float32_t2 xyDiff = output.modifiedU.xy - output.inverted.xy; | ||
| output.roundtripError = nbl::hlsl::length(xyDiff); | ||
| output.jacobianProduct = (float32_t(1.0) / output.forwardPdf) * output.backwardPdf; |
There was a problem hiding this comment.
you can still work out a Jacobian from perturbing u
There was a problem hiding this comment.
only for the hemisphere I guess
| sampling::ProjectedSphericalTriangle<float32_t>::cache_type cache; | ||
| output.generated = sampler.generate(input.u, cache); | ||
| output.cachedPdf = cache.pdf; | ||
| output.forwardPdf = sampler.forwardPdf(cache); |
There was a problem hiding this comment.
you can do a JAcobian test, since its bijective if you wanted to
| output.inverted = sampler.generateInverse(output.generated); | ||
| // Backward: evaluate pdf at generated point (no cache needed) | ||
| output.backwardPdf = sampler.backwardPdf(output.generated); |
There was a problem hiding this comment.
differentiated generateInverse Jacobian determinant should equal the PDF I think
while differentiated generate multiplied with PDF comes out to 1
| } | ||
|
|
||
| output.backwardPdf = sampler.backwardPdf(output.generated); | ||
| output.separateBackwardPdf = sampler.separateBackwardPdf(output.generated); |
There was a problem hiding this comment.
you can test a lot of things, like:
- separate/independent PDF multiplying together to give the scalar PDF
2 Jacobian test follows PDF
| const float32_t toFloat = asfloat(0x2f800004u); | ||
| uint32_t2 acc = (uint32_t2)0; | ||
| uint32_t accPdf = 0; | ||
| for (uint32_t i = 0u; i < uint32_t(BENCH_ITERS); i++) | ||
| { | ||
| float32_t2 u = float32_t2(rng(), rng()) * toFloat; | ||
| sampling::SphericalRectangle<float32_t>::cache_type cache; | ||
| acc ^= asuint(sampler.generate(u, cache)); | ||
| accPdf ^= asuint(sampler.forwardPdf(cache)); | ||
| } |
There was a problem hiding this comment.
you need two benchmark modes, multiple samples from same create and multiple samples with create (to measure set-up overhead)
first one matters only for rejection sampling or multisampling, second one is more real use case when you only draw 1 NEE sample per path vertex so the create to generate ratio is 1:1
# Conflicts: # common/include/nbl/examples/Tester/ITester.h
No description provided.