]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
redesigned r_celoutlines shader code to be a shadowing method rather than edge detect...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 5 May 2012 21:24:08 +0000 (21:24 +0000)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 13 May 2012 19:17:45 +0000 (21:17 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11814 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=8e6c353f0e8e9114b863b7fff3c4cc5c554f1dde

shader_glsl.h

index 1833bdf30b37263f886e00cd81537f1c82ed4864..d3b258de8e033c699094524f680d8d8692ac523c 100644 (file)
 "//    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"