Correctly handle attenuation func of none

This commit is contained in:
Pokechu22 2022-02-27 12:21:49 -08:00
commit 8a53fe4f46

View file

@ -27,6 +27,15 @@ static void GenerateLightShader(ShaderCode& object, const LightingUidData& uid_d
switch (attn_func)
{
case AttenuationFunc::None:
// This logic correctly reproduces the behavior (if diffuse > 0, then lacc is 255, if it's < 0
// lacc is 0, and if it's equal to 0 lacc is unchanged, but with DiffuseFunc::None lacc instead
// has the light's color added to it), but may be an overly jank implementation (and might give
// incorrect results for a light value of 1/256, for instance; testing is needed)
if (diffuse_func == DiffuseFunc::None)
object.Write(" float attn = 1.0;\n");
else
object.Write(" float attn = 1024.0;\n");
break;
case AttenuationFunc::Dir:
object.Write(" float attn = 1.0;\n");
break;