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.34k stars 133 forks source link

Spotlight position is incorrect in demo #492

Closed gkjohnson closed 8 months ago

ChazHollywood commented 8 months ago

I experienced this as well after updating to the latest version. In my case it appears that the spotlight positions are correct but they are pointing the wrong way. The spotlights are oriented properly when rendered in WebGL but seem to have a different aiming target in the path traced renderer. Still investigating to see if it's something in my code or related to this bug.

Edit: Looking at this demo: https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/spotLights.html

The spotlight looks wrong in the path traced renderer only. If you drag the mouse and move the camera to reveal the webgl renderer you can see that the spotlight is pointing in a different direction that the path traced renderer. Again, looks like the position of the light might be correct but the direction or target is incorrect.

In my code I've tried moving the target to home by creating a spotlight target and using spotLight.target.position.set(0, 0, 0) but it hasn't worked so far.

gkjohnson commented 8 months ago

Fixed in b604b6364597fe3eb5210f12e46c0311b154b250 by making sure the resulting spotlight quaternion is normalized.