mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-19 08:01:50 +00:00
Fix Specular not using Material definition for Glossiness and Level
This commit is contained in:
parent
847f34f2c9
commit
7ce6f2214c
1 changed files with 4 additions and 7 deletions
|
@ -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 lightpos = lights[i];
|
||||||
vec4 lightspot1 = lights[i+2];
|
vec4 lightspot1 = lights[i+2];
|
||||||
|
@ -25,9 +25,6 @@ vec2 lightAttenuation(int i, vec3 normal, vec3 viewdir, float lightcolorA)
|
||||||
if (attenuation <= 0.0)
|
if (attenuation <= 0.0)
|
||||||
return vec2(0.0);
|
return vec2(0.0);
|
||||||
|
|
||||||
float glossiness = uSpecularMaterial.x;
|
|
||||||
float specularLevel = uSpecularMaterial.y;
|
|
||||||
|
|
||||||
vec3 halfdir = normalize(viewdir + lightdir);
|
vec3 halfdir = normalize(viewdir + lightdir);
|
||||||
float specAngle = clamp(dot(halfdir, normal), 0.0f, 1.0f);
|
float specAngle = clamp(dot(halfdir, normal), 0.0f, 1.0f);
|
||||||
float phExp = glossiness * 4.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)
|
for(int i=lightRange.x; i<lightRange.y; i+=4)
|
||||||
{
|
{
|
||||||
vec4 lightcolor = lights[i+1];
|
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;
|
dynlight.rgb += lightcolor.rgb * attenuation.x;
|
||||||
specular.rgb += lightcolor.rgb * attenuation.y;
|
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)
|
for(int i=lightRange.y; i<lightRange.z; i+=4)
|
||||||
{
|
{
|
||||||
vec4 lightcolor = lights[i+1];
|
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;
|
dynlight.rgb -= lightcolor.rgb * attenuation.x;
|
||||||
specular.rgb -= lightcolor.rgb * attenuation.y;
|
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)
|
for(int i=lightRange.z; i<lightRange.w; i+=4)
|
||||||
{
|
{
|
||||||
vec4 lightcolor = lights[i+1];
|
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;
|
addlight.rgb += lightcolor.rgb * attenuation.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue