From: havoc Date: Sat, 5 May 2012 21:24:08 +0000 (+0000) Subject: redesigned r_celoutlines shader code to be a shadowing method rather than edge detect... X-Git-Tag: xonotic-v0.7.0~139 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f76f6258d8bfee9f4c34a1fcafc64eb558c4b9fe;p=xonotic%2Fdarkplaces.git redesigned r_celoutlines shader code to be a shadowing method rather than edge detect, looks better now git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11814 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=8e6c353f0e8e9114b863b7fff3c4cc5c554f1dde --- diff --git a/shader_glsl.h b/shader_glsl.h index 1833bdf3..d3b258de 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -1507,16 +1507,47 @@ "// vec2 ScreenTexCoord = gl_FragCoord.xy * PixelToScreenTexCoord;\n" " vec4 ScreenTexCoordStep = vec4(PixelToScreenTexCoord.x, 0.0, 0.0, PixelToScreenTexCoord.y);\n" " vec4 DepthNeighbors;\n" -" float DepthCenter = dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord).b;\n" -" DepthNeighbors.x = dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord - ScreenTexCoordStep.xy).b;\n" -" DepthNeighbors.y = dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + ScreenTexCoordStep.xy).b;\n" -" DepthNeighbors.z = dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + ScreenTexCoordStep.zw).b;\n" -" DepthNeighbors.w = dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord - ScreenTexCoordStep.zw).b;\n" -" float DepthAverage = dot(DepthNeighbors, vec4(0.25, 0.25, 0.25, 0.25));\n" -" float DepthDelta = abs(dot(DepthNeighbors.xy, vec2(-1.0, 1.0))) + abs(dot(DepthNeighbors.zw, vec2(-1.0, 1.0)));\n" +"\n" +" // enable to test ink on white geometry\n" "// color.rgb = vec3(1.0, 1.0, 1.0);\n" -" color.rgb *= max(0.25, 1.0 - max(0.0, abs(DepthCenter - DepthAverage) - 0.07 * DepthDelta) / (0.03 + 0.03 * DepthDelta));\n" -"// color.rgb *= step(abs(DepthCenter - DepthAverage), 0.2 * DepthDelta);\n" +"\n" +" // note: this seems to be negative\n" +" float DepthCenter = dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord).b;\n" +"\n" +" // edge detect method\n" +"// DepthNeighbors.x = dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord - ScreenTexCoordStep.xy).b;\n" +"// DepthNeighbors.y = dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + ScreenTexCoordStep.xy).b;\n" +"// DepthNeighbors.z = dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + ScreenTexCoordStep.zw).b;\n" +"// DepthNeighbors.w = dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord - ScreenTexCoordStep.zw).b;\n" +"// float DepthAverage = dot(DepthNeighbors, vec4(0.25, 0.25, 0.25, 0.25));\n" +"// float DepthDelta = abs(dot(DepthNeighbors.xy, vec2(-1.0, 1.0))) + abs(dot(DepthNeighbors.zw, vec2(-1.0, 1.0)));\n" +"// color.rgb *= max(0.5, 1.0 - max(0.0, abs(DepthCenter - DepthAverage) - 0.2 * DepthDelta) / (0.01 + 0.2 * DepthDelta));\n" +"// color.rgb *= step(abs(DepthCenter - DepthAverage), 0.2 * DepthDelta); \n" +"\n" +" // shadow method\n" +" float DepthScale1 = 4.0 / DepthCenter; // inner ink (shadow on object)\n" +"// float DepthScale1 = -4.0 / DepthCenter; // outer ink (shadow around object)\n" +"// float DepthScale1 = 0.003;\n" +" float DepthScale2 = DepthScale1 / 2.0;\n" +"// float DepthScale3 = DepthScale1 / 4.0;\n" +" float DepthBias1 = -DepthCenter * DepthScale1;\n" +" float DepthBias2 = -DepthCenter * DepthScale2;\n" +"// float DepthBias3 = -DepthCenter * DepthScale3;\n" +" float DepthShadow = max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2(-1.0, 0.0)).b * DepthScale1 + DepthBias1)\n" +" + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 1.0, 0.0)).b * DepthScale1 + DepthBias1)\n" +" + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 0.0, -1.0)).b * DepthScale1 + DepthBias1)\n" +" + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 0.0, 1.0)).b * DepthScale1 + DepthBias1)\n" +" + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2(-2.0, 0.0)).b * DepthScale2 + DepthBias2)\n" +" + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 2.0, 0.0)).b * DepthScale2 + DepthBias2)\n" +" + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 0.0, -2.0)).b * DepthScale2 + DepthBias2)\n" +" + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 0.0, 2.0)).b * DepthScale2 + DepthBias2)\n" +"// + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2(-3.0, 0.0)).b * DepthScale3 + DepthBias3)\n" +"// + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 3.0, 0.0)).b * DepthScale3 + DepthBias3)\n" +"// + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 0.0, -3.0)).b * DepthScale3 + DepthBias3)\n" +"// + max(0.0, dp_texture2D(Texture_ScreenNormalMap, ScreenTexCoord + PixelToScreenTexCoord * vec2( 0.0, 3.0)).b * DepthScale3 + DepthBias3)\n" +" - 0.0;\n" +" color.rgb *= 1.0 - max(0.0, min(DepthShadow, 1.0));\n" +"// color.r = DepthCenter / -1024.0;\n" "# endif\n" "#endif\n" "\n"