0001:
0002:
0003:
0004:
0005:
0006:
0007:
0008:
0009:
0010: float4x4 mWVP;
0011: float4 vEyePos;
0012:
0013:
0014:
0015:
0016: texture Tex;
0017: sampler TexSamp = sampler_state
0018: {
0019: Texture = <Tex>;
0020: MinFilter = POINT;
0021: MagFilter = POINT;
0022: MipFilter = NONE;
0023:
0024: AddressU = Clamp;
0025: AddressV = Clamp;
0026: };
0027: texture Color;
0028: sampler ColorSamp = sampler_state
0029: {
0030: Texture = <Color>;
0031: MinFilter = POINT;
0032: MagFilter = POINT;
0033: MipFilter = NONE;
0034:
0035: AddressU = Clamp;
0036: AddressV = Clamp;
0037: };
0038:
0039:
0040:
0041: struct VS_OUTPUT
0042: {
0043: float4 Pos : POSITION;
0044: float4 Tex : TEXCOORD0;
0045: float4 Eye : TEXCOORD1;
0046: float4 Normal : TEXCOORD2;
0047: };
0048:
0049:
0050:
0051:
0052: VS_OUTPUT VS (
0053: float4 Pos : POSITION
0054: , float4 Normal : NORMAL
0055: , float4 Tex : TEXCOORD0
0056: ){
0057: VS_OUTPUT Out = (VS_OUTPUT)0;
0058:
0059:
0060: Out.Pos = mul( Pos, mWVP );
0061:
0062:
0063: Out.Tex = Tex;
0064:
0065:
0066: Out.Eye = vEyePos - Pos;
0067: Out.Eye *= 0.2f/Out.Eye.z;
0068: Out.Eye.y = -Out.Eye.y;
0069:
0070:
0071: Out.Normal = Normal;
0072:
0073: return Out;
0074: }
0075:
0076:
0077:
0078: float4 PS( VS_OUTPUT In ) : COLOR
0079: {
0080: float4 O = (float4)0;
0081:
0082: float4 col;
0083: float4 num = 9.0f;
0084: float2 dt = (1.0f/(num-1))*(In.Eye.xyz);
0085: float dd = 1.0/num;
0086: float d = 1.0001 - dd;
0087: float2 uv = In.Tex.xy;
0088: float2 st = 0;
0089: bool ok = false;
0090:
0091: col = tex2D( TexSamp, uv );
0092: st = (d<col.x && !ok) ? uv : st;
0093: ok = (d<col.x) ? true : ok;
0094: uv += dt.xy;
0095: d -= dd;
0096:
0097: col = tex2D( TexSamp, uv );
0098: st = (d<col.x && !ok) ? uv : st;
0099: ok = (d<col.x) ? true : ok;
0100: uv += dt.xy;
0101: d -= dd;
0102:
0103: col = tex2D( TexSamp, uv );
0104: st = (d<col.x && !ok) ? uv : st;
0105: ok = (d<col.x) ? true : ok;
0106: uv += dt.xy;
0107: d -= dd;
0108:
0109: col = tex2D( TexSamp, uv );
0110: st = (d<col.x && !ok) ? uv : st;
0111: ok = (d<col.x) ? true : ok;
0112: uv += dt.xy;
0113: d -= dd;
0114:
0115: col = tex2D( TexSamp, uv );
0116: st = (d<col.x && !ok) ? uv : st;
0117: ok = (d<col.x) ? true : ok;
0118: uv += dt.xy;
0119: d -= dd;
0120:
0121: col = tex2D( TexSamp, uv );
0122: st = (d<col.x && !ok) ? uv : st;
0123: ok = (d<col.x) ? true : ok;
0124: uv += dt.xy;
0125: d -= dd;
0126:
0127: col = tex2D( TexSamp, uv );
0128: st = (d<col.x && !ok) ? uv : st;
0129: ok = (d<col.x) ? true : ok;
0130: uv += dt.xy;
0131: d -= dd;
0132:
0133: col = tex2D( TexSamp, uv );
0134: st = (d<col.x && !ok) ? uv : st;
0135: ok = (d<col.x) ? true : ok;
0136: uv += dt.xy;
0137: d -= dd;
0138:
0139: col = tex2D( TexSamp, uv );
0140: st = (d<col.x && !ok) ? uv : st;
0141: ok = (d<col.x) ? true : ok;
0142:
0143: O = (ok)?tex2D( ColorSamp, st):0.0f;
0144:
0145: return O;
0146: }
0147:
0148:
0149:
0150: technique TShader
0151: {
0152: pass P0
0153: {
0154:
0155: Sampler[0] = (TexSamp);
0156: Sampler[1] = (ColorSamp);
0157:
0158:
0159: VertexShader = compile vs_1_1 VS();
0160: PixelShader = compile ps_2_0 PS();
0161:
0162: Cullmode=None;
0163:
0164: #if 1
0165: AlphaBlendEnable = True;
0166: SrcBlend = SRCALPHA;
0167: DestBlend = INVSrcALPHA;
0168: #endif
0169: }
0170: }
0171: