0001:
0002:
0003:
0004:
0005:
0006:
0007:
0008:
0009:
0010: float4x4 mWVP;
0011: float4 vVector;
0012:
0013: texture DecaleMap;
0014: sampler DecaleSamp = sampler_state
0015: {
0016: Texture = <DecaleMap>;
0017: MinFilter = LINEAR;
0018: MagFilter = LINEAR;
0019: MipFilter = NONE;
0020:
0021: AddressU = Clamp;
0022: AddressV = Clamp;
0023: };
0024: texture ParticleMap;
0025: sampler ParticleSamp = sampler_state
0026: {
0027: Texture = <ParticleMap>;
0028: MinFilter = POINT;
0029: MagFilter = POINT;
0030: MipFilter = NONE;
0031:
0032: AddressU = Clamp;
0033: AddressV = Clamp;
0034: };
0035:
0036:
0037:
0038:
0039: struct VS_OUTPUT
0040: {
0041: float4 Pos : POSITION;
0042: float4 Color : COLOR0;
0043: };
0044:
0045: struct INIT_VS_OUTPUT
0046: {
0047: float4 Pos : POSITION;
0048: };
0049:
0050: struct PARTICLE_VS_OUTPUT
0051: {
0052: float4 Pos : POSITION;
0053: float2 x : TEXCOORD0;
0054: float2 dx : TEXCOORD1;
0055: };
0056:
0057: struct REFLECT_VS_OUTPUT
0058: {
0059: float4 Pos : POSITION;
0060: float2 x : TEXCOORD0;
0061: float2 v : TEXCOORD1;
0062: };
0063:
0064:
0065:
0066:
0067:
0068:
0069:
0070: VertexShader DisplacementVS = asm
0071: {
0072: vs_1_1
0073:
0074: dcl_position0 v0
0075: dcl_normal0 v1
0076: dcl_texcoord0 v2
0077: dcl_sample0 v3
0078:
0079: def c12, 0.0f ,0.5f, 1.0f, 2.0f
0080:
0081: mad r0, v3, c12.w, -c12.z
0082: add r0, v0, r0
0083: mov r0.w, v0.w
0084: m4x4 oPos, r0, c0
0085:
0086: mov oT0, v2
0087: };
0088:
0089: PIXELSHADER DisplacementPS = asm
0090: {
0091: ps.1.1
0092:
0093: tex t0
0094:
0095: mov r0, t0
0096: };
0097:
0098:
0099:
0100: INIT_VS_OUTPUT InitVS (
0101: float4 Pos : POSITION
0102: ){
0103: INIT_VS_OUTPUT Out = (INIT_VS_OUTPUT)0;
0104:
0105: Out.Pos = Pos;
0106:
0107: return Out;
0108: }
0109:
0110: float4 InitPS(INIT_VS_OUTPUT In) : COLOR
0111: {
0112: return vVector;
0113: }
0114:
0115:
0116:
0117:
0118:
0119: float4 ParticlePS(PARTICLE_VS_OUTPUT In) : COLOR
0120: {
0121: float4 Color;
0122:
0123: Color = tex2D( ParticleSamp, In.x )
0124: + tex2D( ParticleSamp, In.dx )
0125: - 0.502;
0126: return Color;
0127: }
0128:
0129:
0130:
0131:
0132:
0133: float4 ReflectVPS ( REFLECT_VS_OUTPUT In ) : COLOR0
0134: {
0135: float4 x = 2.0f*tex2D( ParticleSamp, In.x )-1.0f;
0136: float4 v = 2.0f*tex2D( ParticleSamp, In.v )-1.0f;
0137:
0138: if(x.x<-1.0f || +1.0f<x.x) v.x = -v.x;
0139: if(x.y<-1.0f || +1.0f<x.y) v.y = -0.8f*v.y;
0140: if(x.z<-1.0f || +1.0f<x.z) v.z = -v.z;
0141:
0142: return 0.5f*v + 0.5f;
0143: }
0144:
0145:
0146:
0147: float4 ReflectXPS ( REFLECT_VS_OUTPUT In ) : COLOR0
0148: {
0149: float4 x = 2.0f*tex2D( ParticleSamp, In.x )-1.0f;
0150: float4 v = 2.0f*tex2D( ParticleSamp, In.v )-1.0f;
0151:
0152: if(x.x<-1.0f) x.x = -1.0f; else
0153: if(+1.0f<x.x) x.x = +1.0f;
0154: if(x.y<-1.0f) x.y = -1.0f; else
0155: if(+1.0f<x.y) x.y = +1.0f;
0156: if(x.z<-1.0f) x.z = -1.0f; else
0157: if(+1.0f<x.z) x.z = +1.0f;
0158:
0159: return 0.5f*x + 0.5f;
0160: }
0161:
0162:
0163:
0164:
0165: technique TShader
0166: {
0167: pass P0
0168: {
0169:
0170: VertexShader = <DisplacementVS>;
0171: PixelShader = <DisplacementPS>;
0172:
0173: VertexShaderConstantF[0] = (mWVP);
0174:
0175: Sampler[0] = (DecaleSamp);
0176: }
0177: pass P1
0178: {
0179:
0180: VertexShader = compile vs_1_1 InitVS();
0181: PixelShader = compile ps_1_1 InitPS();
0182: }
0183: pass P2
0184: {
0185:
0186: PixelShader = compile ps_2_0 ParticlePS();
0187: }
0188: pass P3
0189: {
0190:
0191: PixelShader = compile ps_2_0 ReflectVPS();
0192: }
0193: pass P4
0194: {
0195:
0196: PixelShader = compile ps_2_0 ReflectXPS();
0197: }
0198:
0199: }
0200: