Skip to content

Commit

Permalink
Fix Specular not using Material definition for Glossiness and Level
Browse files Browse the repository at this point in the history
  • Loading branch information
AJMJ2012 authored and madame-rachelle committed Aug 8, 2024
1 parent 847f34f commit 7ce6f22
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions wadsrc/static/shaders/glsl/material_specular.fp
Original file line number Diff line number Diff line change
@@ -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];
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 7ce6f22

Please sign in to comment.