Skip to content

Commit 3cc42d3

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 d9efe0c commit 3cc42d3

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
@@ -2402,8 +2402,10 @@ GLShader_generic::GLShader_generic( GLShaderManager *manager ) :
24022402
u_AlphaThreshold( this ),
24032403
u_ModelMatrix( this ),
24042404
u_ModelViewProjectionMatrix( this ),
2405-
u_ColorModulateColorGen( this ),
2406-
u_Color( this ),
2405+
u_ColorModulateColorGen_Float( this ),
2406+
u_ColorModulateColorGen_Uint( this ),
2407+
u_Color_Float( this ),
2408+
u_Color_Uint( this ),
24072409
u_Bones( this ),
24082410
u_VertexInterpolation( this ),
24092411
u_DepthScale( this ),
@@ -2434,8 +2436,8 @@ GLShader_genericMaterial::GLShader_genericMaterial( GLShaderManager* manager ) :
24342436
u_AlphaThreshold( this ),
24352437
u_ModelMatrix( this ),
24362438
u_ModelViewProjectionMatrix( this ),
2437-
u_ColorModulateColorGen( this ),
2438-
u_Color( this ),
2439+
u_ColorModulateColorGen_Uint( this ),
2440+
u_Color_Uint( this ),
24392441
u_DepthScale( this ),
24402442
u_ShowTris( this ),
24412443
u_MaterialColour( this ),
@@ -2469,8 +2471,10 @@ GLShader_lightMapping::GLShader_lightMapping( GLShaderManager *manager ) :
24692471
u_LightTiles( this ),
24702472
u_TextureMatrix( this ),
24712473
u_SpecularExponent( this ),
2472-
u_ColorModulateColorGen( this ),
2473-
u_Color( this ),
2474+
u_ColorModulateColorGen_Float( this ),
2475+
u_ColorModulateColorGen_Uint( this ),
2476+
u_Color_Float( this ),
2477+
u_Color_Uint( this ),
24742478
u_AlphaThreshold( this ),
24752479
u_ViewOrigin( this ),
24762480
u_ModelMatrix( this ),
@@ -2537,8 +2541,8 @@ GLShader_lightMappingMaterial::GLShader_lightMappingMaterial( GLShaderManager* m
25372541
u_LightTiles( this ),
25382542
u_TextureMatrix( this ),
25392543
u_SpecularExponent( this ),
2540-
u_ColorModulateColorGen( this ),
2541-
u_Color( this ),
2544+
u_ColorModulateColorGen_Uint( this ),
2545+
u_Color_Uint( this ),
25422546
u_AlphaThreshold( this ),
25432547
u_ViewOrigin( this ),
25442548
u_ModelMatrix( this ),
@@ -2596,8 +2600,10 @@ GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ( GLShaderMana
25962600
u_TextureMatrix( this ),
25972601
u_SpecularExponent( this ),
25982602
u_AlphaThreshold( this ),
2599-
u_ColorModulateColorGen( this ),
2600-
u_Color( this ),
2603+
u_ColorModulateColorGen_Float( this ),
2604+
u_ColorModulateColorGen_Uint( this ),
2605+
u_Color_Float( this ),
2606+
u_Color_Uint( this ),
26012607
u_ViewOrigin( this ),
26022608
u_LightOrigin( this ),
26032609
u_LightColor( this ),
@@ -2649,8 +2655,10 @@ GLShader_forwardLighting_projXYZ::GLShader_forwardLighting_projXYZ( GLShaderMana
26492655
u_TextureMatrix( this ),
26502656
u_SpecularExponent( this ),
26512657
u_AlphaThreshold( this ),
2652-
u_ColorModulateColorGen( this ),
2653-
u_Color( this ),
2658+
u_ColorModulateColorGen_Float( this ),
2659+
u_ColorModulateColorGen_Uint( this ),
2660+
u_Color_Float( this ),
2661+
u_Color_Uint( this ),
26542662
u_ViewOrigin( this ),
26552663
u_LightOrigin( this ),
26562664
u_LightColor( this ),
@@ -2713,8 +2721,10 @@ GLShader_forwardLighting_directionalSun::GLShader_forwardLighting_directionalSun
27132721
u_TextureMatrix( this ),
27142722
u_SpecularExponent( this ),
27152723
u_AlphaThreshold( this ),
2716-
u_ColorModulateColorGen( this ),
2717-
u_Color( this ),
2724+
u_ColorModulateColorGen_Float( this ),
2725+
u_ColorModulateColorGen_Uint( this ),
2726+
u_Color_Float( this ),
2727+
u_Color_Uint( this ),
27182728
u_ViewOrigin( this ),
27192729
u_LightDir( this ),
27202730
u_LightColor( this ),
@@ -2776,7 +2786,8 @@ GLShader_shadowFill::GLShader_shadowFill( GLShaderManager *manager ) :
27762786
u_LightRadius( this ),
27772787
u_ModelMatrix( this ),
27782788
u_ModelViewProjectionMatrix( this ),
2779-
u_Color( this ),
2789+
u_Color_Float( this ),
2790+
u_Color_Uint( this ),
27802791
u_Bones( this ),
27812792
u_VertexInterpolation( this ),
27822793
GLDeformStage( this ),
@@ -2884,7 +2895,8 @@ GLShader_fogQuake3::GLShader_fogQuake3( GLShaderManager *manager ) :
28842895
u_FogMap( this ),
28852896
u_ModelMatrix( this ),
28862897
u_ModelViewProjectionMatrix( this ),
2887-
u_ColorGlobal( this ),
2898+
u_ColorGlobal_Float( this ),
2899+
u_ColorGlobal_Uint( this ),
28882900
u_Bones( this ),
28892901
u_VertexInterpolation( this ),
28902902
u_FogDistanceVector( this ),
@@ -2906,7 +2918,7 @@ GLShader_fogQuake3Material::GLShader_fogQuake3Material( GLShaderManager* manager
29062918
u_FogMap( this ),
29072919
u_ModelMatrix( this ),
29082920
u_ModelViewProjectionMatrix( this ),
2909-
u_ColorGlobal( this ),
2921+
u_ColorGlobal_Uint( this ),
29102922
u_FogDistanceVector( this ),
29112923
u_FogDepthVector( this ),
29122924
u_FogEyeT( this ),
@@ -2923,7 +2935,8 @@ GLShader_fogGlobal::GLShader_fogGlobal( GLShaderManager *manager ) :
29232935
u_DepthMap( this ),
29242936
u_ModelViewProjectionMatrix( this ),
29252937
u_UnprojectMatrix( this ),
2926-
u_Color( this ),
2938+
u_Color_Float( this ),
2939+
u_Color_Uint( this ),
29272940
u_FogDistanceVector( this )
29282941
{
29292942
}

0 commit comments

Comments
 (0)