From e3a883b6057a6bf3e4105e2f127576a5142a73cc Mon Sep 17 00:00:00 2001 From: eihrul Date: Sat, 27 Feb 2010 02:04:38 +0000 Subject: [PATCH] added 6x6 pcf option for people with too much framerate git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10016 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 376db83f..b1df2d9d 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1163,6 +1163,27 @@ static const char *builtinshaderstring = "# define texval(x, y) texture4(Texture_ShadowMap2D, center + vec2(x, y)*ShadowMap_TextureScale)\n" "# endif\n" " vec2 offset = fract(shadowmaptc.xy - 0.5), center = (shadowmaptc.xy - offset)*ShadowMap_TextureScale;\n" +"# if USESHADOWMAPPCF > 1\n" +" vec4 group1 = step(shadowmaptc.z, texval(-2.0, -2.0));\n" +" vec4 group2 = step(shadowmaptc.z, texval( 0.0, -2.0));\n" +" vec4 group3 = step(shadowmaptc.z, texval( 2.0, -2.0));\n" +" vec4 group4 = step(shadowmaptc.z, texval(-2.0, 0.0));\n" +" vec4 group5 = step(shadowmaptc.z, texval( 0.0, 0.0));\n" +" vec4 group6 = step(shadowmaptc.z, texval( 2.0, 0.0));\n" +" vec4 group7 = step(shadowmaptc.z, texval(-2.0, 2.0));\n" +" vec4 group8 = step(shadowmaptc.z, texval( 0.0, 2.0));\n" +" vec4 group9 = step(shadowmaptc.z, texval( 2.0, 2.0));\n" +" vec4 locols = vec4(group1.ab, group3.ab);\n" +" vec4 hicols = vec4(group7.rg, group9.rg);\n" +" locols.yz += group2.ab;\n" +" hicols.yz += group8.rg;\n" +" vec4 midcols = vec4(group1.rg, group3.rg) + vec4(group7.ab, group9.ab) +\n" +" vec4(group4.rg, group6.rg) + vec4(group4.ab, group6.ab) +\n" +" mix(locols, hicols, offset.y);\n" +" vec4 cols = group5 + vec4(group2.rg, group8.ab);\n" +" cols.xyz += mix(midcols.xyz, midcols.yzw, offset.x);\n" +" f = dot(cols, vec4(1.0/25.0));\n" +"# else\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" @@ -1170,6 +1191,7 @@ static const char *builtinshaderstring = " 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" +"# endif\n" "# else\n" "# ifdef GL_EXT_gpu_shader4\n" "# define texval(x, y) texture2DOffset(Texture_ShadowMap2D, center, ivec2(x, y)).r\n" @@ -2300,14 +2322,36 @@ const char *builtincgshaderstring = "# else\n" "# define texval(x, y) texture4(Texture_ShadowMap2D, center + float2(x, y)*ShadowMap_TextureScale)\n" "# endif\n" -" float2 offset = fract(shadowmaptc.xy - 0.5), center = (shadowmaptc.xy - offset)*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" -" 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" +" float2 offset = frac(shadowmaptc.xy - 0.5), center = (shadowmaptc.xy - offset)*ShadowMap_TextureScale;\n" +"# if USESHADOWMAPPCF > 1\n" +" float4 group1 = step(shadowmaptc.z, texval(-2.0, -2.0));\n" +" float4 group2 = step(shadowmaptc.z, texval( 0.0, -2.0));\n" +" float4 group3 = step(shadowmaptc.z, texval( 2.0, -2.0));\n" +" float4 group4 = step(shadowmaptc.z, texval(-2.0, 0.0));\n" +" float4 group5 = step(shadowmaptc.z, texval( 0.0, 0.0));\n" +" float4 group6 = step(shadowmaptc.z, texval( 2.0, 0.0));\n" +" float4 group7 = step(shadowmaptc.z, texval(-2.0, 2.0));\n" +" float4 group8 = step(shadowmaptc.z, texval( 0.0, 2.0));\n" +" float4 group9 = step(shadowmaptc.z, texval( 2.0, 2.0));\n" +" float4 locols = float4(group1.ab, group3.ab);\n" +" float4 hicols = float4(group7.rg, group9.rg);\n" +" locols.yz += group2.ab;\n" +" hicols.yz += group8.rg;\n" +" float4 midcols = float4(group1.rg, group3.rg) + float4(group7.ab, group9.ab) +\n" +" float4(group4.rg, group6.rg) + float4(group4.ab, group6.ab) +\n" +" lerp(locols, hicols, offset.y);\n" +" float4 cols = group5 + float4(group2.rg, group8.ab);\n" +" cols.xyz += lerp(midcols.xyz, midcols.yzw, offset.x);\n" +" f = dot(cols, float4(1.0/25.0));\n" +"# else\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" +" 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" +"# endif\n" "# else\n" "# define texval(x, y) texDepth2D(Texture_ShadowMap2D, center + float2(x, y)*ShadowMap_TextureScale) \n" "# if USESHADOWMAPPCF > 1\n" -- 2.39.2