From 1c50d258535de869989bd542ba534365b3fa6997 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Tue, 9 Jun 2020 15:27:38 +0300 Subject: [PATCH] Minor shader fixes Don't initialize uniform bool to false explicitly Attempt not to calculate specular lighting if the material specular color is black --- files/shaders/objects_fragment.glsl | 5 +++-- files/shaders/terrain_fragment.glsl | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/files/shaders/objects_fragment.glsl b/files/shaders/objects_fragment.glsl index 78cc8c1ddf..6ce44cc823 100644 --- a/files/shaders/objects_fragment.glsl +++ b/files/shaders/objects_fragment.glsl @@ -49,7 +49,7 @@ uniform vec2 envMapLumaBias; uniform mat2 bumpMapMatrix; #endif -uniform bool simpleWater = false; +uniform bool simpleWater; varying float euclideanDepth; varying float linearDepth; @@ -181,7 +181,8 @@ void main() matSpec = passColor.xyz; #endif - gl_FragData[0].xyz += getSpecular(normalize(viewNormal), normalize(passViewPos.xyz), shininess, matSpec) * shadowing; + if (matSpec != vec3(0.0)) + gl_FragData[0].xyz += getSpecular(normalize(viewNormal), normalize(passViewPos.xyz), shininess, matSpec) * shadowing; #if @radialFog float depth = euclideanDepth; // For the less detailed mesh of simple water we need to recalculate depth on per-pixel basis diff --git a/files/shaders/terrain_fragment.glsl b/files/shaders/terrain_fragment.glsl index 477b1bf9e4..68669dff9e 100644 --- a/files/shaders/terrain_fragment.glsl +++ b/files/shaders/terrain_fragment.glsl @@ -90,7 +90,8 @@ void main() matSpec = passColor.xyz; #endif - gl_FragData[0].xyz += getSpecular(normalize(viewNormal), normalize(passViewPos), shininess, matSpec) * shadowing; + if (matSpec != vec3(0.0)) + gl_FragData[0].xyz += getSpecular(normalize(viewNormal), normalize(passViewPos), shininess, matSpec) * shadowing; #if @radialFog float fogValue = clamp((euclideanDepth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);