From 1098bd2467e0287787b8f503df007eaf9a63b2e2 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Tue, 14 Aug 2018 21:35:23 +0100 Subject: [PATCH] Optimise lighting.glsl for Mesa users. --- files/shaders/lighting.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/files/shaders/lighting.glsl b/files/shaders/lighting.glsl index d234aaaad..c70d0a59a 100644 --- a/files/shaders/lighting.glsl +++ b/files/shaders/lighting.glsl @@ -35,12 +35,12 @@ vec4 doLighting(vec3 viewPos, vec3 viewNormal, vec4 vertexColor, out vec3 shadow vec3 diffuseLight, ambientLight; perLight(ambientLight, diffuseLight, 0, viewPos, viewNormal, diffuse, ambient); #if PER_PIXEL_LIGHTING - lightResult.xyz += ambientLight + diffuseLight * shadowing; + lightResult.xyz += diffuseLight * shadowing - diffuseLight; // This light gets added a second time in the loop to fix Mesa users' slowdown, so we need to negate its contribution here. #else shadowDiffuse = diffuseLight; - lightResult.xyz += ambientLight; + lightResult.xyz -= shadowDiffuse; // This light gets added a second time in the loop to fix Mesa users' slowdown, so we need to negate its contribution here. #endif - for (int i=1; i