Open digi-chris opened 6 days ago
I figured it out... it's on this line:
I'm not entirely sure why, but you have to reverse the sun_proj.y value like this:
var sun_pos : Vector2 = Vector2(sun_proj.x / sun_proj.w, -sun_proj.y / sun_proj.w)
That seems to resolve it.
The other problem with seeing the sun disk when facing away from the camera is of course because the sun is behind the camera. Technically the calculated position is correct. I think this is fairly simple to fix (something to do with the .w coordinate?) but I haven't had a chance to look yet.
Hey @digi-chris ,
Good find, there was a recent change around the projection matrices as the flip only happens when loading those into the GPU struct we use. We're working on direct access to those.
And indeed, when the sun is behind us that will give issues, I believe we can evaluate the sign of sun_proj.z/sun_proj.w
, from memory if that is negative, the sun will be behind us.
Hi,
Thanks for this great example! It's been interesting seeing what's possible with the new compositor.
I'm not 100% sure if I'm just misunderstanding something, but I think the calculation deciding where the sun disk is located is doing something unexpected.
I created a video showing the issue, it also happens in the example but the effect is less pronounced:
https://vimeo.com/1019383187
It seems to me that when looking directly at the sun, the position is correct. As the camera is rotated, especially on the x-axis, the sun disk seems to get higher or lower than the actual sun position. Turning around the face the other way also shows the sun in the opposite direction to where it really is (demonstrated a bit quickly at then end of the video).
I'm not sure if I'm just not setting the sun location correctly, or it's not supposed to work with a dynamically-moving sun and moving camera, but since the example is exhibiting the same behavior I wondered if it's a bug?
Thanks,
Chris.