Skip to content

Commit 36ee01d

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.
1 parent e12cb5a commit 36ee01d

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
@@ -2265,8 +2265,10 @@ GLShader_generic::GLShader_generic( GLShaderManager *manager ) :
22652265
u_AlphaThreshold( this ),
22662266
u_ModelMatrix( this ),
22672267
u_ModelViewProjectionMatrix( this ),
2268-
u_ColorModulateColorGen( this ),
2269-
u_Color( this ),
2268+
u_ColorModulateColorGen_Float( this ),
2269+
u_ColorModulateColorGen_Uint( this ),
2270+
u_Color_Float( this ),
2271+
u_Color_Uint( this ),
22702272
u_Bones( this ),
22712273
u_VertexInterpolation( this ),
22722274
u_DepthScale( this ),
@@ -2297,8 +2299,8 @@ GLShader_genericMaterial::GLShader_genericMaterial( GLShaderManager* manager ) :
22972299
u_AlphaThreshold( this ),
22982300
u_ModelMatrix( this ),
22992301
u_ModelViewProjectionMatrix( this ),
2300-
u_ColorModulateColorGen( this ),
2301-
u_Color( this ),
2302+
u_ColorModulateColorGen_Uint( this ),
2303+
u_Color_Uint( this ),
23022304
u_DepthScale( this ),
23032305
u_ShowTris( this ),
23042306
u_MaterialColour( this ),
@@ -2332,8 +2334,10 @@ GLShader_lightMapping::GLShader_lightMapping( GLShaderManager *manager ) :
23322334
u_LightTiles( this ),
23332335
u_TextureMatrix( this ),
23342336
u_SpecularExponent( this ),
2335-
u_ColorModulateColorGen( this ),
2336-
u_Color( this ),
2337+
u_ColorModulateColorGen_Float( this ),
2338+
u_ColorModulateColorGen_Uint( this ),
2339+
u_Color_Float( this ),
2340+
u_Color_Uint( this ),
23372341
u_AlphaThreshold( this ),
23382342
u_ViewOrigin( this ),
23392343
u_ModelMatrix( this ),
@@ -2400,8 +2404,8 @@ GLShader_lightMappingMaterial::GLShader_lightMappingMaterial( GLShaderManager* m
24002404
u_LightTiles( this ),
24012405
u_TextureMatrix( this ),
24022406
u_SpecularExponent( this ),
2403-
u_ColorModulateColorGen( this ),
2404-
u_Color( this ),
2407+
u_ColorModulateColorGen_Uint( this ),
2408+
u_Color_Uint( this ),
24052409
u_AlphaThreshold( this ),
24062410
u_ViewOrigin( this ),
24072411
u_ModelMatrix( this ),
@@ -2459,8 +2463,10 @@ GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ( GLShaderMana
24592463
u_TextureMatrix( this ),
24602464
u_SpecularExponent( this ),
24612465
u_AlphaThreshold( this ),
2462-
u_ColorModulateColorGen( this ),
2463-
u_Color( this ),
2466+
u_ColorModulateColorGen_Float( this ),
2467+
u_ColorModulateColorGen_Uint( this ),
2468+
u_Color_Float( this ),
2469+
u_Color_Uint( this ),
24642470
u_ViewOrigin( this ),
24652471
u_LightOrigin( this ),
24662472
u_LightColor( this ),
@@ -2512,8 +2518,10 @@ GLShader_forwardLighting_projXYZ::GLShader_forwardLighting_projXYZ( GLShaderMana
25122518
u_TextureMatrix( this ),
25132519
u_SpecularExponent( this ),
25142520
u_AlphaThreshold( this ),
2515-
u_ColorModulateColorGen( this ),
2516-
u_Color( this ),
2521+
u_ColorModulateColorGen_Float( this ),
2522+
u_ColorModulateColorGen_Uint( this ),
2523+
u_Color_Float( this ),
2524+
u_Color_Uint( this ),
25172525
u_ViewOrigin( this ),
25182526
u_LightOrigin( this ),
25192527
u_LightColor( this ),
@@ -2576,8 +2584,10 @@ GLShader_forwardLighting_directionalSun::GLShader_forwardLighting_directionalSun
25762584
u_TextureMatrix( this ),
25772585
u_SpecularExponent( this ),
25782586
u_AlphaThreshold( this ),
2579-
u_ColorModulateColorGen( this ),
2580-
u_Color( this ),
2587+
u_ColorModulateColorGen_Float( this ),
2588+
u_ColorModulateColorGen_Uint( this ),
2589+
u_Color_Float( this ),
2590+
u_Color_Uint( this ),
25812591
u_ViewOrigin( this ),
25822592
u_LightDir( this ),
25832593
u_LightColor( this ),
@@ -2639,7 +2649,8 @@ GLShader_shadowFill::GLShader_shadowFill( GLShaderManager *manager ) :
26392649
u_LightRadius( this ),
26402650
u_ModelMatrix( this ),
26412651
u_ModelViewProjectionMatrix( this ),
2642-
u_Color( this ),
2652+
u_Color_Float( this ),
2653+
u_Color_Uint( this ),
26432654
u_Bones( this ),
26442655
u_VertexInterpolation( this ),
26452656
GLDeformStage( this ),
@@ -2747,7 +2758,8 @@ GLShader_fogQuake3::GLShader_fogQuake3( GLShaderManager *manager ) :
27472758
u_FogMap( this ),
27482759
u_ModelMatrix( this ),
27492760
u_ModelViewProjectionMatrix( this ),
2750-
u_ColorGlobal( this ),
2761+
u_ColorGlobal_Float( this ),
2762+
u_ColorGlobal_Uint( this ),
27512763
u_Bones( this ),
27522764
u_VertexInterpolation( this ),
27532765
u_FogDistanceVector( this ),
@@ -2769,7 +2781,7 @@ GLShader_fogQuake3Material::GLShader_fogQuake3Material( GLShaderManager* manager
27692781
u_FogMap( this ),
27702782
u_ModelMatrix( this ),
27712783
u_ModelViewProjectionMatrix( this ),
2772-
u_ColorGlobal( this ),
2784+
u_ColorGlobal_Uint( this ),
27732785
u_FogDistanceVector( this ),
27742786
u_FogDepthVector( this ),
27752787
u_FogEyeT( this ),
@@ -2786,7 +2798,8 @@ GLShader_fogGlobal::GLShader_fogGlobal( GLShaderManager *manager ) :
27862798
u_DepthMap( this ),
27872799
u_ModelViewProjectionMatrix( this ),
27882800
u_UnprojectMatrix( this ),
2789-
u_Color( this ),
2801+
u_Color_Float( this ),
2802+
u_Color_Uint( this ),
27902803
u_FogDistanceVector( this )
27912804
{
27922805
}

0 commit comments

Comments
 (0)