From: cloudwalk Date: Mon, 21 Dec 2020 16:36:54 +0000 (+0000) Subject: shader_glsl: Don't use the r_colorfringe codepath if not enabled (terencehill) X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=706c061c2356f658c4f026ffe04bef2f41299cdb;p=xonotic%2Fdarkplaces.git shader_glsl: Don't use the r_colorfringe codepath if not enabled (terencehill) Fixes scr_screenshot_alpha git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13077 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index 5482cc5b..747c5f0e 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -847,9 +847,10 @@ enum SHADERSTATICPARM_SHADOWSAMPLER = 10, ///< sampler SHADERSTATICPARM_CELSHADING = 11, ///< celshading (alternative diffuse and specular math) SHADERSTATICPARM_CELOUTLINES = 12, ///< celoutline (depth buffer analysis to produce outlines) - SHADERSTATICPARM_FXAA = 13 ///< fast approximate anti aliasing + SHADERSTATICPARM_FXAA = 13, ///< fast approximate anti aliasing + SHADERSTATICPARM_COLORFRINGE = 14 ///< colorfringe (chromatic aberration) }; -#define SHADERSTATICPARMS_COUNT 14 +#define SHADERSTATICPARMS_COUNT 15 static const char *shaderstaticparmstrings_list[SHADERSTATICPARMS_COUNT]; static int shaderstaticparms_count = 0; @@ -898,6 +899,8 @@ qbool R_CompileShader_CheckStaticParms(void) R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_CELSHADING); if (r_celoutlines.integer) R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_CELOUTLINES); + if (r_colorfringe.value) + R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_COLORFRINGE); return memcmp(r_compileshader_staticparms, r_compileshader_staticparms_save, sizeof(r_compileshader_staticparms)) != 0; } @@ -926,6 +929,7 @@ static void R_CompileShader_AddStaticParms(unsigned int mode, uint64_t permutati R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_CELSHADING, "USECELSHADING"); R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_CELOUTLINES, "USECELOUTLINES"); R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_FXAA, "USEFXAA"); + R_COMPILESHADER_STATICPARM_EMIT(SHADERSTATICPARM_COLORFRINGE, "USECOLORFRINGE"); } /// information about each possible shader permutation diff --git a/shader_glsl.h b/shader_glsl.h index 11ec83dc..5a4b224a 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -300,11 +300,15 @@ "\n", "void main(void)\n", "{\n", +"#ifdef USECOLORFRINGE\n", " float fringe = ColorFringe;//.0033f;\n", " float amount = distance(TexCoord1, vec2(.5f,.5f));\n", " vec2 offset = vec2(amount*fringe,amount*fringe);\n", -" dp_FragColor.xy = texture(Texture_First, TexCoord1-offset).xy;\n", -" dp_FragColor.z = texture(Texture_First, TexCoord1+offset).z;\n", +" dp_FragColor.xy = dp_texture2D(Texture_First, TexCoord1-offset).xy;\n", +" dp_FragColor.z = dp_texture2D(Texture_First, TexCoord1+offset).z;\n", +"#else\n", +" dp_FragColor = dp_texture2D(Texture_First, TexCoord1);\n", +"#endif\n", "\n", "#ifdef USEFXAA\n", " dp_FragColor = fxaa(dp_FragColor, 8.0); // 8.0 can be changed for larger span\n",