From e2f9e12efb76707f6f31530d80d9ab06c24a5668 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 19 Oct 2019 16:35:06 +0200 Subject: [PATCH] - implemented shade level based depth fading for the true color renderer. --- source/glbackend/gl_palmanager.cpp | 11 ++++++----- wadsrc/static/demolition/shaders/glsl/polymost.fp | 5 ++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/glbackend/gl_palmanager.cpp b/source/glbackend/gl_palmanager.cpp index fbb286476..a6afd32d0 100644 --- a/source/glbackend/gl_palmanager.cpp +++ b/source/glbackend/gl_palmanager.cpp @@ -262,16 +262,17 @@ void PaletteManager::BindPalswap(int index) if (uindex != lastsindex) { lastsindex = uindex; - if (palswaps[uindex].swaptexture == nullptr) + auto& ps = palswaps[uindex]; + if (ps.swaptexture == nullptr) { auto p = GLInterface.NewTexture(); p->CreateTexture(256, numshades, true, false); - p->LoadTexture((uint8_t*)palswaps[uindex].lookup); + p->LoadTexture((uint8_t*)ps.lookup); p->SetSampler(Sampler2DNoFilter); - palswaps[uindex].swaptexture = p; + ps.swaptexture = p; } - inst->BindTexture(1, palswaps[uindex].swaptexture); - inst->SetFadeColor(palswaps[index].fadeColor); + inst->BindTexture(1, ps.swaptexture); + inst->SetFadeColor(ps.fadeColor); } } diff --git a/wadsrc/static/demolition/shaders/glsl/polymost.fp b/wadsrc/static/demolition/shaders/glsl/polymost.fp index 18bd37048..ae4fb1a2d 100644 --- a/wadsrc/static/demolition/shaders/glsl/polymost.fp +++ b/wadsrc/static/demolition/shaders/glsl/polymost.fp @@ -183,7 +183,10 @@ void main() else { color.rgb *= detailColor.rgb; - // todo: For True Color, calculate a shade value from the table and apply that to the color directly. + shade = clamp(shade / (u_numShades-2), 0.0, 1.0); + // Apply the shade as a linear depth fade ramp. + color.rgb = mix(color.rgb, u_fogColor.rgb, shade); + } if (fullbright == 0.0) color.rgb *= v_color.rgb; color.a *= v_color.a;