Fix Specular not using Material definition for Glossiness and Level

This commit is contained in:
Ashley Miller-Jelfs 2024-08-08 15:13:59 +09:30 committed by Rachael Alexanderson
parent 847f34f2c9
commit 7ce6f2214c

View file

@ -1,5 +1,5 @@
vec2 lightAttenuation(int i, vec3 normal, vec3 viewdir, float lightcolorA)
vec2 lightAttenuation(int i, vec3 normal, vec3 viewdir, float lightcolorA, float glossiness, float specularLevel)
{
vec4 lightpos = lights[i];
vec4 lightspot1 = lights[i+2];
@ -25,9 +25,6 @@ vec2 lightAttenuation(int i, vec3 normal, vec3 viewdir, float lightcolorA)
if (attenuation <= 0.0)
return vec2(0.0);
float glossiness = uSpecularMaterial.x;
float specularLevel = uSpecularMaterial.y;
vec3 halfdir = normalize(viewdir + lightdir);
float specAngle = clamp(dot(halfdir, normal), 0.0f, 1.0f);
float phExp = glossiness * 4.0f;
@ -51,7 +48,7 @@ vec3 ProcessMaterialLight(Material material, vec3 color)
for(int i=lightRange.x; i<lightRange.y; i+=4)
{
vec4 lightcolor = lights[i+1];
vec2 attenuation = lightAttenuation(i, normal, viewdir, lightcolor.a);
vec2 attenuation = lightAttenuation(i, normal, viewdir, lightcolor.a, material.Glossiness, material.SpecularLevel);
dynlight.rgb += lightcolor.rgb * attenuation.x;
specular.rgb += lightcolor.rgb * attenuation.y;
}
@ -60,7 +57,7 @@ vec3 ProcessMaterialLight(Material material, vec3 color)
for(int i=lightRange.y; i<lightRange.z; i+=4)
{
vec4 lightcolor = lights[i+1];
vec2 attenuation = lightAttenuation(i, normal, viewdir, lightcolor.a);
vec2 attenuation = lightAttenuation(i, normal, viewdir, lightcolor.a, material.Glossiness, material.SpecularLevel);
dynlight.rgb -= lightcolor.rgb * attenuation.x;
specular.rgb -= lightcolor.rgb * attenuation.y;
}
@ -99,7 +96,7 @@ vec3 ProcessMaterialLight(Material material, vec3 color)
for(int i=lightRange.z; i<lightRange.w; i+=4)
{
vec4 lightcolor = lights[i+1];
vec2 attenuation = lightAttenuation(i, normal, viewdir, lightcolor.a);
vec2 attenuation = lightAttenuation(i, normal, viewdir, lightcolor.a, material.Glossiness, material.SpecularLevel);
addlight.rgb += lightcolor.rgb * attenuation.x;
}