Skip to content

Commit 0e84ccd

Browse files
committed
renderer: introduce and use IF_NOALPHA
1 parent 6e38dad commit 0e84ccd

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/engine/renderer/tr_bsp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,8 @@ static void R_LoadLightmaps( lump_t *l, const char *bspName )
483483
return;
484484
}
485485

486-
int lightMapBits = IF_LIGHTMAP | IF_NOPICMIP;
487-
int deluxeMapBits = IF_NORMALMAP | IF_NOPICMIP;
486+
int lightMapBits = IF_LIGHTMAP | IF_NOALPHA | IF_NOPICMIP;
487+
int deluxeMapBits = IF_NORMALMAP | IF_NOALPHA | IF_NOPICMIP;
488488

489489
if ( tr.worldLinearizeLightMap )
490490
{

src/engine/renderer/tr_image.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,13 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
849849
int mipWidth, mipHeight, mipLayers, mipSize, blockSize = 0;
850850
int i, c;
851851
const byte *scan;
852+
853+
bool isSRGB = image->bits & IF_SRGB;
854+
bool isAlpha = !( image->bits & IF_NOALPHA );
855+
852856
GLenum target;
853857
GLenum format = GL_RGBA;
854-
GLenum internalFormat = GL_RGB;
855-
bool isSRGB = image->bits & IF_SRGB;
858+
GLenum internalFormat = isAlpha ? GL_RGBA : GL_RGB;
856859

857860
static const vec4_t oneClampBorder = { 1, 1, 1, 1 };
858861
static const vec4_t zeroClampBorder = { 0, 0, 0, 1 };
@@ -1054,15 +1057,12 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
10541057
}
10551058
else
10561059
{
1057-
// lightmap does not have alpha channel
1058-
if ( image->bits & IF_LIGHTMAP )
1059-
{
1060-
internalFormat = GL_RGB8;
1061-
}
1062-
else
1063-
{
1064-
internalFormat = GL_RGBA8;
1065-
}
1060+
internalFormat = GL_RGBA8;
1061+
}
1062+
1063+
if ( internalFormat == GL_RGBA8 && !isAlpha )
1064+
{
1065+
internalFormat = GL_RGB8;
10661066
}
10671067

10681068
// Detect formats.
@@ -2757,7 +2757,7 @@ static void R_CreateColorGradeImage()
27572757
}
27582758

27592759
imageParams_t imageParams = {};
2760-
imageParams.bits = IF_NOPICMIP;
2760+
imageParams.bits = IF_NOPICMIP | IF_NOALPHA;
27612761
imageParams.filterType = filterType_t::FT_LINEAR;
27622762
imageParams.wrapType = wrapTypeEnum_t::WT_EDGE_CLAMP;
27632763

src/engine/renderer/tr_local.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ enum class ssaoMode {
484484
IF_BC4 = BIT( 22 ),
485485
IF_BC5 = BIT( 23 ),
486486
IF_RGBA32UI = BIT( 24 ),
487-
IF_HOMEPATH = BIT( 25 )
487+
IF_HOMEPATH = BIT( 25 ),
488+
IF_NOALPHA = BIT( 26 )
488489
};
489490

490491
enum class filterType_t

0 commit comments

Comments
 (0)