From 5f22732876aa94e0e94e63765cb1da1ccdebd991 Mon Sep 17 00:00:00 2001 From: epochwon Date: Wed, 27 Aug 2025 13:51:22 -0400 Subject: [PATCH 1/2] disable sun specular underwater --- files/shaders/compatibility/water.frag | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/shaders/compatibility/water.frag b/files/shaders/compatibility/water.frag index dbf36560b3..d657989282 100644 --- a/files/shaders/compatibility/water.frag +++ b/files/shaders/compatibility/water.frag @@ -171,6 +171,10 @@ void main(void) float specular = pow(atan(phongTerm * SPEC_MAGIC), SPEC_HARDNESS) * SPEC_BRIGHTNESS; specular = clamp(specular, 0.0, 1.0) * shadow * sunSpec.a; + // disable sun specular when underwater + if (cameraPos.z < 0.0) + specular = 0.0; + // artificial specularity to make rain ripples more noticeable vec3 skyColorEstimate = vec3(max(0.0, mix(-0.3, 1.0, sunFade))); vec3 rainSpecular = abs(rainRipple.w)*mix(skyColorEstimate, vec3(1.0), 0.05)*0.5; From d0d7fe024a20711d5c68889118e65ecf86b4e109 Mon Sep 17 00:00:00 2001 From: epochwon Date: Sat, 30 Aug 2025 10:28:53 -0400 Subject: [PATCH 2/2] skip specular calculations underwater --- files/shaders/compatibility/water.frag | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/files/shaders/compatibility/water.frag b/files/shaders/compatibility/water.frag index d657989282..f40a6fef22 100644 --- a/files/shaders/compatibility/water.frag +++ b/files/shaders/compatibility/water.frag @@ -165,15 +165,15 @@ void main(void) // specular const float SPEC_MAGIC = 1.55; // from the original blender shader, changing it makes the spec vanish or become too bright - vec3 specNormal = normalize(vec3(normal.x * SPEC_BUMPINESS, normal.y * SPEC_BUMPINESS, normal.z)); - vec3 viewReflectDir = reflect(viewDir, specNormal); - float phongTerm = max(dot(viewReflectDir, sunWorldDir), 0.0); - float specular = pow(atan(phongTerm * SPEC_MAGIC), SPEC_HARDNESS) * SPEC_BRIGHTNESS; - specular = clamp(specular, 0.0, 1.0) * shadow * sunSpec.a; - - // disable sun specular when underwater - if (cameraPos.z < 0.0) - specular = 0.0; + float specular = 0.0; + if (cameraPos.z >= 0.0) + { + vec3 specNormal = normalize(vec3(normal.x * SPEC_BUMPINESS, normal.y * SPEC_BUMPINESS, normal.z)); + vec3 viewReflectDir = reflect(viewDir, specNormal); + float phongTerm = max(dot(viewReflectDir, sunWorldDir), 0.0); + specular = pow(atan(phongTerm * SPEC_MAGIC), SPEC_HARDNESS) * SPEC_BRIGHTNESS; + specular = clamp(specular, 0.0, 1.0) * shadow * sunSpec.a; + } // artificial specularity to make rain ripples more noticeable vec3 skyColorEstimate = vec3(max(0.0, mix(-0.3, 1.0, sunFade)));