From 34690453e94ce3bf4f752699efd64f97686fc1d1 Mon Sep 17 00:00:00 2001 From: eihrul Date: Thu, 25 Feb 2010 16:12:37 +0000 Subject: [PATCH] attempting workaround for coord rounding incompatibilities between GL_ARB_texture_gather (nvidia) and GL_AMD_texture_texture4 (ati) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10004 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 1ba07e70..a233953d 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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" -- 2.39.2