Skip to content

Commit 70f44fd

Browse files
committed
renderer: add non-bitwise alternative for u_Color and u_ColorModulateColorGen
Add non-bitwise alternative for u_Color and u_ColorModulateColorGen, it is used when GLSL 1.20 isn't supported. The material system assumes GLSL 1.20 is supported.
1 parent c5c3129 commit 70f44fd

13 files changed

+482
-204
lines changed

src/engine/renderer/Material.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ void UpdateSurfaceDataGeneric3D( uint32_t* materials, shaderStage_t* pStage, boo
148148
alphaGen_t alphaGen = SetAlphaGen( pStage );
149149

150150
const bool styleLightMap = pStage->type == stageType_t::ST_STYLELIGHTMAP || pStage->type == stageType_t::ST_STYLECOLORMAP;
151-
gl_genericShaderMaterial->SetUniform_ColorModulateColorGen( rgbGen, alphaGen, mayUseVertexOverbright, styleLightMap );
151+
gl_genericShaderMaterial->SetUniform_ColorModulateColorGen_Uint( rgbGen, alphaGen, mayUseVertexOverbright, styleLightMap );
152152

153153
Tess_ComputeColor( pStage );
154-
gl_genericShaderMaterial->SetUniform_Color( tess.svars.color );
154+
gl_genericShaderMaterial->SetUniform_Color_Uint( tess.svars.color );
155155

156156
bool hasDepthFade = pStage->hasDepthFade;
157157
if ( hasDepthFade ) {
@@ -178,10 +178,10 @@ void UpdateSurfaceDataLightMapping( uint32_t* materials, shaderStage_t* pStage,
178178
}
179179

180180
// u_ColorModulate
181-
gl_lightMappingShaderMaterial->SetUniform_ColorModulateColorGen( rgbGen, alphaGen, false, !fullbright );
181+
gl_lightMappingShaderMaterial->SetUniform_ColorModulateColorGen_Uint( rgbGen, alphaGen, false, !fullbright );
182182

183183
// u_Color
184-
gl_lightMappingShaderMaterial->SetUniform_Color( tess.svars.color );
184+
gl_lightMappingShaderMaterial->SetUniform_Color_Uint( tess.svars.color );
185185

186186
// u_AlphaThreshold
187187
gl_lightMappingShaderMaterial->SetUniform_AlphaTest( pStage->stateBits );
@@ -1054,7 +1054,7 @@ void BindShaderFog( Material* material ) {
10541054
gl_fogQuake3ShaderMaterial->SetUniform_FogDepthVector( fogDepthVector );
10551055
gl_fogQuake3ShaderMaterial->SetUniform_FogEyeT( eyeT );
10561056

1057-
gl_fogQuake3ShaderMaterial->SetUniform_ColorGlobal( fog->color );
1057+
gl_fogQuake3ShaderMaterial->SetUniform_ColorGlobal_Uint( fog->color );
10581058

10591059
gl_fogQuake3ShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
10601060
gl_fogQuake3ShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] );

src/engine/renderer/gl_shader.cpp

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2411,8 +2411,10 @@ GLShader_generic::GLShader_generic() :
24112411
u_AlphaThreshold( this ),
24122412
u_ModelMatrix( this ),
24132413
u_ModelViewProjectionMatrix( this ),
2414-
u_ColorModulateColorGen( this ),
2415-
u_Color( this ),
2414+
u_ColorModulateColorGen_Float( this ),
2415+
u_ColorModulateColorGen_Uint( this ),
2416+
u_Color_Float( this ),
2417+
u_Color_Uint( this ),
24162418
u_Bones( this ),
24172419
u_VertexInterpolation( this ),
24182420
u_DepthScale( this ),
@@ -2444,8 +2446,8 @@ GLShader_genericMaterial::GLShader_genericMaterial() :
24442446
u_AlphaThreshold( this ),
24452447
u_ModelMatrix( this ),
24462448
u_ModelViewProjectionMatrix( this ),
2447-
u_ColorModulateColorGen( this ),
2448-
u_Color( this ),
2449+
u_ColorModulateColorGen_Uint( this ),
2450+
u_Color_Uint( this ),
24492451
u_DepthScale( this ),
24502452
u_ShowTris( this ),
24512453
u_MaterialColour( this ),
@@ -2479,8 +2481,10 @@ GLShader_lightMapping::GLShader_lightMapping() :
24792481
u_LightTiles( this ),
24802482
u_TextureMatrix( this ),
24812483
u_SpecularExponent( this ),
2482-
u_ColorModulateColorGen( this ),
2483-
u_Color( this ),
2484+
u_ColorModulateColorGen_Float( this ),
2485+
u_ColorModulateColorGen_Uint( this ),
2486+
u_Color_Float( this ),
2487+
u_Color_Uint( this ),
24842488
u_AlphaThreshold( this ),
24852489
u_ViewOrigin( this ),
24862490
u_ModelMatrix( this ),
@@ -2547,8 +2551,8 @@ GLShader_lightMappingMaterial::GLShader_lightMappingMaterial() :
25472551
u_LightTiles( this ),
25482552
u_TextureMatrix( this ),
25492553
u_SpecularExponent( this ),
2550-
u_ColorModulateColorGen( this ),
2551-
u_Color( this ),
2554+
u_ColorModulateColorGen_Uint( this ),
2555+
u_Color_Uint( this ),
25522556
u_AlphaThreshold( this ),
25532557
u_ViewOrigin( this ),
25542558
u_ModelMatrix( this ),
@@ -2607,8 +2611,10 @@ GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ():
26072611
u_TextureMatrix( this ),
26082612
u_SpecularExponent( this ),
26092613
u_AlphaThreshold( this ),
2610-
u_ColorModulateColorGen( this ),
2611-
u_Color( this ),
2614+
u_ColorModulateColorGen_Float( this ),
2615+
u_ColorModulateColorGen_Uint( this ),
2616+
u_Color_Float( this ),
2617+
u_Color_Uint( this ),
26122618
u_ViewOrigin( this ),
26132619
u_LightOrigin( this ),
26142620
u_LightColor( this ),
@@ -2661,8 +2667,10 @@ GLShader_forwardLighting_projXYZ::GLShader_forwardLighting_projXYZ():
26612667
u_TextureMatrix( this ),
26622668
u_SpecularExponent( this ),
26632669
u_AlphaThreshold( this ),
2664-
u_ColorModulateColorGen( this ),
2665-
u_Color( this ),
2670+
u_ColorModulateColorGen_Float( this ),
2671+
u_ColorModulateColorGen_Uint( this ),
2672+
u_Color_Float( this ),
2673+
u_Color_Uint( this ),
26662674
u_ViewOrigin( this ),
26672675
u_LightOrigin( this ),
26682676
u_LightColor( this ),
@@ -2726,8 +2734,10 @@ GLShader_forwardLighting_directionalSun::GLShader_forwardLighting_directionalSun
27262734
u_TextureMatrix( this ),
27272735
u_SpecularExponent( this ),
27282736
u_AlphaThreshold( this ),
2729-
u_ColorModulateColorGen( this ),
2730-
u_Color( this ),
2737+
u_ColorModulateColorGen_Float( this ),
2738+
u_ColorModulateColorGen_Uint( this ),
2739+
u_Color_Float( this ),
2740+
u_Color_Uint( this ),
27312741
u_ViewOrigin( this ),
27322742
u_LightDir( this ),
27332743
u_LightColor( this ),
@@ -2790,7 +2800,8 @@ GLShader_shadowFill::GLShader_shadowFill() :
27902800
u_LightRadius( this ),
27912801
u_ModelMatrix( this ),
27922802
u_ModelViewProjectionMatrix( this ),
2793-
u_Color( this ),
2803+
u_Color_Float( this ),
2804+
u_Color_Uint( this ),
27942805
u_Bones( this ),
27952806
u_VertexInterpolation( this ),
27962807
GLDeformStage( this ),
@@ -2903,7 +2914,8 @@ GLShader_fogQuake3::GLShader_fogQuake3() :
29032914
u_FogMap( this ),
29042915
u_ModelMatrix( this ),
29052916
u_ModelViewProjectionMatrix( this ),
2906-
u_ColorGlobal( this ),
2917+
u_ColorGlobal_Float( this ),
2918+
u_ColorGlobal_Uint( this ),
29072919
u_Bones( this ),
29082920
u_VertexInterpolation( this ),
29092921
u_FogDistanceVector( this ),
@@ -2926,7 +2938,7 @@ GLShader_fogQuake3Material::GLShader_fogQuake3Material() :
29262938
u_FogMap( this ),
29272939
u_ModelMatrix( this ),
29282940
u_ModelViewProjectionMatrix( this ),
2929-
u_ColorGlobal( this ),
2941+
u_ColorGlobal_Uint( this ),
29302942
u_FogDistanceVector( this ),
29312943
u_FogDepthVector( this ),
29322944
u_FogEyeT( this ),
@@ -2943,7 +2955,8 @@ GLShader_fogGlobal::GLShader_fogGlobal() :
29432955
u_ColorMap( this ),
29442956
u_DepthMap( this ),
29452957
u_UnprojectMatrix( this ),
2946-
u_Color( this ),
2958+
u_Color_Float( this ),
2959+
u_Color_Uint( this ),
29472960
u_FogDistanceVector( this )
29482961
{
29492962
}

0 commit comments

Comments
 (0)