0001:
0002:
0003:
0004:
0005:
0006:
0007:
0008:
0009:
0010: float4x4 mWVP;
0011: float4 vCol;
0012: float4 vLightDir;
0013:
0014:
0015:
0016:
0017: texture SrcTex;
0018: sampler SrcSamp = sampler_state
0019: {
0020: Texture = <SrcTex>;
0021: MinFilter = LINEAR;
0022: MagFilter = LINEAR;
0023: MipFilter = NONE;
0024:
0025: AddressU = Clamp;
0026: AddressV = Clamp;
0027: };
0028:
0029: texture CoverTex0;
0030: sampler CoverSamp0 = sampler_state
0031: {
0032: Texture = <CoverTex0>;
0033: MinFilter = LINEAR;
0034: MagFilter = LINEAR;
0035: MipFilter = NONE;
0036:
0037: AddressU = Wrap;
0038: AddressV = Wrap;
0039: };
0040:
0041: texture CoverTex1;
0042: sampler CoverSamp1 = sampler_state
0043: {
0044: Texture = <CoverTex1>;
0045: MinFilter = LINEAR;
0046: MagFilter = LINEAR;
0047: MipFilter = NONE;
0048:
0049: AddressU = Wrap;
0050: AddressV = Wrap;
0051: };
0052:
0053: texture CoverTex2;
0054: sampler CoverSamp2 = sampler_state
0055: {
0056: Texture = <CoverTex2>;
0057: MinFilter = LINEAR;
0058: MagFilter = LINEAR;
0059: MipFilter = NONE;
0060:
0061: AddressU = Wrap;
0062: AddressV = Wrap;
0063: };
0064:
0065: texture CoverTex3;
0066: sampler CoverSamp3 = sampler_state
0067: {
0068: Texture = <CoverTex3>;
0069: MinFilter = LINEAR;
0070: MagFilter = LINEAR;
0071: MipFilter = NONE;
0072:
0073: AddressU = Wrap;
0074: AddressV = Wrap;
0075: };
0076:
0077: texture CoverTex4;
0078: sampler CoverSamp4 = sampler_state
0079: {
0080: Texture = <CoverTex4>;
0081: MinFilter = LINEAR;
0082: MagFilter = LINEAR;
0083: MipFilter = NONE;
0084:
0085: AddressU = Wrap;
0086: AddressV = Wrap;
0087: };
0088:
0089: texture CoverTex5;
0090: sampler CoverSamp5 = sampler_state
0091: {
0092: Texture = <CoverTex5>;
0093: MinFilter = LINEAR;
0094: MagFilter = LINEAR;
0095: MipFilter = NONE;
0096:
0097: AddressU = Wrap;
0098: AddressV = Wrap;
0099: };
0100:
0101: texture CoverTex6;
0102: sampler CoverSamp6 = sampler_state
0103: {
0104: Texture = <CoverTex6>;
0105: MinFilter = LINEAR;
0106: MagFilter = LINEAR;
0107: MipFilter = NONE;
0108:
0109: AddressU = Wrap;
0110: AddressV = Wrap;
0111: };
0112:
0113: texture CoverTex7;
0114: sampler CoverSamp7 = sampler_state
0115: {
0116: Texture = <CoverTex7>;
0117: MinFilter = LINEAR;
0118: MagFilter = LINEAR;
0119: MipFilter = NONE;
0120:
0121: AddressU = Wrap;
0122: AddressV = Wrap;
0123: };
0124:
0125:
0126:
0127: struct VS_OUTPUT
0128: {
0129: float4 Pos : POSITION;
0130: float4 Color : COLOR0;
0131: float2 Tex0 : TEXCOORD0;
0132: float2 Tex1 : TEXCOORD1;
0133: };
0134:
0135:
0136:
0137:
0138: VS_OUTPUT VS (
0139: float4 Pos : POSITION
0140: ,float4 Normal : NORMAL
0141: ,float4 Tex0 : TEXCOORD0
0142: ){
0143: VS_OUTPUT Out = (VS_OUTPUT)0;
0144:
0145: float4 pos = mul( Pos, mWVP );
0146:
0147:
0148: Out.Pos = pos;
0149:
0150: Out.Tex0 = Tex0;
0151:
0152: return Out;
0153: }
0154:
0155:
0156:
0157: float4 vWeight[8];
0158: float4 PS (VS_OUTPUT In) : COLOR
0159: {
0160: float4 Out;
0161:
0162:
0163: float Cover = dot(vWeight[0], tex2D( CoverSamp0, In.Tex0 ));
0164: Cover+= dot(vWeight[1], tex2D( CoverSamp1, In.Tex0 ));
0165: Cover+= dot(vWeight[2], tex2D( CoverSamp2, In.Tex0 ));
0166: Cover+= dot(vWeight[3], tex2D( CoverSamp3, In.Tex0 ));
0167: Cover+= dot(vWeight[4], tex2D( CoverSamp4, In.Tex0 ));
0168: Cover+= dot(vWeight[5], tex2D( CoverSamp5, In.Tex0 ));
0169: Cover+= dot(vWeight[6], tex2D( CoverSamp6, In.Tex0 ));
0170: Cover+= dot(vWeight[7], tex2D( CoverSamp7, In.Tex0 ));
0171:
0172: Cover = (Cover<0.3)?1:(1-5.0f*(Cover-0.3));
0173: if(Cover<0) Cover=0;
0174:
0175:
0176: Out = tex2D( SrcSamp, In.Tex0 ) *(Cover+0.3f);
0177:
0178: return Out;
0179: }
0180:
0181:
0182:
0183: VS_OUTPUT VS_Height (
0184: float4 Pos : POSITION
0185: , float4 Normal : NORMAL
0186: , float4 Tex0 : TEXCOORD0
0187: ){
0188: VS_OUTPUT Out = (VS_OUTPUT)0;
0189:
0190: float4 pos = mul( Pos, mWVP );
0191:
0192:
0193: Out.Pos = 2.0 * Tex0 - 1.0;
0194: Out.Pos.y *= -1;
0195: Out.Pos.z = 0.5;
0196: Out.Pos.w = 1;
0197:
0198:
0199: Out.Color = Pos.y;
0200:
0201: return Out;
0202: }
0203:
0204:
0205:
0206:
0207: float4 PS_Height (VS_OUTPUT In) : COLOR
0208: {
0209: float4 Out;
0210:
0211:
0212: Out = In.Color;
0213:
0214: return Out;
0215: }
0216:
0217:
0218:
0219: float4 vOffset;
0220: VS_OUTPUT VS_Cover (
0221: float4 Pos : POSITION
0222: , float2 Tex0 : TEXCOORD0
0223: ){
0224: VS_OUTPUT Out = (VS_OUTPUT)0;
0225:
0226:
0227: Out.Pos = Pos;
0228:
0229:
0230: Out.Tex0 = Tex0;
0231: Out.Tex1 = Tex0+vOffset.xy;
0232:
0233: return Out;
0234: }
0235:
0236:
0237:
0238:
0239: float fRayHeight;
0240: float4 PS_Cover(VS_OUTPUT In) : COLOR
0241: {
0242: float4 Out;
0243:
0244: float4 center = tex2D( SrcSamp, In.Tex0 );
0245: float4 offset = tex2D( SrcSamp, In.Tex1 );
0246:
0247: Out = (offset-center)/fRayHeight;
0248:
0249: return Out;
0250: }
0251:
0252:
0253:
0254:
0255: technique TShader
0256: {
0257: pass P0
0258: {
0259: VertexShader = compile vs_1_1 VS_Height();
0260: PixelShader = compile ps_2_0 PS_Height();
0261: }
0262: pass P1
0263: {
0264: VertexShader = compile vs_1_1 VS_Cover();
0265: PixelShader = compile ps_2_0 PS_Cover();
0266: }
0267: pass P2
0268: {
0269: VertexShader = compile vs_1_1 VS();
0270: PixelShader = compile ps_2_0 PS();
0271: }
0272: }
0273: