From 8382883d3db39651901d63f2da3157493eb77cfc Mon Sep 17 00:00:00 2001 From: slipher Date: Mon, 4 May 2026 21:45:57 -0500 Subject: [PATCH 1/2] Move `alphaGen portal` support to "generic" shader For alphaGen portal, a "portal" shader was used, which was like the "generic" shader but with most features removed. Instead of that, move alphaGen portal support to the "generic" shader so that it can be combined with other features. This fixes the ancient-remains foliage which uses alphaGen portal to fade out when the camera is close, but also needs alpha testing which was not supported in the "portal" shader. (Also it's vertex-lit so it should use overbright.) I added back the capability for the "generic" shader to do vertex lighting, but the implementation is simpler than before. --- src/engine/renderer/Material.cpp | 22 +++++++++-- src/engine/renderer/Material.h | 1 + src/engine/renderer/gl_shader.cpp | 6 +++ src/engine/renderer/gl_shader.h | 38 ++++++++++++++++++- src/engine/renderer/glsl_source/common.glsl | 3 +- .../renderer/glsl_source/generic_fp.glsl | 15 ++++++++ src/engine/renderer/tr_shade.cpp | 15 +++++++- src/engine/renderer/tr_shader.cpp | 11 ++++-- 8 files changed, 101 insertions(+), 10 deletions(-) diff --git a/src/engine/renderer/Material.cpp b/src/engine/renderer/Material.cpp index c4aab70bb6..4bb2911bd9 100644 --- a/src/engine/renderer/Material.cpp +++ b/src/engine/renderer/Material.cpp @@ -142,7 +142,7 @@ void UpdateSurfaceDataNOP( uint32_t*, shaderStage_t*, bool, bool ) { } void UpdateSurfaceDataGeneric3D( uint32_t* materials, shaderStage_t* pStage, bool, bool ) { - // shader_t* shader = pStage->shader; + shader_t* shader = pStage->shader; materials += pStage->bufferOffset; @@ -154,11 +154,13 @@ void UpdateSurfaceDataGeneric3D( uint32_t* materials, shaderStage_t* pStage, boo alphaGen_t alphaGen = SetAlphaGen( pStage ); const bool styleLightMap = pStage->type == stageType_t::ST_STYLELIGHTMAP || pStage->type == stageType_t::ST_STYLECOLORMAP; - gl_genericShaderMaterial->SetUniform_ColorModulateColorGen_Uint( rgbGen, alphaGen, styleLightMap ); + gl_genericShaderMaterial->SetUniform_ColorModulateColorGen_Uint( rgbGen, alphaGen, styleLightMap || pStage->forceVertexLighting ); Tess_ComputeColor( pStage ); gl_genericShaderMaterial->SetUniform_Color_Uint( tess.svars.color ); + gl_genericShaderMaterial->SetUniform_InversePortalRange( 1.0f / shader->portalRange ); + gl_genericShaderMaterial->SetUniform_DepthScale( pStage->depthFadeValue ); gl_genericShaderMaterial->WriteUniformsToBuffer( materials, GLShader::MATERIAL ); @@ -879,6 +881,7 @@ void BindShaderGeneric3D( Material* material ) { // Select shader permutation. gl_genericShaderMaterial->SetTCGenEnvironment( material->tcGenEnvironment ); gl_genericShaderMaterial->SetTCGenLightmap( material->tcGen_Lightmap ); + gl_genericShaderMaterial->SetAlphaGenPortal( material->alphaGenPortal ); gl_genericShaderMaterial->SetDepthFade( material->hasDepthFade ); gl_genericShaderMaterial->SetDeform( material->deformIndex ); @@ -892,6 +895,14 @@ void BindShaderGeneric3D( Material* material ) { gl_genericShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix ); gl_genericShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] ); + { + matrix_t unprojectMatrix; + MatrixCopy( backEnd.viewParms.projectionMatrix, unprojectMatrix ); + MatrixInverse( unprojectMatrix ); + MatrixMultiplyTranslation( unprojectMatrix, -1.0f, -1.0f, -1.0f ); + MatrixMultiplyScale( unprojectMatrix, 2.0f / windowConfig.vidWidth, 2.0f / windowConfig.vidHeight, 2.0f ); + gl_genericShaderMaterial->SetUniform_UnprojectMatrix( unprojectMatrix ); + } gl_genericShaderMaterial->SetUniform_DepthMapBindless( GL_BindToTMU( 1, tr.depthSamplerImage ) ); @@ -1097,6 +1108,10 @@ void ProcessMaterialGeneric3D( Material* material, shaderStage_t* pStage, Materi gl_genericShaderMaterial->SetTCGenEnvironment( pStage->tcGen_Environment ); gl_genericShaderMaterial->SetTCGenLightmap( pStage->tcGen_Lightmap ); + bool alphaGenPortal = pStage->alphaGen == alphaGen_t::AGEN_PORTAL; + material->alphaGenPortal = alphaGenPortal; + gl_genericShaderMaterial->SetAlphaGenPortal( alphaGenPortal ); + bool hasDepthFade = pStage->hasDepthFade; material->hasDepthFade = hasDepthFade; gl_genericShaderMaterial->SetDepthFade( hasDepthFade ); @@ -1299,7 +1314,8 @@ void MaterialSystem::AddStage( MaterialSurface* surface, shaderStage_t* pStage, } if ( pStage->shader->reliefDepthScale != pStage2->shader->reliefDepthScale - || pStage->shader->reliefOffsetBias != pStage2->shader->reliefOffsetBias ) + || pStage->shader->reliefOffsetBias != pStage2->shader->reliefOffsetBias + || pStage->shader->portalRange != pStage2->shader->portalRange ) { continue; } diff --git a/src/engine/renderer/Material.h b/src/engine/renderer/Material.h index edb3b5f2b6..a7857a2bd2 100644 --- a/src/engine/renderer/Material.h +++ b/src/engine/renderer/Material.h @@ -129,6 +129,7 @@ struct Material { int deformIndex; bool tcGenEnvironment; bool tcGen_Lightmap; + bool alphaGenPortal; bool hasDepthFade; bool bspSurface; diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp index 64b942fae8..06cfe6fa94 100644 --- a/src/engine/renderer/gl_shader.cpp +++ b/src/engine/renderer/gl_shader.cpp @@ -2446,12 +2446,14 @@ GLShader_generic::GLShader_generic() : u_AlphaThreshold( this ), u_ModelMatrix( this ), u_ModelViewProjectionMatrix( this ), + u_UnprojectMatrix( this ), u_ColorModulateColorGen_Float( this ), u_ColorModulateColorGen_Uint( this ), u_Color_Float( this ), u_Color_Uint( this ), u_Bones( this ), u_VertexInterpolation( this ), + u_InversePortalRange( this ), u_DepthScale( this ), u_ProfilerZero( this ), u_ProfilerRenderSubGroups( this ), @@ -2460,6 +2462,7 @@ GLShader_generic::GLShader_generic() : GLCompileMacro_USE_VERTEX_ANIMATION( this ), GLCompileMacro_USE_TCGEN_ENVIRONMENT( this ), GLCompileMacro_USE_TCGEN_LIGHTMAP( this ), + GLCompileMacro_USE_ALPHAGEN_PORTAL( this ), GLCompileMacro_USE_DEPTH_FADE( this ) { } @@ -2480,8 +2483,10 @@ GLShader_genericMaterial::GLShader_genericMaterial() : u_AlphaThreshold( this ), u_ModelMatrix( this ), u_ModelViewProjectionMatrix( this ), + u_UnprojectMatrix( this ), u_ColorModulateColorGen_Uint( this ), u_Color_Uint( this ), + u_InversePortalRange( this ), u_DepthScale( this ), u_ShowTris( this ), u_MaterialColour( this ), @@ -2490,6 +2495,7 @@ GLShader_genericMaterial::GLShader_genericMaterial() : GLDeformStage( this ), GLCompileMacro_USE_TCGEN_ENVIRONMENT( this ), GLCompileMacro_USE_TCGEN_LIGHTMAP( this ), + GLCompileMacro_USE_ALPHAGEN_PORTAL( this ), GLCompileMacro_USE_DEPTH_FADE( this ) { } diff --git a/src/engine/renderer/gl_shader.h b/src/engine/renderer/gl_shader.h index a325dc9935..82e2ed02d8 100644 --- a/src/engine/renderer/gl_shader.h +++ b/src/engine/renderer/gl_shader.h @@ -939,6 +939,7 @@ class GLCompileMacro USE_REFLECTIVE_SPECULAR, LIGHT_DIRECTIONAL, USE_DEPTH_FADE, + USE_ALPHAGEN_PORTAL, USE_PHYSICAL_MAPPING, }; @@ -1425,6 +1426,35 @@ class GLCompileMacro_USE_DEPTH_FADE : } }; +class GLCompileMacro_USE_ALPHAGEN_PORTAL : + GLCompileMacro +{ +public: + GLCompileMacro_USE_ALPHAGEN_PORTAL( GLShader *shader ) : + GLCompileMacro( shader ) + { + } + + const char *GetName() const override + { + return "USE_ALPHAGEN_PORTAL"; + } + + EGLCompileMacro GetType() const override + { + return EGLCompileMacro::USE_ALPHAGEN_PORTAL; + } + + int GetShaderTypes() const override { + return ShaderType::FRAGMENT; + } + + void SetAlphaGenPortal( bool enable ) + { + SetMacro( enable ); + } +}; + class GLCompileMacro_USE_PHYSICAL_MAPPING : GLCompileMacro { @@ -2401,7 +2431,7 @@ class u_InversePortalRange : { public: u_InversePortalRange( GLShader *shader ) : - GLUniform1f( shader, "u_InversePortalRange", PUSH ) + GLUniform1f( shader, "u_InversePortalRange", MATERIAL_OR_PUSH ) { } @@ -2939,12 +2969,14 @@ class GLShader_generic : public u_AlphaThreshold, public u_ModelMatrix, public u_ModelViewProjectionMatrix, + public u_UnprojectMatrix, public u_ColorModulateColorGen_Float, public u_ColorModulateColorGen_Uint, public u_Color_Float, public u_Color_Uint, public u_Bones, public u_VertexInterpolation, + public u_InversePortalRange, public u_DepthScale, public u_ProfilerZero, public u_ProfilerRenderSubGroups, @@ -2953,6 +2985,7 @@ class GLShader_generic : public GLCompileMacro_USE_VERTEX_ANIMATION, public GLCompileMacro_USE_TCGEN_ENVIRONMENT, public GLCompileMacro_USE_TCGEN_LIGHTMAP, + public GLCompileMacro_USE_ALPHAGEN_PORTAL, public GLCompileMacro_USE_DEPTH_FADE { public: @@ -2969,8 +3002,10 @@ class GLShader_genericMaterial : public u_AlphaThreshold, public u_ModelMatrix, public u_ModelViewProjectionMatrix, + public u_UnprojectMatrix, public u_ColorModulateColorGen_Uint, public u_Color_Uint, + public u_InversePortalRange, public u_DepthScale, public u_ShowTris, public u_MaterialColour, @@ -2979,6 +3014,7 @@ class GLShader_genericMaterial : public GLDeformStage, public GLCompileMacro_USE_TCGEN_ENVIRONMENT, public GLCompileMacro_USE_TCGEN_LIGHTMAP, + public GLCompileMacro_USE_ALPHAGEN_PORTAL, public GLCompileMacro_USE_DEPTH_FADE { public: GLShader_genericMaterial(); diff --git a/src/engine/renderer/glsl_source/common.glsl b/src/engine/renderer/glsl_source/common.glsl index 141f632261..c2e3ec2456 100644 --- a/src/engine/renderer/glsl_source/common.glsl +++ b/src/engine/renderer/glsl_source/common.glsl @@ -135,7 +135,6 @@ void ColorModulateColor_lightFactor( vec4 unpackedColor = UnpackColor( packedColor ); - unpackedColor.rgb *= lightFactor; - ModulateColor( colorModulation, unpackedColor, color ); + color.rgb *= lightFactor; } diff --git a/src/engine/renderer/glsl_source/generic_fp.glsl b/src/engine/renderer/glsl_source/generic_fp.glsl index 77f0e0ea57..82c6052c92 100644 --- a/src/engine/renderer/glsl_source/generic_fp.glsl +++ b/src/engine/renderer/glsl_source/generic_fp.glsl @@ -42,6 +42,11 @@ IN(smooth) float var_FadeDepth; uniform sampler2D u_DepthMap; #endif +#if defined(USE_ALPHAGEN_PORTAL) +uniform float u_InversePortalRange; +uniform mat4 u_UnprojectMatrix; +#endif + #insert shaderProfiler_fp DECLARE_OUTPUT(vec4) @@ -67,6 +72,16 @@ void main() return; } + // Normally alpha modulation is supposed to be done before the alpha test, but this looks + // better for the ancient-remains foliage combining alphagen portal with an alpha-tested + // plant image: fades out to 0 smoothly instead of cutting off at 0.5. +#if defined(USE_ALPHAGEN_PORTAL) + vec4 position = u_UnprojectMatrix * vec4(gl_FragCoord.xyz, 1.0); + float portalAlpha = length(position.xyz / position.w) * u_InversePortalRange; +portalAlpha = length(position.xyz / position.w) * (1.0/256.0); + color.a *= clamp(portalAlpha, 0.0, 1.0); +#endif + #if defined(USE_DEPTH_FADE) float depth = texture2D(u_DepthMap, gl_FragCoord.xy / r_FBufSize).x; diff --git a/src/engine/renderer/tr_shade.cpp b/src/engine/renderer/tr_shade.cpp index 239a92932d..69a663e500 100644 --- a/src/engine/renderer/tr_shade.cpp +++ b/src/engine/renderer/tr_shade.cpp @@ -814,6 +814,7 @@ void ProcessShaderGeneric3D( const shaderStage_t* pStage ) { gl_genericShader->SetDeform( pStage->deformIndex ); gl_genericShader->SetTCGenEnvironment( pStage->tcGen_Environment ); gl_genericShader->SetTCGenLightmap( pStage->tcGen_Lightmap ); + gl_genericShader->SetAlphaGenPortal( pStage->alphaGen == alphaGen_t::AGEN_PORTAL ); gl_genericShader->SetDepthFade( pStage->hasDepthFade ); } @@ -926,7 +927,7 @@ void Render_generic3D( shaderStage_t *pStage ) alphaGen_t alphaGen = SetAlphaGen( pStage ); const bool styleLightMap = pStage->type == stageType_t::ST_STYLELIGHTMAP || pStage->type == stageType_t::ST_STYLECOLORMAP; - SetUniform_ColorModulateColorGen( gl_genericShader, rgbGen, alphaGen, styleLightMap ); + SetUniform_ColorModulateColorGen( gl_genericShader, rgbGen, alphaGen, styleLightMap || pStage->forceVertexLighting ); // u_Color SetUniform_Color( gl_genericShader, tess.svars.color ); @@ -963,6 +964,18 @@ void Render_generic3D( shaderStage_t *pStage ) gl_genericShader->SetUniform_TextureMatrix( tess.svars.texMatrices[ TB_COLORMAP ] ); + if ( pStage->alphaGen == alphaGen_t::AGEN_PORTAL ) + { + matrix_t unprojectMatrix; + MatrixCopy( backEnd.viewParms.projectionMatrix, unprojectMatrix ); + MatrixInverse( unprojectMatrix ); + MatrixMultiplyTranslation( unprojectMatrix, -1.0f, -1.0f, -1.0f ); + MatrixMultiplyScale( unprojectMatrix, 2.0f / windowConfig.vidWidth, 2.0f / windowConfig.vidHeight, 2.0f ); + + gl_genericShader->SetUniform_InversePortalRange( 1.0f / tess.surfaceShader->portalRange ); + gl_genericShader->SetUniform_UnprojectMatrix( unprojectMatrix ); + } + if ( hasDepthFade ) { gl_genericShader->SetUniform_DepthScale( pStage->depthFadeValue ); diff --git a/src/engine/renderer/tr_shader.cpp b/src/engine/renderer/tr_shader.cpp index bffc8d2f72..368ead0aa8 100644 --- a/src/engine/renderer/tr_shader.cpp +++ b/src/engine/renderer/tr_shader.cpp @@ -2938,7 +2938,6 @@ static bool ParseStage( shaderStage_t *stage, const char **text ) } else if ( !Q_stricmp( token, "portal" ) ) { - stage->type = stageType_t::ST_PORTALMAP; stage->alphaGen = alphaGen_t::AGEN_PORTAL; token = COM_ParseExt2( text, false ); @@ -5441,9 +5440,15 @@ static void FinishStages() case stageType_t::ST_COLORMAP: if ( stage->rgbGen == colorGen_t::CGEN_VERTEX && shader.registerFlags & RSF_BSP ) { - // vertex colors used as lighting detected. Enable overbright and realtime lights - stage->type = stageType_t::ST_DIFFUSEMAP; + // Vertex colors used as lighting detected. Enable overbright + stage->forceVertexLighting = true; // use vertex lighting even if there is a lightmap + + if ( stage->alphaGen != alphaGen_t::AGEN_PORTAL ) // AGEN_PORTAL not supported in lightMapping + { + // use lightMapping shader to get realtime lights + stage->type = stageType_t::ST_DIFFUSEMAP; + } } default: From 999841a0e5977ca55607eed69c8d7fc94ddceb7d Mon Sep 17 00:00:00 2001 From: slipher Date: Mon, 4 May 2026 21:58:16 -0500 Subject: [PATCH 2/2] NUKE now-unused ST_PORTALMAP stage --- src.cmake | 2 - src/engine/renderer/GeometryOptimiser.cpp | 4 -- src/engine/renderer/GeometryOptimiser.h | 1 - src/engine/renderer/gl_shader.cpp | 16 ------ src/engine/renderer/gl_shader.h | 13 ----- .../renderer/glsl_source/portal_fp.glsl | 45 ----------------- .../renderer/glsl_source/portal_vp.glsl | 50 ------------------- src/engine/renderer/tr_local.h | 2 - src/engine/renderer/tr_shade.cpp | 35 ------------- src/engine/renderer/tr_shader.cpp | 13 ----- 10 files changed, 181 deletions(-) delete mode 100644 src/engine/renderer/glsl_source/portal_fp.glsl delete mode 100644 src/engine/renderer/glsl_source/portal_vp.glsl diff --git a/src.cmake b/src.cmake index bd5e8b47e0..2265b4fc97 100644 --- a/src.cmake +++ b/src.cmake @@ -139,8 +139,6 @@ set(GLSL_EMBED_LIST lightMapping_fp.glsl liquid_vp.glsl liquid_fp.glsl - portal_vp.glsl - portal_fp.glsl reflection_CB_vp.glsl reflection_CB_fp.glsl screen_vp.glsl diff --git a/src/engine/renderer/GeometryOptimiser.cpp b/src/engine/renderer/GeometryOptimiser.cpp index b151ddd988..1a3929a364 100644 --- a/src/engine/renderer/GeometryOptimiser.cpp +++ b/src/engine/renderer/GeometryOptimiser.cpp @@ -100,10 +100,6 @@ void MarkShaderBuildScreen( const shaderStage_t* ) { gl_screenShader->MarkProgramForBuilding(); } -void MarkShaderBuildPortal( const shaderStage_t* ) { - gl_portalShader->MarkProgramForBuilding(); -} - void MarkShaderBuildHeatHaze( const shaderStage_t* pStage ) { ProcessShaderHeatHaze( pStage ); gl_heatHazeShader->MarkProgramForBuilding(); diff --git a/src/engine/renderer/GeometryOptimiser.h b/src/engine/renderer/GeometryOptimiser.h index cfce0db7e1..eea4166b42 100644 --- a/src/engine/renderer/GeometryOptimiser.h +++ b/src/engine/renderer/GeometryOptimiser.h @@ -84,7 +84,6 @@ void MarkShaderBuildLightMapping( const shaderStage_t* pStage ); void MarkShaderBuildReflection( const shaderStage_t* pStage ); void MarkShaderBuildSkybox( const shaderStage_t* pStage ); void MarkShaderBuildScreen( const shaderStage_t* pStage ); -void MarkShaderBuildPortal( const shaderStage_t* pStage ); void MarkShaderBuildHeatHaze( const shaderStage_t* pStage ); void MarkShaderBuildLiquid( const shaderStage_t* pStage ); diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp index 06cfe6fa94..0b20d932bb 100644 --- a/src/engine/renderer/gl_shader.cpp +++ b/src/engine/renderer/gl_shader.cpp @@ -72,7 +72,6 @@ GLShader_heatHaze *gl_heatHazeShader = nullptr; GLShader_heatHazeMaterial *gl_heatHazeShaderMaterial = nullptr; GLShader_liquid *gl_liquidShader = nullptr; GLShader_liquidMaterial *gl_liquidShaderMaterial = nullptr; -GLShader_portal *gl_portalShader = nullptr; GLShader_reflection *gl_reflectionShader = nullptr; GLShader_reflectionMaterial *gl_reflectionShaderMaterial = nullptr; GLShader_screen *gl_screenShader = nullptr; @@ -2775,21 +2774,6 @@ GLShader_screenMaterial::GLShader_screenMaterial() : u_ModelViewProjectionMatrix( this ) { } -GLShader_portal::GLShader_portal() : - GLShader( "portal", ATTR_POSITION, - false, "portal", "portal" ), - u_CurrentMap( this ), - u_ModelViewMatrix( this ), - u_ModelViewProjectionMatrix( this ), - u_InversePortalRange( this ) -{ -} - -void GLShader_portal::SetShaderProgramUniforms( ShaderProgramDescriptor *shaderProgram ) -{ - glUniform1i( glGetUniformLocation( shaderProgram->id, "u_CurrentMap" ), 0 ); -} - GLShader_contrast::GLShader_contrast() : GLShader( "contrast", ATTR_POSITION, false, "screenSpace", "contrast" ), diff --git a/src/engine/renderer/gl_shader.h b/src/engine/renderer/gl_shader.h index 82e2ed02d8..dbd3a55a06 100644 --- a/src/engine/renderer/gl_shader.h +++ b/src/engine/renderer/gl_shader.h @@ -3268,18 +3268,6 @@ class GLShader_screenMaterial : GLShader_screenMaterial(); }; -class GLShader_portal : - public GLShader, - public u_CurrentMap, - public u_ModelViewMatrix, - public u_ModelViewProjectionMatrix, - public u_InversePortalRange -{ -public: - GLShader_portal(); - void SetShaderProgramUniforms( ShaderProgramDescriptor *shaderProgram ) override; -}; - class GLShader_contrast : public GLShader, public u_ColorMap { @@ -3563,7 +3551,6 @@ extern GLShader_heatHaze *gl_heatHazeShader; extern GLShader_heatHazeMaterial *gl_heatHazeShaderMaterial; extern GLShader_liquid *gl_liquidShader; extern GLShader_liquidMaterial *gl_liquidShaderMaterial; -extern GLShader_portal *gl_portalShader; extern GLShader_reflection *gl_reflectionShader; extern GLShader_reflectionMaterial *gl_reflectionShaderMaterial; extern GLShader_screen *gl_screenShader; diff --git a/src/engine/renderer/glsl_source/portal_fp.glsl b/src/engine/renderer/glsl_source/portal_fp.glsl deleted file mode 100644 index e33c9fde1d..0000000000 --- a/src/engine/renderer/glsl_source/portal_fp.glsl +++ /dev/null @@ -1,45 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2008 Robert Beckebans - -This file is part of XreaL source code. - -XreaL source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -XreaL source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with XreaL source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -/* portal_fp.glsl */ - -uniform sampler2D u_CurrentMap; -uniform float u_InversePortalRange; - -IN(smooth) vec3 var_Position; -IN(smooth) vec4 var_Color; -IN(smooth) vec2 var_TexCoords; - -DECLARE_OUTPUT(vec4) - -void main() -{ - vec4 color = texture2D(u_CurrentMap, var_TexCoords); - color *= var_Color; - - float len = length(var_Position); - - len *= u_InversePortalRange; - color.a = clamp(len, 0.0, 1.0); - - outputColor = color; -} diff --git a/src/engine/renderer/glsl_source/portal_vp.glsl b/src/engine/renderer/glsl_source/portal_vp.glsl deleted file mode 100644 index d006be3c30..0000000000 --- a/src/engine/renderer/glsl_source/portal_vp.glsl +++ /dev/null @@ -1,50 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2008 Robert Beckebans - -This file is part of XreaL source code. - -XreaL source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -XreaL source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with XreaL source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -/* portal_vp.glsl */ - -IN vec3 attr_Position; -IN vec4 attr_Color; -IN vec4 attr_TexCoord0; - -uniform mat4 u_ModelViewMatrix; -uniform mat4 u_ModelViewProjectionMatrix; - -OUT(smooth) vec3 var_Position; -OUT(smooth) vec4 var_Color; -OUT(smooth) vec2 var_TexCoords; - -void main() -{ - vec2 texCoord = attr_TexCoord0.xy; - - // transform vertex position into homogenous clip-space - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - - // transform vertex position into camera space - var_Position = (u_ModelViewMatrix * vec4(attr_Position, 1.0)).xyz; - - // assign color - var_Color = attr_Color; - - var_TexCoords = texCoord; -} diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h index 9d58e99b3d..557e9c85b5 100644 --- a/src/engine/renderer/tr_local.h +++ b/src/engine/renderer/tr_local.h @@ -938,7 +938,6 @@ enum ST_REFLECTIONMAP, // cubeMap based reflection ST_SKYBOXMAP, ST_SCREENMAP, // 2d offscreen or portal rendering - ST_PORTALMAP, ST_HEATHAZEMAP, // heatHaze post process effect ST_LIQUIDMAP, ST_FOGMAP_INNER, // a fog seen from inside @@ -3249,7 +3248,6 @@ void GLimp_LogComment_( std::string comment ); void Render_reflection_CB( shaderStage_t *pStage ); void Render_skybox( shaderStage_t *pStage ); void Render_screen( shaderStage_t *pStage ); - void Render_portal( shaderStage_t *pStage ); void Render_heatHaze( shaderStage_t *pStage ); void Render_liquid( shaderStage_t *pStage ); void Render_fog( shaderStage_t *pStage ); diff --git a/src/engine/renderer/tr_shade.cpp b/src/engine/renderer/tr_shade.cpp index 69a663e500..ad140f2f19 100644 --- a/src/engine/renderer/tr_shade.cpp +++ b/src/engine/renderer/tr_shade.cpp @@ -343,11 +343,6 @@ static void GLSL_InitGPUShadersOrError() gl_contrastShader->MarkProgramForBuilding(); } - // portal process effect - gl_shaderManager.LoadShader( gl_portalShader ); - - gl_portalShader->MarkProgramForBuilding(); - // camera post process effect gl_shaderManager.LoadShader( gl_cameraEffectsShader ); @@ -509,7 +504,6 @@ void GLSL_ShutdownGPUShaders() gl_heatHazeShaderMaterial = nullptr; gl_screenShader = nullptr; gl_screenShaderMaterial = nullptr; - gl_portalShader = nullptr; gl_contrastShader = nullptr; gl_cameraEffectsShader = nullptr; gl_blurShader = nullptr; @@ -1411,35 +1405,6 @@ void Render_screen( shaderStage_t *pStage ) GL_CheckErrors(); } -/* This doesn't render the portal itself but the texture -blended to it to fade it with distance. */ -void Render_portal( shaderStage_t *pStage ) -{ - GLIMP_LOGCOMMENT( "--- Render_portal ---" ); - - GL_State( pStage->stateBits ); - - // enable shader, set arrays - gl_portalShader->BindProgram(); - - { - GL_VertexAttribsState( ATTR_POSITION | ATTR_TEXCOORD ); - glVertexAttrib4fv( ATTR_INDEX_COLOR, tess.svars.color.ToArray() ); - } - - gl_portalShader->SetUniform_InversePortalRange( 1 / tess.surfaceShader->portalRange ); - - gl_portalShader->SetUniform_ModelViewMatrix( glState.modelViewMatrix[ glState.stackIndex ] ); - gl_portalShader->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[ glState.stackIndex ] ); - - // bind u_CurrentMap - gl_portalShader->SetUniform_CurrentMapBindless( BindAnimatedImage( 0, &pStage->bundle[TB_COLORMAP] ) ); - - Tess_DrawElements(); - - GL_CheckErrors(); -} - void Render_heatHaze( shaderStage_t *pStage ) { float deformMagnitude; diff --git a/src/engine/renderer/tr_shader.cpp b/src/engine/renderer/tr_shader.cpp index 368ead0aa8..fbbdeb9ad0 100644 --- a/src/engine/renderer/tr_shader.cpp +++ b/src/engine/renderer/tr_shader.cpp @@ -2748,10 +2748,6 @@ static bool ParseStage( shaderStage_t *stage, const char **text ) { stage->type = stageType_t::ST_SCREENMAP; } - else if ( !Q_stricmp( token, "portalMap" ) ) - { - stage->type = stageType_t::ST_PORTALMAP; - } else if ( !Q_stricmp( token, "heathazeMap" ) ) { stage->type = stageType_t::ST_HEATHAZEMAP; @@ -5652,14 +5648,6 @@ static void SetStagesRenderers() &UpdateSurfaceDataScreen, &BindShaderScreen, &ProcessMaterialScreen, }; break; - case stageType_t::ST_PORTALMAP: - /* Comment from the Material code: - This is supposedly used for alphagen portal and portal surfaces should never get here. */ - stageRendererOptions = { - &Render_portal, &MarkShaderBuildPortal, - &UpdateSurfaceDataNONE, &BindShaderNONE, &ProcessMaterialNONE, - }; - break; case stageType_t::ST_HEATHAZEMAP: stageRendererOptions = { &Render_heatHaze, &MarkShaderBuildHeatHaze, @@ -6596,7 +6584,6 @@ class ListShadersCmd : public Cmd::StaticCmd { stageType_t::ST_REFLECTIONMAP, "REFLECTIONMAP" }, { stageType_t::ST_SKYBOXMAP, "SKYBOXMAP" }, { stageType_t::ST_SCREENMAP, "SCREENMAP" }, - { stageType_t::ST_PORTALMAP, "PORTALMAP" }, { stageType_t::ST_HEATHAZEMAP, "HEATHAZEMAP" }, { stageType_t::ST_LIQUIDMAP, "LIQUIDMAP" }, { stageType_t::ST_LIGHTMAP, "LIGHTMAP" },