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.28k stars 125 forks source link

first tentative modifications for "invisible" area lights #470

Closed robertoranon closed 6 months ago

gkjohnson commented 7 months ago

The "dimming" of the area where the light surface technically is is caused because hitting the light technically counts as one of the limited "bounces" that a path is allowed to traverse. So the paths that go around the light surface bounce around the scene 3 times while the paths that hit the light only bounce twice since the light absorbs one.

To that end - here's what I'm thinking:

  1. We should remove the ability to hit "lights" from the traceScene function since this is causing light surfaces to cast shadows and is causing them to "use" path bounce. If this is addressed then the dimming issue you reported should no longer be an issue.
  2. Then we should iterate over all lights in the path tracing loop and add any light contribution from lights that are passed through up to the next ray termination point.
  3. On the state.firstRay || state.transmissiveRay we find the closest light marked as visible we intersect with if any and terminate so it's visible.

It depends on how you want to handle it - but it might be easiest to handle points 1 and 2 first and then 3 can be done in separately.

Hopefully that all makes sense - let me know if you have any other questions or need more direction on the codebase!

robertoranon commented 6 months ago

Hi, sorry for taking so long, but I was quite busy. Here is a modification of this PR that removes the ability to trace lights from the traceScene function, as well as other modifications: