Fix vertex lighting
This commit is contained in:
parent
b82ba53b6b
commit
ecf60edc33
1 changed files with 19 additions and 13 deletions
|
|
@ -11,21 +11,27 @@
|
|||
|
||||
vec3 lightValue(DynLightInfo light)
|
||||
{
|
||||
#ifdef USE_SPRITE_CENTER
|
||||
float lightdistance = distance(light.pos.xyz, uActorCenter.xyz);
|
||||
float lightdistance;
|
||||
vec3 lightdir;
|
||||
|
||||
if (USE_SPRITE_CENTER)
|
||||
{
|
||||
lightdistance = distance(light.pos.xyz, uActorCenter.xyz);
|
||||
|
||||
if (light.radius < lightdistance)
|
||||
return vec3(0.0); // Early out lights touching surface but not this fragment
|
||||
|
||||
lightdir = normalize(light.pos.xyz - uActorCenter.xyz);
|
||||
}
|
||||
else
|
||||
{
|
||||
lightdistance = distance(light.pos.xyz, pixelpos.xyz);
|
||||
|
||||
if (light.radius < lightdistance)
|
||||
return vec3(0.0); // Early out lights touching surface but not this fragment
|
||||
if (light.radius < lightdistance)
|
||||
return vec3(0.0); // Early out lights touching surface but not this fragment
|
||||
|
||||
vec3 lightdir = normalize(light.pos.xyz - uActorCenter.xyz);
|
||||
#else
|
||||
float lightdistance = distance(light.pos.xyz, pixelpos.xyz);
|
||||
|
||||
if (light.radius < lightdistance)
|
||||
return vec3(0.0); // Early out lights touching surface but not this fragment
|
||||
|
||||
vec3 lightdir = normalize(light.pos.xyz - pixelpos.xyz);
|
||||
#endif
|
||||
lightdir = normalize(light.pos.xyz - pixelpos.xyz);
|
||||
}
|
||||
|
||||
float attenuation = distanceAttenuation(lightdistance, light.radius, light.strength, light.linearity);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue