]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Begin adding border shading (vignette) postprocessing effect samual/bordershading
authorSamual Lenks <samual@xonotic.org>
Sat, 28 Dec 2013 14:15:12 +0000 (09:15 -0500)
committerSamual Lenks <samual@xonotic.org>
Sat, 28 Dec 2013 14:15:12 +0000 (09:15 -0500)
gl_rmain.c
shader_glsl.h
shader_hlsl.h

index 338950aab2c805b3a621852cebfb6f48b8557685..0bac7f36062ee4ec9cfaaeacc1199e4e1b989964 100644 (file)
@@ -881,9 +881,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_BORDERSHADING = 14 ///< darken edges of screen with shaded gradient
 };
-#define SHADERSTATICPARMS_COUNT 14
+#define SHADERSTATICPARMS_COUNT 15
 
 static const char *shaderstaticparmstrings_list[SHADERSTATICPARMS_COUNT];
 static int shaderstaticparms_count = 0;
@@ -933,6 +934,8 @@ qboolean R_CompileShader_CheckStaticParms(void)
        if (r_celoutlines.integer)
                R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_CELOUTLINES);
 
+       R_COMPILESHADER_STATICPARM_ENABLE(SHADERSTATICPARM_BORDERSHADING);
+
        return memcmp(r_compileshader_staticparms, r_compileshader_staticparms_save, sizeof(r_compileshader_staticparms)) != 0;
 }
 
@@ -960,6 +963,7 @@ static void R_CompileShader_AddStaticParms(unsigned int mode, unsigned int permu
        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_BORDERSHADING, "USEBORDERSHADING");
 }
 
 /// information about each possible shader permutation
index 1c6cb906768149fce8126ff71705baf75a5ec494..8eb4c0c9f5eeca04116844a1ff320ea06047e1b6 100644 (file)
 "      dp_FragColor.rgb = dp_FragColor.rgb * (1.0 + UserVec2.x) + vec3(max(0.0, sobel - UserVec2.z))*UserVec2.y;\n",
 "#endif\n",
 "\n",
+"#ifdef USEBORDERSHADING\n",
+"      // scaled simple border shading\n",
+"      // todo: replace the following with cvarred settings\n",
+"      float vertpad = 0.15;\n",
+"      float horipad = 0.1;\n",
+"      float multiplier = 4.0;\n", 
+"      float dist = min(horipad + TexCoord1.x, min(vertpad + TexCoord1.y, min((1.0 + horipad) - TexCoord1.x, (1.0 + vertpad) - TexCoord1.y)));\n",
+"\n",
+"      dist = clamp(dist * multiplier, 0.0, 1.0);\n",
+"      dp_FragColor.xyz *= dist;\n",
+"#endif\n",
+"\n",
 "#ifdef USEBLOOM\n",
 "      dp_FragColor += max(vec4(0,0,0,0), dp_texture2D(Texture_Second, TexCoord2) - BloomColorSubtract);\n",
 "#endif\n",
index e81e603990d4912e3bb1d7545f4c875eb5fcce64..34ebee6cf086444badd9ee6c22d0b8dc90e1af84 100644 (file)
 "      dp_FragColor.rgb = dp_FragColor.rgb * (1.0 + UserVec2.x) + float3(1,1,1)*max(0.0, sobel - UserVec2.z)*UserVec2.y;\n",
 "#endif\n",
 "\n",
+"#ifdef USEBORDERSHADING\n",
+"      // scaled simple border shading\n",
+"      // todo: replace the following with cvarred settings\n",
+"      float vertpad = 0.15;\n",
+"      float horipad = 0.1;\n",
+"      float multiplier = 4.0;\n", 
+"      float dist = min(horipad + TexCoord1.x, min(vertpad + TexCoord1.y, min((1.0 + horipad) - TexCoord1.x, (1.0 + vertpad) - TexCoord1.y)));\n",
+"\n",
+"      dist = clamp(dist * multiplier, 0.0, 1.0);\n",
+"      dp_FragColor.xyz *= dist;\n",
+"#endif\n",
+"\n",
 "#ifdef USEBLOOM\n",
 "      dp_FragColor += max(float4(0,0,0,0), tex2D(Texture_Second, TexCoord2) - BloomColorSubtract);\n",
 "#endif\n",