diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 429f69c349..d70eb51661 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -72,6 +72,7 @@ void FRenderState::Reset() mModelMatrixEnabled = false; mTextureMatrixEnabled = false; mObjectColor = 0xffffffff; + mObjectColor2 = 0; mVertexBuffer = mCurrentVertexBuffer = NULL; mColormapState = CM_DEFAULT; mSoftLight = 0; @@ -144,6 +145,8 @@ bool FRenderState::ApplyShader() glVertexAttrib4fv(VATTR_COLOR, mColor.vec); glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec); + //activeShader->muObjectColor2.Set(mObjectColor2); + activeShader->muObjectColor2.Set(mObjectColor2); activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muFogEnabled.Set(fogset); diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 76e2c791cd..2bef2ff91b 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -106,6 +106,7 @@ class FRenderState FStateVec4 mClipLine; PalEntry mFogColor; PalEntry mObjectColor; + PalEntry mObjectColor2; FStateVec4 mDynColor; float mClipSplit[2]; @@ -381,6 +382,11 @@ public: mObjectColor = pe; } + void SetObjectColor2(PalEntry pe) + { + mObjectColor2 = pe; + } + void SetFog(PalEntry c, float d) { const float LOG2E = 1.442692f; // = 1/log(2) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index ef512faea9..421139050c 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -225,6 +225,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muFogColor.Init(hShader, "uFogColor"); muDynLightColor.Init(hShader, "uDynLightColor"); muObjectColor.Init(hShader, "uObjectColor"); + muObjectColor2.Init(hShader, "uObjectColor2"); muGlowBottomColor.Init(hShader, "uGlowBottomColor"); muGlowTopColor.Init(hShader, "uGlowTopColor"); muGlowBottomPlane.Init(hShader, "uGlowBottomPlane"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index f9eb5c2920..e8012aa5d3 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -271,6 +271,7 @@ class FShader FBufferedUniformPE muFogColor; FBufferedUniform4f muDynLightColor; FBufferedUniformPE muObjectColor; + FBufferedUniformPE muObjectColor2; FUniform4f muGlowBottomColor; FUniform4f muGlowTopColor; FUniform4f muGlowBottomPlane; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 145f76964c..a6bc6bbd7f 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -1,5 +1,5 @@ in vec4 pixelpos; -in vec2 glowdist; +in vec3 glowdist; in vec4 vWorldNormal; in vec4 vEyeNormal; @@ -89,7 +89,8 @@ vec4 getTexel(vec2 st) } break; } - texel *= uObjectColor; + if (uObjectColor2.a == 0) texel *= uObjectColor; + else texel *= mix(uObjectColor, uObjectColor2, glowdist.z); return desaturate(texel); } diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 1de8854c0d..f4937ab66a 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -6,7 +6,7 @@ in vec4 aColor; in vec4 aVertex2; in vec4 aNormal; out vec4 pixelpos; -out vec2 glowdist; +out vec3 glowdist; out vec4 vWorldNormal; out vec4 vEyeNormal; @@ -50,9 +50,15 @@ void main() pixelpos.xyz = worldcoord.xyz; pixelpos.w = -eyeCoordPos.z/eyeCoordPos.w; - glowdist.x = -((uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z) - worldcoord.y; - glowdist.y = worldcoord.y + ((uGlowBottomPlane.w + uGlowBottomPlane.x * worldcoord.x + uGlowBottomPlane.y * worldcoord.z) * uGlowBottomPlane.z); + float topatpoint = -((uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z); + float bottomatpoint = -((uGlowBottomPlane.w + uGlowBottomPlane.x * worldcoord.x + uGlowBottomPlane.y * worldcoord.z) * uGlowBottomPlane.z); + glowdist.x = topatpoint - worldcoord.y; + glowdist.y = worldcoord.y - bottomatpoint; + glowdist.z = glowdist.x / (topatpoint - bottomatpoint); + + return (uGlowTopPlane.w + normal.X*v->fX() + normal.Y*v->fY()) * negiC; + if (uSplitBottomPlane.z != 0.0) { gl_ClipDistance[3] = -((uSplitTopPlane.w + uSplitTopPlane.x * worldcoord.x + uSplitTopPlane.y * worldcoord.z) * uSplitTopPlane.z) - worldcoord.y; diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 2099427d53..c109c8524a 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -15,6 +15,7 @@ uniform float uAlphaThreshold; // colors uniform vec4 uObjectColor; +uniform vec4 uObjectColor2; uniform vec4 uDynLightColor; uniform vec4 uFogColor; uniform float uDesaturationFactor;