Skip to content

Commit 60e7dc8

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 3c98e96 commit 60e7dc8

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
@@ -2407,8 +2407,10 @@ GLShader_generic::GLShader_generic( GLShaderManager *manager ) :
24072407
u_AlphaThreshold( this ),
24082408
u_ModelMatrix( this ),
24092409
u_ModelViewProjectionMatrix( this ),
2410-
u_ColorModulateColorGen( this ),
2411-
u_Color( this ),
2410+
u_ColorModulateColorGen_Float( this ),
2411+
u_ColorModulateColorGen_Uint( this ),
2412+
u_Color_Float( this ),
2413+
u_Color_Uint( this ),
24122414
u_Bones( this ),
24132415
u_VertexInterpolation( this ),
24142416
u_DepthScale( this ),
@@ -2439,8 +2441,8 @@ GLShader_genericMaterial::GLShader_genericMaterial( GLShaderManager* manager ) :
24392441
u_AlphaThreshold( this ),
24402442
u_ModelMatrix( this ),
24412443
u_ModelViewProjectionMatrix( this ),
2442-
u_ColorModulateColorGen( this ),
2443-
u_Color( this ),
2444+
u_ColorModulateColorGen_Uint( this ),
2445+
u_Color_Uint( this ),
24442446
u_DepthScale( this ),
24452447
u_ShowTris( this ),
24462448
u_MaterialColour( this ),
@@ -2474,8 +2476,10 @@ GLShader_lightMapping::GLShader_lightMapping( GLShaderManager *manager ) :
24742476
u_LightTiles( this ),
24752477
u_TextureMatrix( this ),
24762478
u_SpecularExponent( this ),
2477-
u_ColorModulateColorGen( this ),
2478-
u_Color( this ),
2479+
u_ColorModulateColorGen_Float( this ),
2480+
u_ColorModulateColorGen_Uint( this ),
2481+
u_Color_Float( this ),
2482+
u_Color_Uint( this ),
24792483
u_AlphaThreshold( this ),
24802484
u_ViewOrigin( this ),
24812485
u_ModelMatrix( this ),
@@ -2542,8 +2546,8 @@ GLShader_lightMappingMaterial::GLShader_lightMappingMaterial( GLShaderManager* m
25422546
u_LightTiles( this ),
25432547
u_TextureMatrix( this ),
25442548
u_SpecularExponent( this ),
2545-
u_ColorModulateColorGen( this ),
2546-
u_Color( this ),
2549+
u_ColorModulateColorGen_Uint( this ),
2550+
u_Color_Uint( this ),
25472551
u_AlphaThreshold( this ),
25482552
u_ViewOrigin( this ),
25492553
u_ModelMatrix( this ),
@@ -2601,8 +2605,10 @@ GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ( GLShaderMana
26012605
u_TextureMatrix( this ),
26022606
u_SpecularExponent( this ),
26032607
u_AlphaThreshold( this ),
2604-
u_ColorModulateColorGen( this ),
2605-
u_Color( this ),
2608+
u_ColorModulateColorGen_Float( this ),
2609+
u_ColorModulateColorGen_Uint( this ),
2610+
u_Color_Float( this ),
2611+
u_Color_Uint( this ),
26062612
u_ViewOrigin( this ),
26072613
u_LightOrigin( this ),
26082614
u_LightColor( this ),
@@ -2654,8 +2660,10 @@ GLShader_forwardLighting_projXYZ::GLShader_forwardLighting_projXYZ( GLShaderMana
26542660
u_TextureMatrix( this ),
26552661
u_SpecularExponent( this ),
26562662
u_AlphaThreshold( this ),
2657-
u_ColorModulateColorGen( this ),
2658-
u_Color( this ),
2663+
u_ColorModulateColorGen_Float( this ),
2664+
u_ColorModulateColorGen_Uint( this ),
2665+
u_Color_Float( this ),
2666+
u_Color_Uint( this ),
26592667
u_ViewOrigin( this ),
26602668
u_LightOrigin( this ),
26612669
u_LightColor( this ),
@@ -2718,8 +2726,10 @@ GLShader_forwardLighting_directionalSun::GLShader_forwardLighting_directionalSun
27182726
u_TextureMatrix( this ),
27192727
u_SpecularExponent( this ),
27202728
u_AlphaThreshold( this ),
2721-
u_ColorModulateColorGen( this ),
2722-
u_Color( this ),
2729+
u_ColorModulateColorGen_Float( this ),
2730+
u_ColorModulateColorGen_Uint( this ),
2731+
u_Color_Float( this ),
2732+
u_Color_Uint( this ),
27232733
u_ViewOrigin( this ),
27242734
u_LightDir( this ),
27252735
u_LightColor( this ),
@@ -2781,7 +2791,8 @@ GLShader_shadowFill::GLShader_shadowFill( GLShaderManager *manager ) :
27812791
u_LightRadius( this ),
27822792
u_ModelMatrix( this ),
27832793
u_ModelViewProjectionMatrix( this ),
2784-
u_Color( this ),
2794+
u_Color_Float( this ),
2795+
u_Color_Uint( this ),
27852796
u_Bones( this ),
27862797
u_VertexInterpolation( this ),
27872798
GLDeformStage( this ),
@@ -2889,7 +2900,8 @@ GLShader_fogQuake3::GLShader_fogQuake3( GLShaderManager *manager ) :
28892900
u_FogMap( this ),
28902901
u_ModelMatrix( this ),
28912902
u_ModelViewProjectionMatrix( this ),
2892-
u_ColorGlobal( this ),
2903+
u_ColorGlobal_Float( this ),
2904+
u_ColorGlobal_Uint( this ),
28932905
u_Bones( this ),
28942906
u_VertexInterpolation( this ),
28952907
u_FogDistanceVector( this ),
@@ -2911,7 +2923,7 @@ GLShader_fogQuake3Material::GLShader_fogQuake3Material( GLShaderManager* manager
29112923
u_FogMap( this ),
29122924
u_ModelMatrix( this ),
29132925
u_ModelViewProjectionMatrix( this ),
2914-
u_ColorGlobal( this ),
2926+
u_ColorGlobal_Uint( this ),
29152927
u_FogDistanceVector( this ),
29162928
u_FogDepthVector( this ),
29172929
u_FogEyeT( this ),
@@ -2928,7 +2940,8 @@ GLShader_fogGlobal::GLShader_fogGlobal( GLShaderManager *manager ) :
29282940
u_DepthMap( this ),
29292941
u_ModelViewProjectionMatrix( this ),
29302942
u_UnprojectMatrix( this ),
2931-
u_Color( this ),
2943+
u_Color_Float( this ),
2944+
u_Color_Uint( this ),
29322945
u_FogDistanceVector( this )
29332946
{
29342947
}

0 commit comments

Comments
 (0)