mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- fix distance attenuation for PBR materials
This commit is contained in:
parent
c0cf19e9b5
commit
4ac43dac36
1 changed files with 7 additions and 2 deletions
|
@ -56,6 +56,11 @@ float quadraticDistanceAttenuation(vec4 lightpos)
|
||||||
return attenuation;
|
return attenuation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float linearDistanceAttenuation(vec4 lightpos)
|
||||||
|
{
|
||||||
|
float lightdistance = distance(lightpos.xyz, pixelpos.xyz);
|
||||||
|
return clamp((lightpos.w - lightdistance) / lightpos.w, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
vec3 ProcessMaterialLight(Material material, vec3 ambientLight)
|
vec3 ProcessMaterialLight(Material material, vec3 ambientLight)
|
||||||
{
|
{
|
||||||
|
@ -93,7 +98,7 @@ vec3 ProcessMaterialLight(Material material, vec3 ambientLight)
|
||||||
vec3 L = normalize(lightpos.xyz - worldpos);
|
vec3 L = normalize(lightpos.xyz - worldpos);
|
||||||
vec3 H = normalize(V + L);
|
vec3 H = normalize(V + L);
|
||||||
|
|
||||||
float attenuation = quadraticDistanceAttenuation(lightpos);
|
float attenuation = linearDistanceAttenuation(lightpos);
|
||||||
if (lightspot1.w == 1.0)
|
if (lightspot1.w == 1.0)
|
||||||
attenuation *= spotLightAttenuation(lightpos, lightspot1.xyz, lightspot2.x, lightspot2.y);
|
attenuation *= spotLightAttenuation(lightpos, lightspot1.xyz, lightspot2.x, lightspot2.y);
|
||||||
if (lightcolor.a < 0.0)
|
if (lightcolor.a < 0.0)
|
||||||
|
@ -133,7 +138,7 @@ vec3 ProcessMaterialLight(Material material, vec3 ambientLight)
|
||||||
vec3 L = normalize(lightpos.xyz - worldpos);
|
vec3 L = normalize(lightpos.xyz - worldpos);
|
||||||
vec3 H = normalize(V + L);
|
vec3 H = normalize(V + L);
|
||||||
|
|
||||||
float attenuation = quadraticDistanceAttenuation(lightpos);
|
float attenuation = linearDistanceAttenuation(lightpos);
|
||||||
if (lightspot1.w == 1.0)
|
if (lightspot1.w == 1.0)
|
||||||
attenuation *= spotLightAttenuation(lightpos, lightspot1.xyz, lightspot2.x, lightspot2.y);
|
attenuation *= spotLightAttenuation(lightpos, lightspot1.xyz, lightspot2.x, lightspot2.y);
|
||||||
if (lightcolor.a < 0.0)
|
if (lightcolor.a < 0.0)
|
||||||
|
|
Loading…
Reference in a new issue