skip specular calculations underwater

This commit is contained in:
epochwon 2025-08-30 10:28:53 -04:00
parent 5f22732876
commit d0d7fe024a

View File

@ -165,15 +165,15 @@ void main(void)
// specular // specular
const float SPEC_MAGIC = 1.55; // from the original blender shader, changing it makes the spec vanish or become too bright 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)); float specular = 0.0;
vec3 viewReflectDir = reflect(viewDir, specNormal); if (cameraPos.z >= 0.0)
float phongTerm = max(dot(viewReflectDir, sunWorldDir), 0.0); {
float specular = pow(atan(phongTerm * SPEC_MAGIC), SPEC_HARDNESS) * SPEC_BRIGHTNESS; vec3 specNormal = normalize(vec3(normal.x * SPEC_BUMPINESS, normal.y * SPEC_BUMPINESS, normal.z));
specular = clamp(specular, 0.0, 1.0) * shadow * sunSpec.a; vec3 viewReflectDir = reflect(viewDir, specNormal);
float phongTerm = max(dot(viewReflectDir, sunWorldDir), 0.0);
// disable sun specular when underwater specular = pow(atan(phongTerm * SPEC_MAGIC), SPEC_HARDNESS) * SPEC_BRIGHTNESS;
if (cameraPos.z < 0.0) specular = clamp(specular, 0.0, 1.0) * shadow * sunSpec.a;
specular = 0.0; }
// artificial specularity to make rain ripples more noticeable // artificial specularity to make rain ripples more noticeable
vec3 skyColorEstimate = vec3(max(0.0, mix(-0.3, 1.0, sunFade))); vec3 skyColorEstimate = vec3(max(0.0, mix(-0.3, 1.0, sunFade)));