JamesTKhan/Mundus

Water Reflections break on Camera Yaw/Roll rotation

Closed this issue · 2 comments

Describe the bug
Water reflections break when the camera view is rotated on X or Z axis. Reflections only invert the pitch currently.

To Reproduce
Steps to reproduce the behavior:

  1. Load into a runtime project with water
  2. Rotate camera (cam.rotate(Vector3.Z, 50);)

Here is the issue captured in a video showing a camera Z rotation: https://imgur.com/a/8rsZ14L

I emailed ThinMatrix, and he confirmed that his reflection solution does not handle pitch/roll of the camera.

Email from ThinMatrix:

Hey Anthony,

The code I made in the tutorials doesn't take camera roll into account, which is why the reflection gets messed up. It shouldn't be too hard to add it to the calculations though. However, I have to admit it's been many many years since I worked on water reflections so I can't think how to do that off the top of my head right now. I guess you'd have to apply the roll (maybe inverted?) to the camera when you invert it for rendering the reflection pass. Something like that. Maybe you can find the solution online - it's a fairly common technique so there should be plenty of resources out there.

Hope you find a fix,
Karl