Video backends: fix rounding in lighting computation.

For whatever reason, the hardware doesn't do a full divide by 255, but
instead uses an approximation with shifting, similar to the way it is done
in TEV.
This commit is contained in:
magumagu
2014-05-11 12:53:02 -07:00
parent 36720e6822
commit 9e4eeb3b9b
2 changed files with 16 additions and 11 deletions

View File

@ -255,7 +255,8 @@ static void GenerateLightingShader(T& object, LightingUidData& uid_data, int com
GenerateLightShader<T>(object, uid_data, i, lit_index, lightsColName, lightsName, coloralpha);
}
}
object.Write("%s%d = float4(mat * clamp(lacc, 0, 255) / 255) / 255.0;\n", dest, j);
object.Write("lacc = clamp(lacc, 0, 255);");
object.Write("%s%d = float4((mat * (lacc + (lacc >> 7))) >> 8) / 255.0;\n", dest, j);
object.Write("}\n");
}
}