- fixed Intel rendering glitch with uDynLightColor

This commit is contained in:
Magnus Norddahl 2018-03-12 21:44:55 +01:00
parent 5fccdd9acd
commit 9b7bef59d2
2 changed files with 27 additions and 29 deletions

View file

@ -34,13 +34,12 @@ vec3 lightContribution(int i, vec3 normal)
vec3 ProcessMaterial(vec3 material, vec3 color)
{
if (uLightIndex >= 0)
{
vec4 dynlight = uDynLightColor;
vec3 normal = ApplyNormalMap();
if (uLightIndex >= 0)
{
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);
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);
}
}

View file

@ -36,16 +36,15 @@ vec2 lightAttenuation(int i, vec3 normal, vec3 viewdir, float lightcolorA)
vec3 ProcessMaterial(vec3 material, vec3 color)
{
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);
if (uLightIndex >= 0)
{
ivec4 lightRange = ivec4(lights[uLightIndex]) + ivec4(uLightIndex + 1);
if (lightRange.z > lightRange.x)
{
// modulated lights
@ -66,6 +65,7 @@ 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);
@ -73,6 +73,9 @@ vec3 ProcessMaterial(vec3 material, vec3 color)
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);
@ -87,11 +90,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);
}
}