forked from LeenkxTeam/LNXSDK
Water Foam Fix
This commit is contained in:
@ -151,6 +151,7 @@ void main() {
|
||||
}
|
||||
|
||||
// Displace surface
|
||||
float geomZ = p.z; // undisplaced depth for foam/fog tests
|
||||
p.z += (sin(p.x * 10.0 / waterDisplace + speed) * cos(p.y * 10.0 / waterDisplace + speed)
|
||||
+ sin(p.x * 20.0 / waterDisplace + speed * 1.3) * cos(p.y * 20.0 / waterDisplace + speed * 1.3) * 0.5)
|
||||
/ 50.0 * waterDisplace;
|
||||
@ -229,13 +230,13 @@ void main() {
|
||||
float specAmount = pow(max(dot(n2, h), 0.0), 200.0) * (200.0 + 8.0) / (PI * 8.0);
|
||||
fragColor.rgb += specAmount * (isSky ? 0.3 : 1.0) * horizonFactor;
|
||||
// Depth fog - blend toward waterColor with depth, faded at horizon
|
||||
float depthFog = clamp(-(p.z - waterLevel) * waterDensity, 0.0, 0.9);
|
||||
float depthFog = clamp(-(geomZ - waterLevel) * waterDensity, 0.0, 0.9);
|
||||
fragColor.rgb = mix(fragColor.rgb, waterColor, depthFog * horizonFactor);
|
||||
// Alpha fades smoothly at horizon instead of hard cut
|
||||
fragColor.a = isSky ? horizonFactor : clamp(abs(p.z - waterLevel) * 5.0, 0.0, 1.0);
|
||||
fragColor.a = isSky ? horizonFactor : clamp(abs(geomZ - waterLevel) * 5.0, 0.0, 1.0);
|
||||
|
||||
// Foam - based on actual geometry depth below water surface
|
||||
float fd = isSky ? 1.0 : abs(p.z - waterLevel);
|
||||
float fd = isSky ? 1.0 : abs(geomZ - waterLevel);
|
||||
if (fd < 0.1) {
|
||||
// Based on foam by Owen Deery
|
||||
// http://fire-face.com/personal/water
|
||||
|
||||
Reference in New Issue
Block a user