Skip to content

renderer: add non-bitwise alternative for u_Color and u_ColorModulateColorGen #1570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/engine/renderer/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ void UpdateSurfaceDataGeneric3D( uint32_t* materials, shaderStage_t* pStage, boo
alphaGen_t alphaGen = SetAlphaGen( pStage );

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

Tess_ComputeColor( pStage );
gl_genericShaderMaterial->SetUniform_Color( tess.svars.color );
gl_genericShaderMaterial->SetUniform_Color_Uint( tess.svars.color );

bool hasDepthFade = pStage->hasDepthFade;
if ( hasDepthFade ) {
Expand All @@ -178,10 +178,10 @@ void UpdateSurfaceDataLightMapping( uint32_t* materials, shaderStage_t* pStage,
}

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

// u_Color
gl_lightMappingShaderMaterial->SetUniform_Color( tess.svars.color );
gl_lightMappingShaderMaterial->SetUniform_Color_Uint( tess.svars.color );

// u_AlphaThreshold
gl_lightMappingShaderMaterial->SetUniform_AlphaTest( pStage->stateBits );
Expand Down Expand Up @@ -1054,7 +1054,7 @@ void BindShaderFog( Material* material ) {
gl_fogQuake3ShaderMaterial->SetUniform_FogDepthVector( fogDepthVector );
gl_fogQuake3ShaderMaterial->SetUniform_FogEyeT( eyeT );

gl_fogQuake3ShaderMaterial->SetUniform_ColorGlobal( fog->color );
gl_fogQuake3ShaderMaterial->SetUniform_ColorGlobal_Uint( fog->color );

gl_fogQuake3ShaderMaterial->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix );
gl_fogQuake3ShaderMaterial->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[glState.stackIndex] );
Expand Down
49 changes: 31 additions & 18 deletions src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2407,8 +2407,10 @@ GLShader_generic::GLShader_generic( GLShaderManager *manager ) :
u_AlphaThreshold( this ),
u_ModelMatrix( this ),
u_ModelViewProjectionMatrix( this ),
u_ColorModulateColorGen( this ),
u_Color( this ),
u_ColorModulateColorGen_Float( this ),
u_ColorModulateColorGen_Uint( this ),
u_Color_Float( this ),
u_Color_Uint( this ),
u_Bones( this ),
u_VertexInterpolation( this ),
u_DepthScale( this ),
Expand Down Expand Up @@ -2439,8 +2441,8 @@ GLShader_genericMaterial::GLShader_genericMaterial( GLShaderManager* manager ) :
u_AlphaThreshold( this ),
u_ModelMatrix( this ),
u_ModelViewProjectionMatrix( this ),
u_ColorModulateColorGen( this ),
u_Color( this ),
u_ColorModulateColorGen_Uint( this ),
u_Color_Uint( this ),
u_DepthScale( this ),
u_ShowTris( this ),
u_MaterialColour( this ),
Expand Down Expand Up @@ -2474,8 +2476,10 @@ GLShader_lightMapping::GLShader_lightMapping( GLShaderManager *manager ) :
u_LightTiles( this ),
u_TextureMatrix( this ),
u_SpecularExponent( this ),
u_ColorModulateColorGen( this ),
u_Color( this ),
u_ColorModulateColorGen_Float( this ),
u_ColorModulateColorGen_Uint( this ),
u_Color_Float( this ),
u_Color_Uint( this ),
u_AlphaThreshold( this ),
u_ViewOrigin( this ),
u_ModelMatrix( this ),
Expand Down Expand Up @@ -2542,8 +2546,8 @@ GLShader_lightMappingMaterial::GLShader_lightMappingMaterial( GLShaderManager* m
u_LightTiles( this ),
u_TextureMatrix( this ),
u_SpecularExponent( this ),
u_ColorModulateColorGen( this ),
u_Color( this ),
u_ColorModulateColorGen_Uint( this ),
u_Color_Uint( this ),
u_AlphaThreshold( this ),
u_ViewOrigin( this ),
u_ModelMatrix( this ),
Expand Down Expand Up @@ -2601,8 +2605,10 @@ GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ( GLShaderMana
u_TextureMatrix( this ),
u_SpecularExponent( this ),
u_AlphaThreshold( this ),
u_ColorModulateColorGen( this ),
u_Color( this ),
u_ColorModulateColorGen_Float( this ),
u_ColorModulateColorGen_Uint( this ),
u_Color_Float( this ),
u_Color_Uint( this ),
u_ViewOrigin( this ),
u_LightOrigin( this ),
u_LightColor( this ),
Expand Down Expand Up @@ -2654,8 +2660,10 @@ GLShader_forwardLighting_projXYZ::GLShader_forwardLighting_projXYZ( GLShaderMana
u_TextureMatrix( this ),
u_SpecularExponent( this ),
u_AlphaThreshold( this ),
u_ColorModulateColorGen( this ),
u_Color( this ),
u_ColorModulateColorGen_Float( this ),
u_ColorModulateColorGen_Uint( this ),
u_Color_Float( this ),
u_Color_Uint( this ),
u_ViewOrigin( this ),
u_LightOrigin( this ),
u_LightColor( this ),
Expand Down Expand Up @@ -2718,8 +2726,10 @@ GLShader_forwardLighting_directionalSun::GLShader_forwardLighting_directionalSun
u_TextureMatrix( this ),
u_SpecularExponent( this ),
u_AlphaThreshold( this ),
u_ColorModulateColorGen( this ),
u_Color( this ),
u_ColorModulateColorGen_Float( this ),
u_ColorModulateColorGen_Uint( this ),
u_Color_Float( this ),
u_Color_Uint( this ),
u_ViewOrigin( this ),
u_LightDir( this ),
u_LightColor( this ),
Expand Down Expand Up @@ -2781,7 +2791,8 @@ GLShader_shadowFill::GLShader_shadowFill( GLShaderManager *manager ) :
u_LightRadius( this ),
u_ModelMatrix( this ),
u_ModelViewProjectionMatrix( this ),
u_Color( this ),
u_Color_Float( this ),
u_Color_Uint( this ),
u_Bones( this ),
u_VertexInterpolation( this ),
GLDeformStage( this ),
Expand Down Expand Up @@ -2889,7 +2900,8 @@ GLShader_fogQuake3::GLShader_fogQuake3( GLShaderManager *manager ) :
u_FogMap( this ),
u_ModelMatrix( this ),
u_ModelViewProjectionMatrix( this ),
u_ColorGlobal( this ),
u_ColorGlobal_Float( this ),
u_ColorGlobal_Uint( this ),
u_Bones( this ),
u_VertexInterpolation( this ),
u_FogDistanceVector( this ),
Expand All @@ -2911,7 +2923,7 @@ GLShader_fogQuake3Material::GLShader_fogQuake3Material( GLShaderManager* manager
u_FogMap( this ),
u_ModelMatrix( this ),
u_ModelViewProjectionMatrix( this ),
u_ColorGlobal( this ),
u_ColorGlobal_Uint( this ),
u_FogDistanceVector( this ),
u_FogDepthVector( this ),
u_FogEyeT( this ),
Expand All @@ -2928,7 +2940,8 @@ GLShader_fogGlobal::GLShader_fogGlobal( GLShaderManager *manager ) :
u_DepthMap( this ),
u_ModelViewProjectionMatrix( this ),
u_UnprojectMatrix( this ),
u_Color( this ),
u_Color_Float( this ),
u_Color_Uint( this ),
u_FogDistanceVector( this )
{
}
Expand Down
Loading