1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-19 19:10:12 +00:00

try to estimate vertical water depth, not screen-direction water depth

This commit is contained in:
wareya 2021-03-20 13:11:19 -04:00
parent 56fe1a8c12
commit 2ea0bf91e6

View file

@ -254,7 +254,11 @@ void main(void)
// wobbly water: hard-fade into refraction texture at extremely low depth, with a wobble based on normal mapping
vec3 normalShoreRippleRain = texture2D(normalMap,normalCoords(UV, 2.0, 2.7, -1.0*waterTimer, 0.05, 0.1, normal3)).rgb - 0.5
+ texture2D(normalMap,normalCoords(UV, 2.0, 2.7, waterTimer, 0.04, -0.13, normal4)).rgb - 0.5;
float shoreOffset = clamp((realWaterDepth - (normal2.r + mix(0, normalShoreRippleRain.r, rainIntensity) + 0.35)*8), 0, 1);
float verticalWaterDepth = realWaterDepth * mix(abs(vVec.z), 1.0, 0.2); // an estimate
float shoreOffset = verticalWaterDepth - (normal2.r + mix(0, normalShoreRippleRain.r, rainIntensity) + 0.15)*8;
float fuzzFactor = min(1.0, 1000.0/surfaceDepth) * mix(abs(vVec.z), 1, 0.2);
shoreOffset *= fuzzFactor;
shoreOffset = clamp(shoreOffset, 0, 1);
gl_FragData[0].xyz = mix(rawRefraction, gl_FragData[0].xyz, shoreOffset);
#else
gl_FragData[0].xyz = mix(reflection, waterColor, (1.0-fresnel)*0.5) + specular * gl_LightSource[0].specular.xyz + vec3(rainRipple.w) * 0.7;