From 3b5d7c98e27e8bcbd432a045d2632559badeb21b Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 2 May 2010 12:33:51 +0000 Subject: [PATCH] first draft of sobel operator, use r_glsl_postprocess_uservec1 with an x value > 100 From: Wolfgang (Blub) Bumiller git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10115 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gl_rmain.c b/gl_rmain.c index d07ad154..120ee2e9 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -693,12 +693,44 @@ static const char *builtinshaderstring = "#ifdef USEPOSTPROCESSING\n" "// do r_glsl_dumpshader, edit glsl/default.glsl, and replace this by your own postprocessing if you want\n" "// this code does a blur with the radius specified in the first component of r_glsl_postprocess_uservec1 and blends it using the second component\n" +" if (UserVec1.x > 100.0) {\n" +" // vec2 ts = textureSize(Texture_First, 0);\n" +" // vec2 px = vec2(1/ts.x, 1/ts.y);\n" +" vec2 px = PixelSize;\n" +" vec4 x1 = texture2D(Texture_First, TexCoord1 + vec2(-px.x, px.y));\n" +" vec4 x2 = texture2D(Texture_First, TexCoord1 + vec2(-px.x, 0.0));\n" +" vec4 x3 = texture2D(Texture_First, TexCoord1 + vec2(-px.x,-px.y));\n" +" vec4 x4 = texture2D(Texture_First, TexCoord1 + vec2( px.x, px.y));\n" +" vec4 x5 = texture2D(Texture_First, TexCoord1 + vec2( px.x, 0.0));\n" +" vec4 x6 = texture2D(Texture_First, TexCoord1 + vec2( px.x,-px.y));\n" +" vec4 y1 = texture2D(Texture_First, TexCoord1 + vec2( px.x,-px.y));\n" +" vec4 y2 = texture2D(Texture_First, TexCoord1 + vec2( 0.0,-px.y));\n" +" vec4 y3 = texture2D(Texture_First, TexCoord1 + vec2(-px.x,-px.y));\n" +" vec4 y4 = texture2D(Texture_First, TexCoord1 + vec2( px.x, px.y));\n" +" vec4 y5 = texture2D(Texture_First, TexCoord1 + vec2( 0.0, px.y));\n" +" vec4 y6 = texture2D(Texture_First, TexCoord1 + vec2(-px.x, px.y));\n" +"" +" float px1 = -1.0 * (0.30*x1.r + 0.59*x1.g + 0.11*x1.b);\n" +" float px2 = -2.0 * (0.30*x2.r + 0.59*x2.g + 0.11*x2.b);\n" +" float px3 = -1.0 * (0.30*x3.r + 0.59*x3.g + 0.11*x3.b);\n" +" float px4 = 1.0 * (0.30*x4.r + 0.59*x4.g + 0.11*x4.b);\n" +" float px5 = 2.0 * (0.30*x5.r + 0.59*x5.g + 0.11*x5.b);\n" +" float px6 = 1.0 * (0.30*x6.r + 0.59*x6.g + 0.11*x6.b);\n" +" float py1 = -1.0 * (0.30*y1.r + 0.59*y1.g + 0.11*y1.b);\n" +" float py2 = -2.0 * (0.30*y2.r + 0.59*y2.g + 0.11*y2.b);\n" +" float py3 = -1.0 * (0.30*y3.r + 0.59*y3.g + 0.11*y3.b);\n" +" float py4 = 1.0 * (0.30*y4.r + 0.59*y4.g + 0.11*y4.b);\n" +" float py5 = 2.0 * (0.30*y5.r + 0.59*y5.g + 0.11*y5.b);\n" +" float py6 = 1.0 * (0.30*y6.r + 0.59*y6.g + 0.11*y6.b);\n" +" gl_FragColor = 0.25 * vec4(vec3(abs(px1 + px2 + px3 + px4 + px5 + px6)), 1) + 0.25 * vec4(vec3(abs(py1 + py2 + py3 + py4 + py5 + py6)), 1);\n" +" } else {\n" " gl_FragColor += texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2(-0.987688, -0.156434)) * UserVec1.y;\n" " gl_FragColor += texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2(-0.156434, -0.891007)) * UserVec1.y;\n" " gl_FragColor += texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2( 0.891007, -0.453990)) * UserVec1.y;\n" " gl_FragColor += texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2( 0.707107, 0.707107)) * UserVec1.y;\n" " gl_FragColor += texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2(-0.453990, 0.891007)) * UserVec1.y;\n" " gl_FragColor /= (1 + 5 * UserVec1.y);\n" +" }\n" "#endif\n" "\n" "#ifdef USESATURATION\n" -- 2.39.2