From 49865aa158f9770385dbd7087ab1ff5613e8cc27 Mon Sep 17 00:00:00 2001 From: Eikthyrnir Date: Sun, 14 Jan 2024 21:14:38 +0100 Subject: [PATCH] attempt to not apply normal mapping on clouds --- cw 7/shaders/shader_earth.frag | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cw 7/shaders/shader_earth.frag b/cw 7/shaders/shader_earth.frag index 0016977..411c38b 100644 --- a/cw 7/shaders/shader_earth.frag +++ b/cw 7/shaders/shader_earth.frag @@ -64,16 +64,16 @@ void main() vec3 cloudColor = texture2D(clouds, vertexTexCoordOut).rgb; //disabled to prevent riffled clouds - //textureColor = mix(vec3(1), textureColor, cloudColor.r); + textureColor = mix(vec3(1), textureColor, cloudColor.r); + + normalizedVertexNormal = vec3(0, 0, 1); + if (cloudColor.r < 1) { + //get normal from normal sampler + vec3 samplerNormal = texture2D(normalSampler, vertexTexCoordOut).xyz; + samplerNormal = 2 * samplerNormal - 1;//since sampler has values from [0, 1], but we want [-1, 1] + normalizedVertexNormal = normalize(samplerNormal);// to avoid potential precision problems in sampler texture + } - //get normal from normal sampler - vec3 samplerNormal = texture2D(normalSampler, vertexTexCoordOut).xyz; - samplerNormal = 2 * samplerNormal - 1;//since sampler has values from [0, 1], but we want [-1, 1] - normalizedVertexNormal = normalize(samplerNormal);// to avoid potential precision problems in sampler texture - - //Debug - //normalizedVertexNormal = vec3(0, 0, 1); - outColor = calcPointLight(textureColor, sunPos, sunLightDirTS, sunColor, sunLightExp); outColor += calcSpotLight(textureColor, reflectorPos, reflectorLightDirTS, reflectorColor, reflectorLightExp);