@@ -87,6 +87,11 @@ static Cvar::Cvar<float> r_portalDefaultRange(
8787Cvar::Cvar<bool > r_depthShaders (
8888 " r_depthShaders" , " use depth pre-pass shaders" , Cvar::CHEAT , true );
8989
90+ Cvar::Cvar<bool > r_compressColormaps (
91+ " r_compressColormaps" , " compress uncompressed color maps" , Cvar::NONE , false );
92+ Cvar::Cvar<bool > r_compressSkyboxes (
93+ " r_compressSkyboxes" , " compress uncompressed skyboxes" , Cvar::NONE , false );
94+
9095struct delayedStageTexture_t {
9196 bool active;
9297 stageType_t type;
@@ -1518,6 +1523,25 @@ static bool LoadMap( shaderStage_t *stage, const char *buffer, stageType_t type,
15181523 }
15191524 }
15201525
1526+ if ( r_compressColormaps.Get () )
1527+ {
1528+ if ( ! ( shader.registerFlags & RSF_2D ) )
1529+ {
1530+ switch ( type )
1531+ {
1532+ case stageType_t::ST_COLORMAP :
1533+ case stageType_t::ST_DIFFUSEMAP :
1534+ case stageType_t::ST_GLOWMAP :
1535+ case stageType_t::ST_REFLECTIONMAP :
1536+ case stageType_t::ST_SKYBOXMAP :
1537+ imageParams.bits |= IF_COMPRESS ;
1538+ break ;
1539+ default :
1540+ break ;
1541+ }
1542+ }
1543+ }
1544+
15211545 // determine image options
15221546 if ( stage->overrideNoPicMip || shader.noPicMip || stage->highQuality || stage->forceHighQuality )
15231547 {
@@ -3719,6 +3743,11 @@ static void ParseSkyParms( const char **text )
37193743 imageParams.bits |= IF_SRGB ;
37203744 }
37213745
3746+ if ( r_compressSkyboxes.Get () )
3747+ {
3748+ imageParams.bits |= IF_COMPRESS ;
3749+ }
3750+
37223751 shader.sky .outerbox = R_FindCubeImage ( prefix, imageParams );
37233752
37243753 if ( !shader.sky .outerbox )
@@ -6410,6 +6439,12 @@ shader_t *R_FindShader( const char *name, int flags )
64106439 imageParams.bits |= IF_SRGB ;
64116440 }
64126441
6442+ // HACK: Detect color grade images with RSF_NOMIP.
6443+ if ( r_compressColormaps.Get () && ! ( flags & RSF_NOMIP ) )
6444+ {
6445+ imageParams.bits |= IF_COMPRESS ;
6446+ }
6447+
64136448 image = R_FindImageFile ( fileName, imageParams );
64146449 }
64156450
@@ -7034,6 +7069,8 @@ void R_InitShaders()
70347069 Cvar::Latch (r_dpMaterial);
70357070 Cvar::Latch (r_depthShaders);
70367071 Cvar::Latch (r_portalDefaultRange);
7072+ Cvar::Latch (r_compressColormaps);
7073+ Cvar::Latch (r_compressSkyboxes);
70377074
70387075 memset ( shaderTableHashTable, 0 , sizeof ( shaderTableHashTable ) );
70397076 memset ( shaderHashTable, 0 , sizeof ( shaderHashTable ) );
0 commit comments