(gl/vk)_shader_gen: Use floor instead of int cast (#6885)

This commit is contained in:
GPUCode 2023-08-17 23:16:28 +03:00 committed by GitHub
parent 1d3bf64f13
commit bc0bf4d3d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 8 deletions

View file

@ -1246,13 +1246,13 @@ float LookupLightingLUT(int lut_index, int index, float delta) {
}
float LookupLightingLUTUnsigned(int lut_index, float pos) {
int index = clamp(int(pos * 256.0), 0, 255);
int index = int(clamp(floor(pos * 256.0), 0.f, 255.f));
float delta = pos * 256.0 - float(index);
return LookupLightingLUT(lut_index, index, delta);
}
float LookupLightingLUTSigned(int lut_index, float pos) {
int index = clamp(int(pos * 128.0), -128, 127);
int index = int(clamp(floor(pos * 128.0), -128.f, 127.f));
float delta = pos * 128.0 - float(index);
if (index < 0) index += 256;
return LookupLightingLUT(lut_index, index, delta);