forked from mirrors/0ad
eihrul's shadow filter patch, fixes ticket #1738.
This was SVN commit r12929.
This commit is contained in:
@@ -94,16 +94,10 @@ TEX tex, v_tex, texture[0], 2D;
|
||||
FRC offset.xy, offset;
|
||||
ADD size.xy, offset, 1.0;
|
||||
SUB size.zw, 2.0, offset.xyxy;
|
||||
RCP weight.x, size.x;
|
||||
RCP weight.y, size.y;
|
||||
RCP weight.z, size.z;
|
||||
RCP weight.w, size.w;
|
||||
SUB weight.xy, 2.0, weight;
|
||||
SUB weight.zw, weight, 1.0;
|
||||
|
||||
SUB offset.xy, v_shadow, offset;
|
||||
MAD offset.xy, -0.5, offset, v_shadow;
|
||||
MOV offset.z, biasedShdw.z;
|
||||
ADD weight, weight, offset.xyxy;
|
||||
ADD weight, { 1.0, 1.0, -0.5, -0.5 }, offset.xyxy;
|
||||
MUL weight, weight, shadowScale.zwzw;
|
||||
|
||||
MOV offset.xy, weight.zwww;
|
||||
|
||||
@@ -48,16 +48,10 @@ TEX color, fragment.texcoord[0], texture[0], 2D;
|
||||
FRC offset.xy, offset;
|
||||
ADD size.xy, offset, 1.0;
|
||||
SUB size.zw, 2.0, offset.xyxy;
|
||||
RCP weight.x, size.x;
|
||||
RCP weight.y, size.y;
|
||||
RCP weight.z, size.z;
|
||||
RCP weight.w, size.w;
|
||||
SUB weight.xy, 2.0, weight;
|
||||
SUB weight.zw, weight, 1.0;
|
||||
|
||||
SUB offset.xy, fragment.texcoord[2], offset;
|
||||
MOV offset.z, biasedShdw;
|
||||
ADD weight, weight, offset.xyxy;
|
||||
MAD offset.xy, -0.5, offset, fragment.texcoord[2];
|
||||
MOV offset.z, biasedShdw.z;
|
||||
ADD weight, { 1.0, 1.0, -0.5, -0.5 }, offset.xyxy;
|
||||
MUL weight, weight, shadowScale.zwzw;
|
||||
|
||||
MOV offset.xy, weight.zwww;
|
||||
|
||||
@@ -74,7 +74,7 @@ float get_shadow()
|
||||
#if USE_SHADOW_PCF
|
||||
vec2 offset = fract(v_shadow.xy - 0.5);
|
||||
vec4 size = vec4(offset + 1.0, 2.0 - offset);
|
||||
vec4 weight = (vec4(2.0 - 1.0 / size.xy, 1.0 / size.zw - 1.0) + (v_shadow.xy - offset).xyxy) * shadowScale.zwzw;
|
||||
vec4 weight = (vec4(1.0, 1.0, -0.5, -0.5) + (v_shadow.xy - 0.5*offset).xyxy) * shadowScale.zwzw;
|
||||
return (1.0/9.0)*dot(size.zxzx*size.wwyy,
|
||||
vec4(shadow2D(shadowTex, vec3(weight.zw, biasedShdwZ)).r,
|
||||
shadow2D(shadowTex, vec3(weight.xw, biasedShdwZ)).r,
|
||||
|
||||
@@ -61,7 +61,7 @@ float get_shadow(vec4 coords)
|
||||
#if USE_SHADOW_PCF
|
||||
vec2 offset = fract(coords.xy - 0.5);
|
||||
vec4 size = vec4(offset + 1.0, 2.0 - offset);
|
||||
vec4 weight = (vec4(2.0 - 1.0 / size.xy, 1.0 / size.zw - 1.0) + (coords.xy - offset).xyxy) * shadowScale.zwzw;
|
||||
vec4 weight = (vec4(1.0, 1.0, -0.5, -0.5) + (coords.xy - 0.5*offset).xyxy) * shadowScale.zwzw;
|
||||
return (1.0/9.0)*dot(size.zxzx*size.wwyy,
|
||||
vec4(shadow2D(shadowTex, vec3(weight.zw, coords.z)).r,
|
||||
shadow2D(shadowTex, vec3(weight.xw, coords.z)).r,
|
||||
|
||||
@@ -41,7 +41,7 @@ float get_shadow()
|
||||
#if USE_SHADOW_PCF
|
||||
vec2 offset = fract(v_shadow.xy - 0.5);
|
||||
vec4 size = vec4(offset + 1.0, 2.0 - offset);
|
||||
vec4 weight = (vec4(2.0 - 1.0 / size.xy, 1.0 / size.zw - 1.0) + (v_shadow.xy - offset).xyxy) * shadowScale.zwzw;
|
||||
vec4 weight = (vec4(1.0, 1.0, -0.5, -0.5) + (v_shadow.xy - 0.5*offset).xyxy) * shadowScale.zwzw;
|
||||
return (1.0/9.0)*dot(size.zxzx*size.wwyy,
|
||||
vec4(shadow2D(shadowTex, vec3(weight.zw, v_shadow.z)).r,
|
||||
shadow2D(shadowTex, vec3(weight.xw, v_shadow.z)).r,
|
||||
|
||||
@@ -76,7 +76,7 @@ float get_shadow()
|
||||
#if USE_SHADOW_PCF
|
||||
vec2 offset = fract(v_shadow.xy - 0.5);
|
||||
vec4 size = vec4(offset + 1.0, 2.0 - offset);
|
||||
vec4 weight = (vec4(2.0 - 1.0 / size.xy, 1.0 / size.zw - 1.0) + (v_shadow.xy - offset).xyxy) * shadowScale.zwzw;
|
||||
vec4 weight = (vec4(1.0, 1.0, -0.5, -0.5) + (v_shadow.xy - 0.5*offset).xyxy) * shadowScale.zwzw;
|
||||
return (1.0/9.0)*dot(size.zxzx*size.wwyy,
|
||||
vec4(shadow2D(shadowTex, vec3(weight.zw, biasedShdwZ)).r,
|
||||
shadow2D(shadowTex, vec3(weight.xw, biasedShdwZ)).r,
|
||||
|
||||
@@ -58,7 +58,7 @@ uniform sampler2D normalMap2;
|
||||
#if USE_SHADOW_PCF
|
||||
vec2 offset = fract(coords.xy - 0.5);
|
||||
vec4 size = vec4(offset + 1.0, 2.0 - offset);
|
||||
vec4 weight = (vec4(2.0 - 1.0 / size.xy, 1.0 / size.zw - 1.0) + (coords.xy - offset).xyxy) * shadowScale.zwzw;
|
||||
vec4 weight = (vec4(1.0, 1.0, -0.5, -0.5) + (coords.xy - 0.5*offset).xyxy) * shadowScale.zwzw;
|
||||
return (1.0/9.0)*dot(size.zxzx*size.wwyy,
|
||||
vec4(shadow2D(shadowTex, vec3(weight.zw, coords.z)).r,
|
||||
shadow2D(shadowTex, vec3(weight.xw, coords.z)).r,
|
||||
|
||||
Reference in New Issue
Block a user