From: divverent Date: Sat, 3 Sep 2011 15:06:21 +0000 (+0000) Subject: disable offsetmapping where TEXF_ALPHA is not set and no height bias exists X-Git-Tag: xonotic-v0.5.0~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2b75d82853369832232c5e7e4c93d2d673cecd0c;p=xonotic%2Fdarkplaces.git disable offsetmapping where TEXF_ALPHA is not set and no height bias exists git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11322 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=f8363704e91dfe99ee1596e926183a86184c57cf --- diff --git a/gl_rmain.c b/gl_rmain.c index b2c7e6f9..427039f8 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -374,7 +374,7 @@ static void R_BuildBlankTextures(void) data[2] = 128; // normal X data[1] = 128; // normal Y data[0] = 255; // normal Z - data[3] = 128; // height + data[3] = 255; // height r_texture_blanknormalmap = R_LoadTexture2D(r_main_texturepool, "blankbump", 1, 1, data, TEXTYPE_BGRA, TEXF_PERSISTENT, -1, NULL); data[0] = 255; data[1] = 255; @@ -2183,7 +2183,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, } else if (rsurfacepass == RSURFPASS_DEFERREDGEOMETRY) { - if (r_glsl_offsetmapping.integer && (rsurface.texture->nmaptexture != r_texture_blanknormalmap || rsurface.texture->offsetbias != 0.0f)) + if (r_glsl_offsetmapping.integer && ((R_TextureFlags(rsurface.texture->nmaptexture) & TEXF_ALPHA) || rsurface.texture->offsetbias != 0.0f)) { switch(rsurface.texture->offsetmapping) { @@ -2204,7 +2204,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, } else if (rsurfacepass == RSURFPASS_RTLIGHT) { - if (r_glsl_offsetmapping.integer && (rsurface.texture->nmaptexture != r_texture_blanknormalmap || rsurface.texture->offsetbias != 0.0f)) + if (r_glsl_offsetmapping.integer && ((R_TextureFlags(rsurface.texture->nmaptexture) & TEXF_ALPHA) || rsurface.texture->offsetbias != 0.0f)) { switch(rsurface.texture->offsetmapping) { @@ -2250,7 +2250,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, } else if (rsurface.texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) { - if (r_glsl_offsetmapping.integer && (rsurface.texture->nmaptexture != r_texture_blanknormalmap || rsurface.texture->offsetbias != 0.0f)) + if (r_glsl_offsetmapping.integer && ((R_TextureFlags(rsurface.texture->nmaptexture) & TEXF_ALPHA) || rsurface.texture->offsetbias != 0.0f)) { switch(rsurface.texture->offsetmapping) { @@ -2303,7 +2303,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, } else if (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT_DIRECTIONAL) { - if (r_glsl_offsetmapping.integer && (rsurface.texture->nmaptexture != r_texture_blanknormalmap || rsurface.texture->offsetbias != 0.0f)) + if (r_glsl_offsetmapping.integer && ((R_TextureFlags(rsurface.texture->nmaptexture) & TEXF_ALPHA) || rsurface.texture->offsetbias != 0.0f)) { switch(rsurface.texture->offsetmapping) { @@ -2366,7 +2366,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, } else if (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT) { - if (r_glsl_offsetmapping.integer && (rsurface.texture->nmaptexture != r_texture_blanknormalmap || rsurface.texture->offsetbias != 0.0f)) + if (r_glsl_offsetmapping.integer && ((R_TextureFlags(rsurface.texture->nmaptexture) & TEXF_ALPHA) || rsurface.texture->offsetbias != 0.0f)) { switch(rsurface.texture->offsetmapping) { @@ -2426,7 +2426,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, } else { - if (r_glsl_offsetmapping.integer && (rsurface.texture->nmaptexture != r_texture_blanknormalmap || rsurface.texture->offsetbias != 0.0f)) + if (r_glsl_offsetmapping.integer && ((R_TextureFlags(rsurface.texture->nmaptexture) & TEXF_ALPHA) || rsurface.texture->offsetbias != 0.0f)) { switch(rsurface.texture->offsetmapping) { diff --git a/gl_textures.c b/gl_textures.c index 06038a3e..180447ff 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -2584,6 +2584,11 @@ int R_TextureHeight(rtexture_t *rt) return rt ? ((gltexture_t *)rt)->inputheight : 0; } +int R_TextureFlags(rtexture_t *rt) +{ + return rt ? ((gltexture_t *)rt)->flags : 0; +} + void R_UpdateTexture(rtexture_t *rt, const unsigned char *data, int x, int y, int z, int width, int height, int depth) { gltexture_t *glt = (gltexture_t *)rt; diff --git a/r_textures.h b/r_textures.h index 03e06908..82e3189c 100644 --- a/r_textures.h +++ b/r_textures.h @@ -179,6 +179,9 @@ int R_TextureWidth(rtexture_t *rt); // returns height of texture, as was specified when it was uploaded int R_TextureHeight(rtexture_t *rt); +// returns flags of texture, as was specified when it was uploaded +int R_TextureFlags(rtexture_t *rt); + // only frees the texture if TEXF_PERSISTENT is not set // also resets the variable void R_PurgeTexture(rtexture_t *prt);