Skip to content

Commit

Permalink
Fixed problem of texture gamma adjustments not working correctly on m…
Browse files Browse the repository at this point in the history
…odel skins with an alpha channel, or at all with hi-res TEXTUREs.
  • Loading branch information
danij committed Dec 14, 2008
1 parent 9007ee3 commit bf08d8a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions doomsday/engine/portable/src/gl_texmanager.c
Expand Up @@ -884,12 +884,7 @@ DGLuint GL_UploadTexture2(texturecontent_t *content)
// The source image can be used as-is.
freeOriginal = false;
rgbaOriginal = data;
for(i = 0; i < width * height * 3; i += 3)
{
data[i] = gammaTable[data[i]];
data[i+1] = gammaTable[data[i+1]];
data[i+2] = gammaTable[data[i+2]];
}

}
else
{
Expand All @@ -900,6 +895,16 @@ DGLuint GL_UploadTexture2(texturecontent_t *content)
rgbaOriginal, GL_GetPalette(), !load8bit);
}

if(applyTexGamma)
{
for(i = 0; i < width * height * comps; i += comps)
{
rgbaOriginal[i] = gammaTable[data[i]];
rgbaOriginal[i+1] = gammaTable[data[i+1]];
rgbaOriginal[i+2] = gammaTable[data[i+2]];
}
}

// If smart filtering is enabled, all textures are magnified 2x.
if(useSmartFilter && !noSmartFilter /* && comps == 3 */ )
{
Expand Down Expand Up @@ -1742,7 +1747,7 @@ byte GL_PrepareTexture(materialtexinst_t* inst, int ofTypeID,
}
else
{
int i;
int i, flags = 0;
image_t image;
boolean alphaChannel = false, RGBData = false;
texturedef_t* texDef = R_GetTextureDef(ofTypeID);
Expand Down Expand Up @@ -1799,12 +1804,16 @@ byte GL_PrepareTexture(materialtexinst_t* inst, int ofTypeID,
alphaChannel = image.isMasked;
}

if(RGBData)
flags |= TXCF_APPLY_GAMMACORRECTION;
if(noCompression)
flags |= TXCF_NO_COMPRESSION;

inst->tex =
GL_UploadTexture(image.pixels, image.width, image.height,
alphaChannel, true, RGBData, false, false,
glmode[mipmapping], glmode[texMagMode],
texAniso, DGL_REPEAT, DGL_REPEAT,
noCompression? TXCF_NO_COMPRESSION : 0);
texAniso, DGL_REPEAT, DGL_REPEAT, flags);

// Average color for glow planes.
if(RGBData)
Expand Down

0 comments on commit bf08d8a

Please sign in to comment.