]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
attempting workaround for coord rounding incompatibilities between GL_ARB_texture_gat...
authoreihrul <eihrul@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 25 Feb 2010 16:12:37 +0000 (16:12 +0000)
committereihrul <eihrul@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 25 Feb 2010 16:12:37 +0000 (16:12 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10004 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c

index 1ba07e7079df53a116fe8177775f73fb2ff0f4e5..a233953df12ad10d58ef8936ed017843c65e2991 100644 (file)
@@ -1162,12 +1162,12 @@ static const char *builtinshaderstring =
 "#      else\n"
 "#        define texval(x, y) texture4(Texture_ShadowMap2D, center + vec2(x, y)*ShadowMap_TextureScale)\n"
 "#      endif\n"
-"      vec2 center = shadowmaptc.xy - 0.5, offset = fract(center);\n"
-"      center *= ShadowMap_TextureScale;\n"
-"      vec4 group1 = step(shadowmaptc.z, texval(-1.0, -1.0));\n"
-"      vec4 group2 = step(shadowmaptc.z, texval( 1.0, -1.0));\n"
-"      vec4 group3 = step(shadowmaptc.z, texval(-1.0,  1.0));\n"
-"      vec4 group4 = step(shadowmaptc.z, texval( 1.0,  1.0));\n"
+"      vec2 center = shadowmaptc.xy - 1.5, offset = fract(center);\n"
+"      center = (center - offset)*ShadowMap_TextureScale;\n"
+"      vec4 group1 = step(shadowmaptc.z, texval(0.0, 0.0));\n"
+"      vec4 group2 = step(shadowmaptc.z, texval(2.0, 0.0));\n"
+"      vec4 group3 = step(shadowmaptc.z, texval(0.0, 2.0));\n"
+"      vec4 group4 = step(shadowmaptc.z, texval(2.0, 2.0));\n"
 "      vec4 cols = vec4(group1.rg, group2.rg) + vec4(group3.ab, group4.ab) +\n"
 "                              mix(vec4(group1.ab, group2.ab), vec4(group3.rg, group4.rg), offset.y);\n"
 "      f = dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));\n"
@@ -2297,16 +2297,16 @@ const char *builtincgshaderstring =
 "#    ifdef USESHADOWMAPPCF\n"
 "#     if defined(GL_ARB_texture_gather) || defined(GL_AMD_texture_texture4)\n"
 "#      ifdef GL_ARB_texture_gather\n"
-"#        define texval(x, y) textureGatherOffset(Texture_ShadowMap2D, center, ivec(x, y))\n"
+"#        define texval(x, y) textureGatherOffset(Texture_ShadowMap2D, center, ivec2(x, y))\n"
 "#      else\n"
-"#        define texval(x, y) texture4(Texture_ShadowMap2D, center + float2(x,y)*ShadowMap_TextureScale)\n"
+"#        define texval(x, y) texture4(Texture_ShadowMap2D, center + float2(x, y)*ShadowMap_TextureScale)\n"
 "#      endif\n"
-"    float2 center = shadowmaptc.xy - 0.5, offset = frac(center);\n"
-"    center *= ShadowMap_TextureScale;\n"
-"    float4 group1 = step(shadowmaptc.z, texval(-1.0, -1.0));\n"
-"    float4 group2 = step(shadowmaptc.z, texval( 1.0, -1.0));\n"
-"    float4 group3 = step(shadowmaptc.z, texval(-1.0,  1.0));\n"
-"    float4 group4 = step(shadowmaptc.z, texval( 1.0,  1.0));\n"
+"    float2 center = shadowmaptc.xy - 1.5, offset = fract(center);\n"
+"    center = (center - offset)*ShadowMap_TextureScale;\n"
+"    float4 group1 = step(shadowmaptc.z, texval(0.0, 0.0));\n"
+"    float4 group2 = step(shadowmaptc.z, texval(2.0, 0.0));\n"
+"    float4 group3 = step(shadowmaptc.z, texval(0.0, 2.0));\n"
+"    float4 group4 = step(shadowmaptc.z, texval(2.0, 2.0));\n"
 "    float4 cols = float4(group1.rg, group2.rg) + float4(group3.ab, group4.ab) +\n"
 "                lerp(float4(group1.ab, group2.ab), float4(group3.rg, group4.rg), offset.y);\n"
 "    f = dot(lerp(cols.xyz, cols.yzw, offset.x), float3(1.0/9.0));\n"