@@ -132,14 +132,14 @@ static void ComputeDynamics( shaderStage_t* pStage ) {
132132// UpdateSurface*() functions will actually write the uniform values to the SSBO
133133// Mirrors parts of the Render_*() functions in tr_shade.cpp
134134
135- void UpdateSurfaceDataNONE ( uint32_t *, shaderStage_t* ) {
135+ void UpdateSurfaceDataNONE ( uint32_t *, shaderStage_t*, bool , bool , bool ) {
136136 ASSERT_UNREACHABLE ();
137137}
138138
139- void UpdateSurfaceDataNOP ( uint32_t *, shaderStage_t* ) {
139+ void UpdateSurfaceDataNOP ( uint32_t *, shaderStage_t*, bool , bool , bool ) {
140140}
141141
142- void UpdateSurfaceDataGeneric3D ( uint32_t * materials, shaderStage_t* pStage ) {
142+ void UpdateSurfaceDataGeneric3D ( uint32_t * materials, shaderStage_t* pStage, bool mayUseVertexOverbright, bool , bool ) {
143143 // shader_t* shader = pStage->shader;
144144
145145 materials += pStage->bufferOffset ;
@@ -151,7 +151,6 @@ void UpdateSurfaceDataGeneric3D( uint32_t* materials, shaderStage_t* pStage ) {
151151 colorGen_t rgbGen = SetRgbGen ( pStage );
152152 alphaGen_t alphaGen = SetAlphaGen ( pStage );
153153
154- bool mayUseVertexOverbright = pStage->mayUseVertexOverbright ;
155154 const bool styleLightMap = pStage->type == stageType_t::ST_STYLELIGHTMAP || pStage->type == stageType_t::ST_STYLECOLORMAP;
156155 gl_genericShaderMaterial->SetUniform_ColorModulateColorGen ( rgbGen, alphaGen, mayUseVertexOverbright, styleLightMap );
157156
@@ -166,7 +165,7 @@ void UpdateSurfaceDataGeneric3D( uint32_t* materials, shaderStage_t* pStage ) {
166165 gl_genericShaderMaterial->WriteUniformsToBuffer ( materials );
167166}
168167
169- void UpdateSurfaceDataLightMapping ( uint32_t * materials, shaderStage_t* pStage ) {
168+ void UpdateSurfaceDataLightMapping ( uint32_t * materials, shaderStage_t* pStage, bool , bool vertexLit, bool fullbright ) {
170169 shader_t * shader = pStage->shader ;
171170
172171 materials += pStage->bufferOffset ;
@@ -178,12 +177,12 @@ void UpdateSurfaceDataLightMapping( uint32_t* materials, shaderStage_t* pStage )
178177 Tess_ComputeColor ( pStage );
179178
180179 // HACK: This only has effect on vertex-lit surfaces
181- if ( pStage-> vertexLit ) {
180+ if ( vertexLit ) {
182181 SetVertexLightingSettings ( lightMode_t::VERTEX, rgbGen );
183182 }
184183
185184 // u_ColorModulate
186- gl_lightMappingShaderMaterial->SetUniform_ColorModulateColorGen ( rgbGen, alphaGen, false , !pStage-> fullbright );
185+ gl_lightMappingShaderMaterial->SetUniform_ColorModulateColorGen ( rgbGen, alphaGen, false , !fullbright );
187186
188187 // u_Color
189188 gl_lightMappingShaderMaterial->SetUniform_Color ( tess.svars .color );
@@ -218,7 +217,7 @@ void UpdateSurfaceDataLightMapping( uint32_t* materials, shaderStage_t* pStage )
218217 gl_lightMappingShaderMaterial->WriteUniformsToBuffer ( materials );
219218}
220219
221- void UpdateSurfaceDataReflection ( uint32_t * materials, shaderStage_t* pStage) {
220+ void UpdateSurfaceDataReflection ( uint32_t * materials, shaderStage_t* pStage, bool , bool , bool ) {
222221 shader_t * shader = pStage->shader ;
223222
224223 materials += pStage->bufferOffset ;
@@ -259,7 +258,7 @@ void UpdateSurfaceDataReflection( uint32_t* materials, shaderStage_t* pStage) {
259258 gl_reflectionShaderMaterial->WriteUniformsToBuffer ( materials );
260259}
261260
262- void UpdateSurfaceDataSkybox ( uint32_t * materials, shaderStage_t* pStage ) {
261+ void UpdateSurfaceDataSkybox ( uint32_t * materials, shaderStage_t* pStage, bool , bool , bool ) {
263262 // shader_t* shader = pStage->shader;
264263
265264 materials += pStage->bufferOffset ;
@@ -270,7 +269,7 @@ void UpdateSurfaceDataSkybox( uint32_t* materials, shaderStage_t* pStage ) {
270269 gl_skyboxShaderMaterial->WriteUniformsToBuffer ( materials );
271270}
272271
273- void UpdateSurfaceDataScreen ( uint32_t * materials, shaderStage_t* pStage) {
272+ void UpdateSurfaceDataScreen ( uint32_t * materials, shaderStage_t* pStage, bool , bool , bool ) {
274273 // shader_t* shader = pStage->shader;
275274
276275 materials += pStage->bufferOffset ;
@@ -283,7 +282,7 @@ void UpdateSurfaceDataScreen( uint32_t* materials, shaderStage_t* pStage) {
283282 gl_screenShaderMaterial->WriteUniformsToBuffer ( materials );
284283}
285284
286- void UpdateSurfaceDataHeatHaze ( uint32_t * materials, shaderStage_t* pStage) {
285+ void UpdateSurfaceDataHeatHaze ( uint32_t * materials, shaderStage_t* pStage, bool , bool , bool ) {
287286 // shader_t* shader = pStage->shader;
288287
289288 materials += pStage->bufferOffset ;
@@ -302,7 +301,7 @@ void UpdateSurfaceDataHeatHaze( uint32_t* materials, shaderStage_t* pStage) {
302301 gl_heatHazeShaderMaterial->WriteUniformsToBuffer ( materials );
303302}
304303
305- void UpdateSurfaceDataLiquid ( uint32_t * materials, shaderStage_t* pStage) {
304+ void UpdateSurfaceDataLiquid ( uint32_t * materials, shaderStage_t* pStage, bool , bool , bool ) {
306305 // shader_t* shader = pStage->shader;
307306
308307 materials += pStage->bufferOffset ;
@@ -354,7 +353,7 @@ void UpdateSurfaceDataLiquid( uint32_t* materials, shaderStage_t* pStage) {
354353 gl_liquidShaderMaterial->WriteUniformsToBuffer ( materials );
355354}
356355
357- void UpdateSurfaceDataFog ( uint32_t * materials, shaderStage_t* pStage ) {
356+ void UpdateSurfaceDataFog ( uint32_t * materials, shaderStage_t* pStage, bool , bool , bool ) {
358357 // shader_t* shader = pStage->shader;
359358
360359 materials += pStage->bufferOffset ;
@@ -489,15 +488,14 @@ void MaterialSystem::GenerateMaterialsBuffer( std::vector<shaderStage_t*>& stage
489488 uint32_t variants = 0 ;
490489 for ( int i = 0 ; i < Util::ordinal ( ShaderStageVariant::ALL ) && variants < pStage->variantOffset ; i++ ) {
491490 if ( pStage->variantOffsets [i] != -1 ) {
492- pStage->mayUseVertexOverbright = i & Util::ordinal ( ShaderStageVariant::VERTEX_OVERBRIGHT );
493- pStage->vertexLit = i & Util::ordinal ( ShaderStageVariant::VERTEX_LIT );
494- pStage->fullbright = i & Util::ordinal ( ShaderStageVariant::FULLBRIGHT );
495- pStage->currentOffset = pStage->variantOffsets [i];
491+ const bool mayUseVertexOverbright = i & Util::ordinal ( ShaderStageVariant::VERTEX_OVERBRIGHT );
492+ const bool vertexLit = i & Util::ordinal ( ShaderStageVariant::VERTEX_LIT );
493+ const bool fullbright = i & Util::ordinal ( ShaderStageVariant::FULLBRIGHT );
496494
497495 const uint32_t variantOffset = pStage->variantOffsets [i] * pStage->paddedSize ;
498496 pStage->bufferOffset += variantOffset;
499497
500- pStage->surfaceDataUpdater ( materialsData, pStage );
498+ pStage->surfaceDataUpdater ( materialsData, pStage, mayUseVertexOverbright, vertexLit, fullbright );
501499
502500 pStage->bufferOffset -= variantOffset;
503501 variants++;
@@ -1244,10 +1242,11 @@ void ProcessMaterialFog( Material* material, shaderStage_t* pStage, drawSurf_t*
12441242 material->program = gl_fogQuake3ShaderMaterial->GetProgram ( pStage->deformIndex );
12451243}
12461244
1247- void MaterialSystem::AddStage ( drawSurf_t* drawSurf, shaderStage_t* pStage, uint32_t stage ) {
1248- const int variant = ( pStage->mayUseVertexOverbright ? Util::ordinal ( ShaderStageVariant::VERTEX_OVERBRIGHT ) : 0 )
1249- | ( pStage->vertexLit ? Util::ordinal ( ShaderStageVariant::VERTEX_LIT ) : 0 )
1250- | ( pStage->fullbright ? Util::ordinal ( ShaderStageVariant::FULLBRIGHT ) : 0 );
1245+ void MaterialSystem::AddStage ( drawSurf_t* drawSurf, shaderStage_t* pStage, uint32_t stage,
1246+ const bool mayUseVertexOverbright, const bool vertexLit, const bool fullbright ) {
1247+ const int variant = ( mayUseVertexOverbright ? Util::ordinal ( ShaderStageVariant::VERTEX_OVERBRIGHT ) : 0 )
1248+ | ( vertexLit ? Util::ordinal ( ShaderStageVariant::VERTEX_LIT ) : 0 )
1249+ | ( fullbright ? Util::ordinal ( ShaderStageVariant::FULLBRIGHT ) : 0 );
12511250
12521251 if ( pStage->variantOffsets [variant] == -1 ) {
12531252 pStage->variantOffsets [variant] = pStage->variantOffset ;
@@ -1353,9 +1352,9 @@ void MaterialSystem::ProcessStage( drawSurf_t* drawSurf, shaderStage_t* pStage,
13531352 lightMode_t lightMode;
13541353 deluxeMode_t deluxeMode;
13551354 SetLightDeluxeMode ( drawSurf, pStage->type , lightMode, deluxeMode );
1356- pStage-> mayUseVertexOverbright = pStage->type == stageType_t::ST_COLORMAP && drawSurf->bspSurface && pStage->shaderBinder == BindShaderGeneric3D;
1357- pStage-> vertexLit = lightMode == lightMode_t::VERTEX && pStage->shaderBinder == BindShaderLightMapping;
1358- pStage-> fullbright = lightMode == lightMode_t::FULLBRIGHT && pStage->shaderBinder == BindShaderLightMapping;
1355+ const bool mayUseVertexOverbright = pStage->type == stageType_t::ST_COLORMAP && drawSurf->bspSurface && pStage->shaderBinder == BindShaderGeneric3D;
1356+ const bool vertexLit = lightMode == lightMode_t::VERTEX && pStage->shaderBinder == BindShaderLightMapping;
1357+ const bool fullbright = lightMode == lightMode_t::FULLBRIGHT && pStage->shaderBinder == BindShaderLightMapping;
13591358
13601359 ComputeDynamics ( pStage );
13611360
@@ -1424,7 +1423,7 @@ void MaterialSystem::ProcessStage( drawSurf_t* drawSurf, shaderStage_t* pStage,
14241423 pStage->useMaterialSystem = true ;
14251424 pStage->initialized = true ;
14261425
1427- AddStage ( drawSurf, pStage, stage );
1426+ AddStage ( drawSurf, pStage, stage, mayUseVertexOverbright, vertexLit, fullbright );
14281427 AddStageTextures ( drawSurf, stage, &materials[previousMaterialID] );
14291428
14301429 if ( std::find ( materials[previousMaterialID].drawSurfs .begin (), materials[previousMaterialID].drawSurfs .end (), drawSurf )
0 commit comments