pmndrs / react-three-gpu-pathtracer

⚡️ A React abstraction for the popular three-gpu-pathtracer
MIT License
131 stars 11 forks source link

Can't add lights to pathtracing scene #7

Open Vikms95 opened 10 months ago

Vikms95 commented 10 months ago

I'm trying to figure out how to insert lights within a pathtracing generated scene. Link to the relevant codesanbox:

https://codesandbox.io/s/react-three-gpu-pathtracer-forked-g2l8l2?file=/src/App.js

In this example, I added a red RectAreaLight within lines 116-131. I copied the methods that were mentioned on one of the repo issues: https://github.com/pmndrs/react-three-gpu-pathtracer/issues/4 https://codesandbox.io/s/react-three-gpu-pathttracer-gltf-lights-3t7bqu?file=/src/App.js

But with no luck. As you can see, the light only appears when you move the OrbitControls within the codesanbox, since that shows the normal render of the scene. When the pathtracing render is enabled (when you do not move the OrbitControls for half a second), the light dissapears. I want the light to also be visible whenever pathtracing is enabled, as in this example from the original pathtracing library, on vanilla Three.js. https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/spotLights.html

Here, the light is visible on both modes.

Vikms95 commented 10 months ago

After trying for a while, I figured that DirectionalLight is working. How is that? I can't get SpotLight or PointLight to work with this.