diff --git a/wadsrc/static/shaders/glsl/material_normal.fp b/wadsrc/static/shaders/glsl/material_normal.fp index 610a239d27..b048f45597 100644 --- a/wadsrc/static/shaders/glsl/material_normal.fp +++ b/wadsrc/static/shaders/glsl/material_normal.fp @@ -34,13 +34,12 @@ vec3 lightContribution(int i, vec3 normal) vec3 ProcessMaterial(vec3 material, vec3 color) { + vec4 dynlight = uDynLightColor; + vec3 normal = ApplyNormalMap(); + if (uLightIndex >= 0) { - vec4 dynlight = uDynLightColor; - vec3 normal = ApplyNormalMap(); - ivec4 lightRange = ivec4(lights[uLightIndex]) + ivec4(uLightIndex + 1); - if (lightRange.z > lightRange.x) { // modulated lights @@ -55,9 +54,13 @@ vec3 ProcessMaterial(vec3 material, vec3 color) dynlight.rgb -= lightContribution(i, normal); } } + } - vec3 frag = material * clamp(color + desaturate(dynlight).rgb, 0.0, 1.4); + vec3 frag = material * clamp(color + desaturate(dynlight).rgb, 0.0, 1.4); + if (uLightIndex >= 0) + { + ivec4 lightRange = ivec4(lights[uLightIndex]) + ivec4(uLightIndex + 1); if (lightRange.w > lightRange.z) { vec4 addlight = vec4(0.0,0.0,0.0,0.0); @@ -70,11 +73,7 @@ vec3 ProcessMaterial(vec3 material, vec3 color) frag = clamp(frag + desaturate(addlight).rgb, 0.0, 1.0); } + } - return frag; - } - else - { - return material * clamp(color + desaturate(uDynLightColor).rgb, 0.0, 1.4); - } + return frag; } diff --git a/wadsrc/static/shaders/glsl/material_specular.fp b/wadsrc/static/shaders/glsl/material_specular.fp index ab61d6cf9f..dff6347370 100644 --- a/wadsrc/static/shaders/glsl/material_specular.fp +++ b/wadsrc/static/shaders/glsl/material_specular.fp @@ -36,16 +36,15 @@ vec2 lightAttenuation(int i, vec3 normal, vec3 viewdir, float lightcolorA) vec3 ProcessMaterial(vec3 material, vec3 color) { + vec4 dynlight = uDynLightColor; + vec4 specular = vec4(0.0, 0.0, 0.0, 1.0); + + vec3 normal = ApplyNormalMap(); + vec3 viewdir = normalize(uCameraPos.xyz - pixelpos.xyz); + if (uLightIndex >= 0) { - vec4 dynlight = uDynLightColor; - vec4 specular = vec4(0.0, 0.0, 0.0, 1.0); - - vec3 normal = ApplyNormalMap(); - vec3 viewdir = normalize(uCameraPos.xyz - pixelpos.xyz); - ivec4 lightRange = ivec4(lights[uLightIndex]) + ivec4(uLightIndex + 1); - if (lightRange.z > lightRange.x) { // modulated lights @@ -66,17 +65,21 @@ vec3 ProcessMaterial(vec3 material, vec3 color) specular.rgb -= lightcolor.rgb * attenuation.y; } } + } - dynlight.rgb = clamp(color + desaturate(dynlight).rgb, 0.0, 1.4); - specular.rgb = clamp(desaturate(specular).rgb, 0.0, 1.4); + dynlight.rgb = clamp(color + desaturate(dynlight).rgb, 0.0, 1.4); + specular.rgb = clamp(desaturate(specular).rgb, 0.0, 1.4); - vec4 materialSpec = texture(speculartexture, vTexCoord.st); - vec3 frag = material * dynlight.rgb + materialSpec.rgb * specular.rgb; + vec4 materialSpec = texture(speculartexture, vTexCoord.st); + vec3 frag = material * dynlight.rgb + materialSpec.rgb * specular.rgb; + if (uLightIndex >= 0) + { + ivec4 lightRange = ivec4(lights[uLightIndex]) + ivec4(uLightIndex + 1); if (lightRange.w > lightRange.z) { vec4 addlight = vec4(0.0,0.0,0.0,0.0); - + // additive lights for(int i=lightRange.z; i