@@ -142,7 +142,7 @@ void UpdateSurfaceDataNOP( uint32_t*, shaderStage_t*, bool, bool ) {
142142}
143143
144144void UpdateSurfaceDataGeneric3D ( uint32_t * materials, shaderStage_t* pStage, bool , bool ) {
145- // shader_t* shader = pStage->shader;
145+ shader_t * shader = pStage->shader ;
146146
147147 materials += pStage->bufferOffset ;
148148
@@ -154,11 +154,13 @@ void UpdateSurfaceDataGeneric3D( uint32_t* materials, shaderStage_t* pStage, boo
154154 alphaGen_t alphaGen = SetAlphaGen ( pStage );
155155
156156 const bool styleLightMap = pStage->type == stageType_t::ST_STYLELIGHTMAP || pStage->type == stageType_t::ST_STYLECOLORMAP;
157- gl_genericShaderMaterial->SetUniform_ColorModulateColorGen_Uint ( rgbGen, alphaGen, styleLightMap );
157+ gl_genericShaderMaterial->SetUniform_ColorModulateColorGen_Uint ( rgbGen, alphaGen, styleLightMap || pStage-> forceVertexLighting );
158158
159159 Tess_ComputeColor ( pStage );
160160 gl_genericShaderMaterial->SetUniform_Color_Uint ( tess.svars .color );
161161
162+ gl_genericShaderMaterial->SetUniform_InversePortalRange ( 1 .0f / shader->portalRange );
163+
162164 gl_genericShaderMaterial->SetUniform_DepthScale ( pStage->depthFadeValue );
163165
164166 gl_genericShaderMaterial->WriteUniformsToBuffer ( materials, GLShader::MATERIAL );
@@ -879,6 +881,7 @@ void BindShaderGeneric3D( Material* material ) {
879881 // Select shader permutation.
880882 gl_genericShaderMaterial->SetTCGenEnvironment ( material->tcGenEnvironment );
881883 gl_genericShaderMaterial->SetTCGenLightmap ( material->tcGen_Lightmap );
884+ gl_genericShaderMaterial->SetAlphaGenPortal ( material->alphaGenPortal );
882885 gl_genericShaderMaterial->SetDepthFade ( material->hasDepthFade );
883886 gl_genericShaderMaterial->SetDeform ( material->deformIndex );
884887
@@ -892,6 +895,14 @@ void BindShaderGeneric3D( Material* material ) {
892895
893896 gl_genericShaderMaterial->SetUniform_ModelMatrix ( backEnd.orientation .transformMatrix );
894897 gl_genericShaderMaterial->SetUniform_ModelViewProjectionMatrix ( glState.modelViewProjectionMatrix [glState.stackIndex ] );
898+ {
899+ matrix_t unprojectMatrix;
900+ MatrixCopy ( backEnd.viewParms .projectionMatrix , unprojectMatrix );
901+ MatrixInverse ( unprojectMatrix );
902+ MatrixMultiplyTranslation ( unprojectMatrix, -1 .0f , -1 .0f , -1 .0f );
903+ MatrixMultiplyScale ( unprojectMatrix, 2 .0f / windowConfig.vidWidth , 2 .0f / windowConfig.vidHeight , 2 .0f );
904+ gl_genericShaderMaterial->SetUniform_UnprojectMatrix ( unprojectMatrix );
905+ }
895906
896907 gl_genericShaderMaterial->SetUniform_DepthMapBindless ( GL_BindToTMU ( 1 , tr.depthSamplerImage ) );
897908
@@ -1097,6 +1108,10 @@ void ProcessMaterialGeneric3D( Material* material, shaderStage_t* pStage, Materi
10971108 gl_genericShaderMaterial->SetTCGenEnvironment ( pStage->tcGen_Environment );
10981109 gl_genericShaderMaterial->SetTCGenLightmap ( pStage->tcGen_Lightmap );
10991110
1111+ bool alphaGenPortal = pStage->alphaGen == alphaGen_t::AGEN_PORTAL;
1112+ material->alphaGenPortal = alphaGenPortal;
1113+ gl_genericShaderMaterial->SetAlphaGenPortal ( alphaGenPortal );
1114+
11001115 bool hasDepthFade = pStage->hasDepthFade ;
11011116 material->hasDepthFade = hasDepthFade;
11021117 gl_genericShaderMaterial->SetDepthFade ( hasDepthFade );
@@ -1299,7 +1314,8 @@ void MaterialSystem::AddStage( MaterialSurface* surface, shaderStage_t* pStage,
12991314 }
13001315
13011316 if ( pStage->shader ->reliefDepthScale != pStage2->shader ->reliefDepthScale
1302- || pStage->shader ->reliefOffsetBias != pStage2->shader ->reliefOffsetBias )
1317+ || pStage->shader ->reliefOffsetBias != pStage2->shader ->reliefOffsetBias
1318+ || pStage->shader ->portalRange != pStage2->shader ->portalRange )
13031319 {
13041320 continue ;
13051321 }
0 commit comments