From bf55997a56ae175691c13897954723a255a08011 Mon Sep 17 00:00:00 2001
From: Stuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Date: Fri, 5 Nov 2021 19:55:05 +0000
Subject: [PATCH] WS30: Improved ambient color

Previous we just applied gl_LightSource[0].ambient without
multiplying it by the texture itself, so it just lightened
everything.

This fixes that.  (ws30-ALS-detailed.frag still to do)
---
 Shaders/ws30-ALS.frag | 2 +-
 Shaders/ws30-q1.frag  | 2 +-
 Shaders/ws30.frag     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Shaders/ws30-ALS.frag b/Shaders/ws30-ALS.frag
index a65c1819e..3a1c5205d 100644
--- a/Shaders/ws30-ALS.frag
+++ b/Shaders/ws30-ALS.frag
@@ -119,7 +119,7 @@ void main()
     vec4 mat_diffuse = texture(diffuseArray, index);
     vec4 mat_specular = texture(specularArray, index);
 
-    vec4 color = gl_Color + mat_diffuse * NdotL *  gl_LightSource[0].diffuse;
+    vec4 color = mat_diffuse * (gl_Color + NdotL *  gl_LightSource[0].diffuse);
 
     // Testing code:
     // Use rlc even when looking up textures to recreate the extra performance hit
diff --git a/Shaders/ws30-q1.frag b/Shaders/ws30-q1.frag
index 4b62e63b3..e30250686 100644
--- a/Shaders/ws30-q1.frag
+++ b/Shaders/ws30-q1.frag
@@ -41,7 +41,7 @@ void main()
 
 	// Different textures have different have different dimensions.
 	// Dimensions array is scaled to fit in [0...1.0] in the texture1D, so has to be scaled back up here.
-	vec4 color = texture(diffuseArray, float(lc)/512.0) * NdotL * gl_LightSource[0].diffuse;	
+	vec4 color = texture(diffuseArray, float(lc)/512.0) * (gl_LightSource[0].ambient + NdotL * gl_LightSource[0].diffuse);
 	vec4 specular = texture(specularArray, float(lc)/512.0);
 	vec2 atlas_dimensions = 10000.0 * texture(dimensionsArray, float(lc)/512.0).st;
 	vec2 atlas_scale =  vec2(tile_width / atlas_dimensions.s, tile_height / atlas_dimensions.t );
diff --git a/Shaders/ws30.frag b/Shaders/ws30.frag
index 07e16e072..90c02e362 100644
--- a/Shaders/ws30.frag
+++ b/Shaders/ws30.frag
@@ -40,7 +40,7 @@ void main()
 
 	// Different textures have different have different dimensions.
 	// Dimensions array is scaled to fit in [0...1.0] in the texture1D, so has to be scaled back up here.
-	vec4 color = texture(diffuseArray, float(lc)/512.0) * NdotL * gl_LightSource[0].diffuse;	
+	vec4 color = texture(diffuseArray, float(lc)/512.0) * (gl_LightSource[0].ambient + NdotL * gl_LightSource[0].diffuse);
 	vec4 specular = texture(specularArray, float(lc)/512.0);
 	vec2 atlas_dimensions = 10000.0 * texture(dimensionsArray, float(lc)/512.0).st;
 	vec2 atlas_scale =  vec2(tile_width / atlas_dimensions.s, tile_height / atlas_dimensions.t );