jbouny / ocean

Realistic water shader for Three.js

Home Page:http://jeremybouny.fr/ocean/demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reflection offset towards screen bottom-right?

fortytwoish opened this issue · comments

commented

Hey! First of all - amazing shader!

Sadly, I'm experiencing some issues. I have set it up according to the Wiki entry and compared it to your examples, there are no differences I could find.

The reflection seems to be offset towards the bottom right, and there is a visible distance towards the reflected terrain. You can see my problems here:
shader1
shader2

Thank you in advance!

Edit: My backfaces weren't visible. That doesn't solve it, sadly - I've still got the offset problem:
image

Edit 2: I managed to fix it! I tweaked some parameters in the shader's mirror sampling section, namely // Compute final 3d distortion, and project it to get the mirror sampling
' float distance = length(worldToEye);',
' vec2 distortion = distordCoord.xy * distortionScale * sqrt(distance) * 0.07;',
' vec3 mirrorDistord = mirrorCoord.xyz + vec3(distortion.x, distortion.y, 4.0);', <- set this vec3's z component to 4.0 instead of 1.0

Still no idea what caused it or whether it was even the shader's problem to begin with, but maybe it's helpful to someone.