From: vortex Date: Sun, 24 Jul 2011 12:34:21 +0000 (+0000) Subject: Fix gl_texturecompression_sprites to check for gl_texturecompression. Rough patch... X-Git-Tag: xonotic-v0.6.0~163^2~300 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0137e106705b25124f9bb314f87454109e9d877b;p=xonotic%2Fdarkplaces.git Fix gl_texturecompression_sprites to check for gl_texturecompression. Rough patch to make v_glslgamma work with 2d graphics (hud, menupics, video etc.). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11252 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_particles.c b/cl_particles.c index 6c28e575..25e8b8b1 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -2436,7 +2436,7 @@ void R_DrawDecal_TransparentCallback(const entity_render_t *ent, const rtlight_t // now render the decals all at once // (this assumes they all use one particle font texture!) GL_BlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); - R_SetupShader_Generic(particletexture[63].texture, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(particletexture[63].texture, NULL, GL_MODULATE, 1, false, false); R_Mesh_PrepareVertices_Generic_Arrays(numsurfaces * 4, particle_vertex3f, particle_color4f, particle_texcoord2f); R_Mesh_Draw(0, numsurfaces * 4, 0, numsurfaces * 2, NULL, NULL, 0, particle_elements, NULL, 0); } @@ -2746,7 +2746,7 @@ void R_DrawParticle_TransparentCallback(const entity_render_t *ent, const rtligh if (texture != particletexture[p->texnum].texture) { texture = particletexture[p->texnum].texture; - R_SetupShader_Generic(texture, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(texture, NULL, GL_MODULATE, 1, false, false); } if (p->blendmode == PBLEND_INVMOD) diff --git a/cl_screen.c b/cl_screen.c index f9c2086a..0aec8006 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -2006,7 +2006,7 @@ static void SCR_DrawLoadingStack(void) sscanf(scr_loadingscreen_barcolor.string, "%f %f %f", &colors[12], &colors[13], &colors[14]); colors[15] = 1; R_Mesh_PrepareVertices_Generic_Arrays(4, verts, colors, NULL); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true, true); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); // make sure everything is cleared, including the progress indicator @@ -2105,11 +2105,11 @@ static void SCR_DrawLoadingScreen (qboolean clear) if(loadingscreentexture) { R_Mesh_PrepareVertices_Generic_Arrays(4, loadingscreentexture_vertex3f, NULL, loadingscreentexture_texcoord2f); - R_SetupShader_Generic(loadingscreentexture, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(loadingscreentexture, NULL, GL_MODULATE, 1, true, true); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); } R_Mesh_PrepareVertices_Generic_Arrays(4, loadingscreenpic_vertex3f, NULL, loadingscreenpic_texcoord2f); - R_SetupShader_Generic(Draw_GetPicTexture(loadingscreenpic), NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(Draw_GetPicTexture(loadingscreenpic), NULL, GL_MODULATE, 1, true, true); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); SCR_DrawLoadingStack(); } diff --git a/clvm_cmds.c b/clvm_cmds.c index 5b0b8043..0b61025e 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -3106,7 +3106,7 @@ static void VM_DrawPolygonCallback (const entity_render_t *ent, const rtlight_t rtexture_t *tex = polys->data_triangles[surfacelist[surfacelistindex]].texture; int drawflag = polys->data_triangles[surfacelist[surfacelistindex]].drawflag; DrawQ_ProcessDrawFlag(drawflag, polys->data_triangles[surfacelist[surfacelistindex]].hasalpha); - R_SetupShader_Generic(tex, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(tex, NULL, GL_MODULATE, 1, false, false); numtriangles = 0; for (;surfacelistindex < numsurfaces;surfacelistindex++) { diff --git a/draw.h b/draw.h index 2a5681a9..c7f1bc27 100644 --- a/draw.h +++ b/draw.h @@ -94,6 +94,7 @@ DRAWFLAG_NUMFLAGS, DRAWFLAG_MASK = 0xFF, // ONLY R_BeginPolygon() DRAWFLAG_MIPMAP = 0x100 // ONLY R_BeginPolygon() }; +#define DRAWFLAGS_BLEND (DRAWFLAG_ADDITIVE + DRAWFLAG_MODULATE + DRAWFLAG_2XMODULATE + DRAWFLAG_SCREEN) typedef struct ft2_settings_s { diff --git a/gl_draw.c b/gl_draw.c index ef1fee21..f1a61cff 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -1141,7 +1141,7 @@ void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, flo width = pic->width; if (height == 0) height = pic->height; - R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); #if 0 // AK07: lets be texel correct on the corners @@ -1157,7 +1157,7 @@ void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, flo #endif } else - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); floats[2] = floats[5] = floats[8] = floats[11] = 0; floats[0] = floats[9] = x; @@ -1190,10 +1190,10 @@ void DrawQ_RotPic(float x, float y, cachepic_t *pic, float width, float height, width = pic->width; if (height == 0) height = pic->height; - R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); } else - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); floats[2] = floats[5] = floats[8] = floats[11] = 0; @@ -1235,7 +1235,7 @@ void DrawQ_Fill(float x, float y, float width, float height, float red, float gr return; // R_Mesh_ResetTextureState(); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); floats[2] = floats[5] = floats[8] = floats[11] = 0; floats[0] = floats[9] = x; @@ -1562,7 +1562,7 @@ float DrawQ_String_Scale(float startx, float starty, const char *text, size_t ma // R_Mesh_ResetTextureState(); if (!fontmap) R_Mesh_TexBind(0, fnt->tex); - R_SetupShader_Generic(fnt->tex, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(fnt->tex, NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); ac = color4f; at = texcoord2f; @@ -1698,7 +1698,7 @@ float DrawQ_String_Scale(float startx, float starty, const char *text, size_t ma at = texcoord2f; av = vertex3f; } - R_SetupShader_Generic(fnt->tex, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(fnt->tex, NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); map = ft2_oldstyle_map; } } @@ -1767,7 +1767,7 @@ float DrawQ_String_Scale(float startx, float starty, const char *text, size_t ma break; } } - R_SetupShader_Generic(map->pic->tex, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(map->pic->tex, NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); } mapch = ch - map->start; @@ -1911,10 +1911,10 @@ void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height width = pic->width; if (height == 0) height = pic->height; - R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); } else - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); floats[2] = floats[5] = floats[8] = floats[11] = 0; floats[0] = floats[9] = x; @@ -1943,7 +1943,7 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags, qboolean hasalpha) DrawQ_ProcessDrawFlag(flags, hasalpha); // R_Mesh_ResetTextureState(); - R_SetupShader_Generic(mesh->texture, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(mesh->texture, NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); R_Mesh_PrepareVertices_Generic_Arrays(mesh->num_vertices, mesh->data_vertex3f, mesh->data_color4f, mesh->data_texcoord2f); R_Mesh_Draw(0, mesh->num_vertices, 0, mesh->num_triangles, mesh->data_element3i, NULL, 0, mesh->data_element3s, NULL, 0); @@ -2000,7 +2000,7 @@ void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, f if(!r_draw2d.integer && !r_draw2d_force) return; - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); switch(vid.renderpath) { @@ -2058,7 +2058,7 @@ void DrawQ_Lines (float width, int numlines, const float *vertex3f, const float case RENDERPATH_GL20: CHECKGLERROR - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, (flags & DRAWFLAGS_BLEND) ? false : true, true); //qglLineWidth(width);CHECKGLERROR @@ -2163,7 +2163,7 @@ void R_DrawGamma(void) } // all the blends ignore depth // R_Mesh_ResetTextureState(); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true, true); GL_DepthMask(true); GL_DepthRange(0, 1); GL_PolygonOffset(0, 0); diff --git a/gl_rmain.c b/gl_rmain.c index eb83eac7..7656e011 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1898,7 +1898,7 @@ void R_GLSL_DumpShader_f(void) Con_Printf("failed to write to hlsl/default.hlsl\n"); } -void R_SetupShader_Generic(rtexture_t *first, rtexture_t *second, int texturemode, int rgbscale, qboolean notrippy) +void R_SetupShader_Generic(rtexture_t *first, rtexture_t *second, int texturemode, int rgbscale, qboolean usegamma, qboolean notrippy) { unsigned int permutation = 0; if (r_trippy.integer && !notrippy) @@ -1910,6 +1910,8 @@ void R_SetupShader_Generic(rtexture_t *first, rtexture_t *second, int texturemod permutation |= SHADERPERMUTATION_SPECULAR; if (texturemode == GL_MODULATE) permutation |= SHADERPERMUTATION_COLORMAPPING; + if (usegamma && r_texture_gammaramps && v_glslgamma.integer && !vid_gammatables_trivial) + permutation |= SHADERPERMUTATION_GAMMARAMPS; else if (texturemode == GL_ADD) permutation |= SHADERPERMUTATION_GLOW; else if (texturemode == GL_DECAL) @@ -1925,6 +1927,8 @@ void R_SetupShader_Generic(rtexture_t *first, rtexture_t *second, int texturemod R_SetupShader_SetPermutationHLSL(SHADERMODE_GENERIC, permutation); R_Mesh_TexBind(GL20TU_FIRST , first ); R_Mesh_TexBind(GL20TU_SECOND, second); + if (permutation & SHADERPERMUTATION_GAMMARAMPS) + R_Mesh_TexBind(r_glsl_permutation->tex_Texture_GammaRamps, r_texture_gammaramps); #endif break; case RENDERPATH_D3D10: @@ -1938,6 +1942,8 @@ void R_SetupShader_Generic(rtexture_t *first, rtexture_t *second, int texturemod R_SetupShader_SetPermutationGLSL(SHADERMODE_GENERIC, permutation); R_Mesh_TexBind(r_glsl_permutation->tex_Texture_First , first ); R_Mesh_TexBind(r_glsl_permutation->tex_Texture_Second, second); + if (r_glsl_permutation->tex_Texture_GammaRamps >= 0) + R_Mesh_TexBind(r_glsl_permutation->tex_Texture_GammaRamps, r_texture_gammaramps); break; case RENDERPATH_GL13: case RENDERPATH_GLES1: @@ -6112,7 +6118,7 @@ void R_Bloom_CopyBloomTexture(float colorscale) break; } // TODO: do boxfilter scale-down in shader? - R_SetupShader_Generic(r_bloomstate.texture_screen, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(r_bloomstate.texture_screen, NULL, GL_MODULATE, 1, false, true); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); r_refdef.stats.bloom_drawpixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight; @@ -6148,7 +6154,7 @@ void R_Bloom_MakeTexture(void) GL_BlendFunc(GL_DST_COLOR, GL_SRC_COLOR); GL_Color(r,r,r,1); R_Mesh_PrepareVertices_Generic_Arrays(4, r_screenvertex3f, NULL, r_bloomstate.bloomtexcoord2f); - R_SetupShader_Generic(r_bloomstate.texture_bloom, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(r_bloomstate.texture_bloom, NULL, GL_MODULATE, 1, false, true); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); r_refdef.stats.bloom_drawpixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight; @@ -6164,7 +6170,7 @@ void R_Bloom_MakeTexture(void) brighten = sqrt(brighten); if(range >= 1) brighten *= (3 * range) / (2 * range - 1); // compensate for the "dot particle" - R_SetupShader_Generic(r_bloomstate.texture_bloom, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(r_bloomstate.texture_bloom, NULL, GL_MODULATE, 1, false, true); for (dir = 0;dir < 2;dir++) { @@ -6356,7 +6362,7 @@ static void R_BlendView(void) R_Mesh_PrepareVertices_Generic_Arrays(4, r_d3dscreenvertex3f, NULL, r_bloomstate.screentexcoord2f); break; } - R_SetupShader_Generic(r_bloomstate.texture_screen, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(r_bloomstate.texture_screen, NULL, GL_MODULATE, 1, false, true); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); r_refdef.stats.bloom_drawpixels += r_refdef.view.viewport.width * r_refdef.view.viewport.height; } @@ -6378,7 +6384,7 @@ static void R_BlendView(void) R_ResetViewRendering2D(); GL_Color(r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]); R_Mesh_PrepareVertices_Generic_Arrays(4, r_screenvertex3f, NULL, NULL); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, true); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); } @@ -6486,7 +6492,7 @@ static void R_BlendView(void) R_ResetViewRendering2D(); GL_Color(r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]); R_Mesh_PrepareVertices_Generic_Arrays(4, r_screenvertex3f, NULL, NULL); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, true); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); } @@ -7144,7 +7150,7 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa } R_Mesh_PrepareVertices_Generic_Arrays(8, vertex3f, color4f, NULL); R_Mesh_ResetTextureState(); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); R_Mesh_Draw(0, 8, 0, 12, NULL, NULL, 0, bboxelements, NULL, 0); } @@ -7160,7 +7166,7 @@ static void R_DrawEntityBBoxes_Callback(const entity_render_t *ent, const rtligh return; GL_CullFace(GL_NONE); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); prog = 0; SV_VM_Begin(); @@ -7310,7 +7316,7 @@ void R_DrawNoModel_TransparentCallback(const entity_render_t *ent, const rtlight } } // R_Mesh_ResetTextureState(); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); R_Mesh_PrepareVertices_Generic_Arrays(6, nomodelvertex3f, color4f, NULL); R_Mesh_Draw(0, 6, 0, 8, nomodelelement3i, NULL, 0, nomodelelement3s, NULL, 0); } @@ -9621,7 +9627,7 @@ static void R_DrawTextureSurfaceList_Sky(int texturenumsurfaces, const msurface_ // transparent sky would be ridiculous if (rsurface.texture->currentmaterialflags & MATERIALFLAGMASK_DEPTHSORTED) return; - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); skyrenderlater = true; RSurf_SetupDepthAndCulling(); GL_DepthMask(true); @@ -9650,7 +9656,7 @@ static void R_DrawTextureSurfaceList_Sky(int texturenumsurfaces, const msurface_ } else { - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); // fog sky GL_BlendFunc(GL_ONE, GL_ZERO); RSurf_PrepareVerticesForBatch(BATCHNEED_ARRAY_VERTEX | BATCHNEED_NOGAPS, texturenumsurfaces, texturesurfacelist); @@ -9945,7 +9951,7 @@ static void R_DrawTextureSurfaceList_ShowSurfaces(int texturenumsurfaces, const float c[4]; // R_Mesh_ResetTextureState(); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); if(rsurface.texture && rsurface.texture->currentskinframe) { @@ -10051,7 +10057,7 @@ static void R_DrawTextureSurfaceList_ShowSurfaces(int texturenumsurfaces, const RSurf_DrawBatch_GL11_ClampColor(); R_Mesh_PrepareVertices_Generic_Arrays(rsurface.batchnumvertices, rsurface.batchvertex3f, rsurface.passcolor4f, NULL); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); RSurf_DrawBatch(); } else if (!r_refdef.view.showdebug) @@ -10566,7 +10572,7 @@ void R_DrawLoc_Callback(const entity_render_t *ent, const rtlight_t *rtlight, in vertex3f[i] = mins[j] + size[j] * locboxvertex3f[i]; R_Mesh_PrepareVertices_Generic_Arrays(6*4, vertex3f, NULL, NULL); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); R_Mesh_Draw(0, 6*4, 0, 6*2, NULL, NULL, 0, locboxelements, NULL, 0); } @@ -11193,7 +11199,7 @@ static void R_DrawModelDecals_Entity(entity_render_t *ent) GL_DepthTest(true); GL_CullFace(GL_NONE); GL_BlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); - R_SetupShader_Generic(decalskinframe->base, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(decalskinframe->base, NULL, GL_MODULATE, 1, false, false); R_Mesh_Draw(0, numtris * 3, 0, numtris, decalsystem->element3i, NULL, 0, decalsystem->element3s, NULL, 0); } } @@ -11250,7 +11256,7 @@ void R_DrawDebugModel(void) { float c = r_refdef.view.colorscale * r_showoverdraw.value * 0.125f; flagsmask = MATERIALFLAG_SKY | MATERIALFLAG_WALL; - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); GL_DepthTest(false); GL_DepthMask(false); GL_DepthRange(0, 1); @@ -11280,7 +11286,7 @@ void R_DrawDebugModel(void) flagsmask = MATERIALFLAG_SKY | MATERIALFLAG_WALL; // R_Mesh_ResetTextureState(); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); GL_DepthRange(0, 1); GL_DepthTest(!r_showdisabledepthtest.integer); GL_DepthMask(false); diff --git a/gl_rsurf.c b/gl_rsurf.c index 967edc6f..ed5534ae 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -362,7 +362,7 @@ static void R_DrawPortal_Callback(const entity_render_t *ent, const rtlight_t *r for (i = 0, v = vertex3f;i < numpoints;i++, v += 3) VectorCopy(portal->points[i].position, v); R_Mesh_PrepareVertices_Generic_Arrays(numpoints, vertex3f, NULL, NULL); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); R_Mesh_Draw(0, numpoints, 0, numpoints - 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); } diff --git a/model_sprite.c b/model_sprite.c index 7b683988..4dc97dfb 100644 --- a/model_sprite.c +++ b/model_sprite.c @@ -95,7 +95,7 @@ static void Mod_Sprite_SharedSetup(const unsigned char *datapointer, int version float modelradius, interval; char name[MAX_QPATH], fogname[MAX_QPATH]; const void *startframes; - int texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | (gl_texturecompression_sprites.integer ? TEXF_COMPRESS : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_ALPHA | TEXF_CLAMP; + int texflags = (r_mipsprites.integer ? TEXF_MIPMAP : 0) | ((gl_texturecompression.integer && gl_texturecompression_sprites.integer) ? TEXF_COMPRESS : 0) | TEXF_ISSPRITE | TEXF_PICMIP | TEXF_ALPHA | TEXF_CLAMP; modelradius = 0; if (loadmodel->numframes < 1) diff --git a/r_explosion.c b/r_explosion.c index 3789d8d8..2a45c215 100644 --- a/r_explosion.c +++ b/r_explosion.c @@ -213,7 +213,7 @@ static void R_DrawExplosion_TransparentCallback(const entity_render_t *ent, cons R_EntityMatrix(&identitymatrix); // R_Mesh_ResetTextureState(); - R_SetupShader_Generic(explosiontexture, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(explosiontexture, NULL, GL_MODULATE, 1, false, false); for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++) { const explosion_t *e = explosion + surfacelist[surfacelistindex]; diff --git a/r_shadow.c b/r_shadow.c index a6d42724..5e7c5eb7 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -2028,7 +2028,7 @@ void R_Shadow_RenderMode_Reset(void) GL_Color(1, 1, 1, 1); GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1); GL_BlendFunc(GL_ONE, GL_ZERO); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); r_shadow_usingshadowmap2d = false; r_shadow_usingshadowmaportho = false; R_SetStencil(false, 255, GL_KEEP, GL_KEEP, GL_KEEP, GL_ALWAYS, 128, 255); @@ -5074,7 +5074,7 @@ void R_DrawModelShadows(void) // apply the blend to the shadowed areas R_Mesh_PrepareVertices_Generic_Arrays(4, r_screenvertex3f, NULL, NULL); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, true); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); // restore the viewport @@ -5256,7 +5256,7 @@ void R_Shadow_DrawCoronas(void) GL_PolygonOffset(0, 0); GL_DepthTest(true); R_Mesh_ResetTextureState(); - R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false); + R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, false, false); } break; case RENDERPATH_D3D9: diff --git a/render.h b/render.h index 9ef7403c..79b1198b 100644 --- a/render.h +++ b/render.h @@ -441,7 +441,7 @@ typedef enum rsurfacepass_e } rsurfacepass_t; -void R_SetupShader_Generic(rtexture_t *first, rtexture_t *second, int texturemode, int rgbscale, qboolean notrippy); +void R_SetupShader_Generic(rtexture_t *first, rtexture_t *second, int texturemode, int rgbscale, qboolean usegamma, qboolean notrippy); void R_SetupShader_DepthOrShadow(qboolean notrippy); void R_SetupShader_ShowDepth(qboolean notrippy); void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, float ambientscale, float diffusescale, float specularscale, rsurfacepass_t rsurfacepass, int texturenumsurfaces, const msurface_t **texturesurfacelist, void *waterplane, qboolean notrippy); diff --git a/shader_glsl.h b/shader_glsl.h index b02bd3c0..570b6748 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -305,6 +305,9 @@ "#ifdef USESPECULAR\n" "uniform sampler2D Texture_Second;\n" "#endif\n" +"#ifdef USEGAMMARAMPS\n" +"uniform sampler2D Texture_GammaRamps;\n" +"#endif\n" "\n" "void main(void)\n" "{\n" @@ -329,6 +332,11 @@ " dp_FragColor = mix(dp_FragColor, tex2, tex2.a);\n" "# endif\n" "#endif\n" +"#ifdef USEGAMMARAMPS\n" +" dp_FragColor.r = dp_texture2D(Texture_GammaRamps, vec2(dp_FragColor.r, 0)).r;\n" +" dp_FragColor.g = dp_texture2D(Texture_GammaRamps, vec2(dp_FragColor.g, 0)).g;\n" +" dp_FragColor.b = dp_texture2D(Texture_GammaRamps, vec2(dp_FragColor.b, 0)).b;\n" +"#endif\n" "}\n" "#endif\n" "#else // !MODE_GENERIC\n" diff --git a/shader_hlsl.h b/shader_hlsl.h index c93d4724..32261175 100644 --- a/shader_hlsl.h +++ b/shader_hlsl.h @@ -295,6 +295,9 @@ "#ifdef USESPECULAR\n" "uniform sampler Texture_Second : register(s1),\n" "#endif\n" +"#ifdef USEGAMMARAMPS\n" +"uniform sampler Texture_GammaRamps : register(s2),\n" +"#endif\n" "out float4 gl_FragColor : COLOR\n" ")\n" "{\n" @@ -319,6 +322,11 @@ " gl_FragColor = lerp(gl_FragColor, tex2, tex2.a);\n" "# endif\n" "#endif\n" +"#ifdef USEGAMMARAMPS\n" +" dp_FragColor.r = dp_texture2D(Texture_GammaRamps, vec2(dp_FragColor.r, 0)).r;\n" +" dp_FragColor.g = dp_texture2D(Texture_GammaRamps, vec2(dp_FragColor.g, 0)).g;\n" +" dp_FragColor.b = dp_texture2D(Texture_GammaRamps, vec2(dp_FragColor.b, 0)).b;\n" +"#endif\n" "}\n" "#endif\n" "#else // !MODE_GENERIC\n"