From 286d53d3bf8445caca19ceaf3ccaa6755049ba46 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 11 Feb 2020 20:55:47 +0100 Subject: [PATCH] - added the missing handling for the basepal tinting. --- source/blood/src/view.cpp | 2 ++ source/build/src/polymost.cpp | 6 ------ source/glbackend/gl_shader.cpp | 1 + source/glbackend/gl_shader.h | 1 + source/glbackend/gl_texture.cpp | 11 ++++++++++- source/glbackend/glbackend.cpp | 1 + wadsrc/static/engine/shaders/glsl/polymost.fp | 2 ++ 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index fabe3a027..70fdc2fab 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -3482,6 +3482,7 @@ void viewDrawScreen(bool sceneonly) } #endif + PspTwoDSetter p2set; if (gViewPos == 0) { if (cl_crosshair) @@ -3533,6 +3534,7 @@ void viewDrawScreen(bool sceneonly) rotatesprite(0, 200 << 16, 65536, 0, 2358, 0, 0, 256 + 22, gViewX0, gViewY0, gViewX1, gViewY1); rotatesprite(320 << 16, 200 << 16, 65536, 1024, 2358, 0, 0, 512 + 18, gViewX0, gViewY0, gViewX1, gViewY1); } + p2set.clear(); if (v4 && gNetPlayers > 1) { DoLensEffect(); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 7e632607e..fe4a3919f 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -3166,12 +3166,6 @@ void polymost_drawrooms() { if (videoGetRenderMode() == REND_CLASSIC) return; - // This is a global setting for the entire scene, so let's do it here, right at the start. - auto& hh = hictinting[MAXPALOOKUPS - 1]; - // This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.) - GLInterface.SetBasepalTint(hh.tint); - - polymost_outputGLDebugMessage(3, "polymost_drawrooms()"); videoBeginDrawing(); diff --git a/source/glbackend/gl_shader.cpp b/source/glbackend/gl_shader.cpp index 256732a98..ea96e7e73 100644 --- a/source/glbackend/gl_shader.cpp +++ b/source/glbackend/gl_shader.cpp @@ -144,6 +144,7 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char Brightness.Init(hShader, "u_brightness"); FogColor.Init(hShader, "u_fogColor"); AlphaThreshold.Init(hShader, "u_alphaThreshold"); + FullscreenTint.Init(hShader, "u_fullscreenTint"); TintModulate.Init(hShader, "u_tintModulate"); TintOverlay.Init(hShader, "u_tintOverlay"); TintFlags.Init(hShader, "u_tintFlags"); diff --git a/source/glbackend/gl_shader.h b/source/glbackend/gl_shader.h index 538958f37..44f245561 100644 --- a/source/glbackend/gl_shader.h +++ b/source/glbackend/gl_shader.h @@ -45,6 +45,7 @@ public: FBufferedUniform1f Brightness; FBufferedUniform1f AlphaThreshold; FBufferedUniformPalEntry FogColor; + FBufferedUniformPalEntry FullscreenTint; FBufferedUniformPalEntry TintModulate; FBufferedUniformPalEntry TintOverlay; FBufferedUniform1i TintFlags; diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index eae6f067d..f6eb2a4b8 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -165,12 +165,21 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int int lookuppal = 0; VSMatrix texmat; + GLInterface.SetBasepalTint(0xffffff); + auto& h = hictinting[palette]; bool applytint = false; auto rep = (hw_hightile && !(h.f & HICTINT_ALWAYSUSEART)) ? tex->FindReplacement(palette) : nullptr; if (rep) { - // Hightile replacements have only one texture representation and it is always the base. + if (usepalette != 0) + { + // This is a global setting for the entire scene, so let's do it here, right at the start. (Fixme: Store this in a static table instead of reusing the same entry for all palettes.) + auto& hh = hictinting[MAXPALOOKUPS - 1]; + // This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.) + GLInterface.SetBasepalTint(hh.tint); + } + tex = rep->faces[0]; TextureType = TT_HICREPLACE; if (rep->palnum != palette || (h.f & HICTINT_APPLYOVERALTPAL)) applytint = true; diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index b72f4fe64..7dc23c8a2 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -473,6 +473,7 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState) shader->TintFlags.Set(hictint_flags); shader->TintModulate.Set(hictint); shader->TintOverlay.Set(hictint_overlay); + shader->FullscreenTint.Set(fullscreenTint); if (matrixIndex[Matrix_View] != -1) shader->RotMatrix.Set(matrixArray[matrixIndex[Matrix_View]].get()); if (matrixIndex[Matrix_Projection] != -1) diff --git a/wadsrc/static/engine/shaders/glsl/polymost.fp b/wadsrc/static/engine/shaders/glsl/polymost.fp index 05d5071c6..71ff2cc10 100644 --- a/wadsrc/static/engine/shaders/glsl/polymost.fp +++ b/wadsrc/static/engine/shaders/glsl/polymost.fp @@ -38,6 +38,7 @@ uniform float u_alphaThreshold; uniform vec4 u_tintOverlay, u_tintModulate; uniform int u_tintFlags; +uniform vec4 u_fullscreenTint; uniform float u_npotEmulationFactor; uniform float u_npotEmulationXOffset; @@ -243,6 +244,7 @@ void main() } color.rgb = pow(color.rgb, vec3(u_brightness)); + color.rgb *= u_fullscreenTint.rgb; // must be the last thing to be done. fragColor = color; fragFog = vec4(0.0, 0.0, 0.0, 1.0); // Does build have colored fog? vec3 normal = normalize(cross(dFdx(v_eyeCoordPosition.xyz), dFdy(v_eyeCoordPosition.xyz)));