Skip to content
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

Biased sampling code #48

Open
Nielsbishere opened this issue Apr 8, 2021 · 0 comments
Open

Biased sampling code #48

Nielsbishere opened this issue Apr 8, 2021 · 0 comments

Comments

@Nielsbishere
Copy link

Nielsbishere commented Apr 8, 2021

https://github.com/cschied/q2vkpt/blob/master/src/refresh/vkpt/shader/path_tracer.h#L464 shows the code:

vec2 pixel_offset = vec2(get_rng(RNG_PRIMARY_OFF_X), get_rng(RNG_PRIMARY_OFF_Y));
pixel_offset.x = sqrt(-2.0 * log(pixel_offset.x));
pixel_offset = clamp(pixel_offset, vec2(-1), vec2(1)) * 0.5;

and get_rng returns

return min(texelFetch(TEX_BLUE_NOISE, ivec3(p), 0).r, 0.9999999999999);

From this, we know that get_rng = [ 0, 0.9999999999999 ] (since the blue noise is unorm r16).
Therefore, pixel_offset would always be in range [ 0, 0.5 >, not [ -.5, .5 > which is required to sample all volume of the pixel (relative to the center 0.5,0.5 pixel).
afbeelding
As provided by this formula of the box muller transform, which always returns <0,1] when [0,1> are provided.
This means the .5,.5;1,1 area is the only part of the pixel that is traced.

Unless this is required for TAA for some reason, I'd imagine the pixel_offset needs to be:

vec2 pixel_offset = vec2(get_rng(RNG_PRIMARY_OFF_X), get_rng(RNG_PRIMARY_OFF_Y));
pixel_offset.x = min(sqrt(-2.0 * log(pixel_offset.x)), 0.9999999999999);
pixel_offset = pixel_offset - 0.5; 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant