diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index e0f5406ddb..b30d7920f1 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -177,6 +177,11 @@ public: mTextureMode = mode; } + int GetTextureMode() + { + return mTextureMode; + } + void EnableTexture(bool on) { mTextureEnabled = on; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 1644c66055..801bebcc5e 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -338,10 +338,18 @@ void GLWall::RenderTranslucentWall() gl_RenderState.EnableTexture(false); extra = 0; } + int tmode = gl_RenderState.GetTextureMode(); gl_SetColor(lightlevel, extra, Colormap, fabsf(alpha)); if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, extra, &Colormap, isadditive); - else gl_SetFog(255, 0, NULL, false); + else + { + if (flags & GLT_CLAMPY) + { + if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); + } + gl_SetFog(255, 0, NULL, false); + } RenderWall(RWF_TEXTURED|RWF_NOSPLIT); @@ -353,6 +361,7 @@ void GLWall::RenderTranslucentWall() gl_RenderState.EnableTexture(true); } gl_RenderState.EnableGlow(false); + gl_RenderState.SetTextureMode(tmode); } //========================================================================== @@ -363,6 +372,7 @@ void GLWall::RenderTranslucentWall() void GLWall::Draw(int pass) { int rel; + int tmode; #ifdef _DEBUG if (seg->linedef-lines==879) @@ -384,13 +394,21 @@ void GLWall::Draw(int pass) case GLPASS_PLAIN: rel = rellight + getExtraLight(); gl_SetColor(lightlevel, rel, Colormap,1.0f); + tmode = gl_RenderState.GetTextureMode(); if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, false); - else gl_SetFog(255, 0, NULL, false); - + else + { + if (flags & GLT_CLAMPY) + { + if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); + } + gl_SetFog(255, 0, NULL, false); + } gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); gl_RenderState.SetMaterial(gltexture, flags & 3, false, -1, false); RenderWall(RWF_TEXTURED|RWF_GLOW); gl_RenderState.EnableGlow(false); + gl_RenderState.SetTextureMode(tmode); break; case GLPASS_TRANSLUCENT: diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 2d2e26d514..6f2fb2bfce 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -20,6 +20,7 @@ enum TexMode TM_OPAQUE, // (r, g, b, 1) TM_INVERSE, // (1-r, 1-g, 1-b, a) TM_REDTOALPHA, // (1, 1, 1, r) + TM_CLAMPY, // (r, g, b, (t >= 0.0 && t <= 1.0)? a:0) }; struct RenderContext diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 6fa304f928..e7421106b5 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -75,6 +75,13 @@ vec4 getTexel(vec2 st) case 4: // TM_REDTOALPHA texel = vec4(1.0, 1.0, 1.0, texel.r); break; + + case 5: // TM_CLAMPY + if (st.t < 0.0 || st.t > 1.0) + { + texel.a = 0.0; + } + break; } texel *= uObjectColor;