From dc39a006dc3d58182d2dba83a4ac50258799c9f6 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 4 Sep 2016 02:37:59 +0200 Subject: [PATCH] Fix palette tonemap precision and compile error on Intel --- src/gl/renderer/gl_postprocess.cpp | 2 +- wadsrc/static/shaders/glsl/tonemap.fp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 77ee5cd79..645bc3fe1 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -257,7 +257,7 @@ void FGLRenderer::BindTonemapPalette(int texunit) { for (int b = 0; b < 64; b++) { - PalEntry color = GPalette.BaseColors[ColorMatcher.Pick((r << 2) | (r >> 1), (g << 2) | (g >> 1), (b << 2) | (b >> 1))]; + PalEntry color = GPalette.BaseColors[ColorMatcher.Pick((r << 2) | (r >> 4), (g << 2) | (g >> 4), (b << 2) | (b >> 4))]; int index = ((r * 64 + g) * 64 + b) * 4; lut[index] = color.r; lut[index + 1] = color.g; diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp index c33349a38..d6574b295 100644 --- a/wadsrc/static/shaders/glsl/tonemap.fp +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -69,15 +69,15 @@ uniform sampler2D PaletteLUT; vec3 Tonemap(vec3 color) { - ivec3 c = ivec3(clamp(color.rgb, vec3(0.0), vec3(1.0)) * 255.0 + 0.5); - int index = ((c.r >> 2) * 64 + (c.g >> 2)) * 64 + (c.b >> 2); + ivec3 c = ivec3(clamp(color.rgb, vec3(0.0), vec3(1.0)) * 63.0 + 0.5); + int index = (c.r * 64 + c.g) * 64 + c.b; int tx = index % 512; int ty = index / 512; return texelFetch(PaletteLUT, ivec2(tx, ty), 0).rgb; } #else -#error "Tonemap mode define is missing" +#error Tonemap mode define is missing #endif void main()