gkjohnson / three-gpu-pathtracer

Path tracing renderer and utilities for three.js built on top of three-mesh-bvh.
https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/index.html
MIT License
1.27k stars 125 forks source link

Allow disabling jitter #628

Closed Codezigineer closed 1 month ago

Codezigineer commented 2 months ago

Jitter is what makes raytracers grainy, by shooting pixels at slightly different directions than normal. This allows disabling it, for tasks that don't need it.

gkjohnson commented 2 months ago

Hello! Thanks for the contribution.

Jitter is what makes raytracers grainy, by shooting pixels at slightly different directions than normal. This allows disabling it, for tasks that don't need it.

Can you provide some screenshots of cases where this disabling jitter helps with the final image and how? Jitter is effectively performing antialiasing - it can contribute to the graininess but every ray bounce is scattered in a random direction regardless of this perpixel jitter which is primarily where the graininess should be coming from.

Codezigineer commented 2 months ago

https://www.shadertoy.com/view/4ljGRd is an example. Some tasks don't need jitter. Not only that, FXAA can run over raytracing without any major impact. Here's an example of FXAA:

https://github.com/gkjohnson/three-gpu-pathtracer/assets/53050996/cb1a62f1-1fe5-4be8-af1e-c009bcbbed82

gkjohnson commented 2 months ago

https://www.shadertoy.com/view/4ljGRd is an example. Some tasks don't need jitter.

This is a very different kind of ray tracer, though. There is no randomness used anywhere and all diffuse lighting is calculated analytically rather than stochastically with random rays. Removing the pixel jitter from this project shouldn't result in the same kind of result.

What's the motivation for this PR? Are you using this for a project and need this change? Do you have screenshots showing what a render looks like before and after so I can understand how disabling the jitter affects the image?

Codezigineer commented 2 months ago

I made this for a project I am working on, that I'm specifically using raytracing because RectArealights don't have shadows. Yes that is the only reason.

gkjohnson commented 2 months ago

Got it - without a demonstration showing the improvements that this PR will bring to the project I won't be able to merge it. I don't think this will address any of the graininess issues in the image generation due to random sampling.

gkjohnson commented 1 month ago

Closing this until it can be shown that there's an improvement to image quality.