]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
shader_glsl: Don't use the r_colorfringe codepath if not enabled (terencehill)
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 21 Dec 2020 16:36:54 +0000 (16:36 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 21 Dec 2020 16:36:54 +0000 (16:36 +0000)
Fixes scr_screenshot_alpha

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13077 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
shader_glsl.h

index 5482cc5b234c9e1b493b07d1d97f038d2fd0e81f..747c5f0ed0889c3aa286d95f4515f0763e9190b8 100644 (file)
@@ -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
index 11ec83dcde56c6c7ce93e78cd9f536f9e1bb6e80..5a4b224a2e88b31b1363444828ed5c824cb78317 100644 (file)
 "\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",