float4x4 World : WORLD; float4x4 View : VIEW; float4x4 Projection : PROJECTION; //float4x4 WorldViewProj: WORLDVIEWPROJ; float4x4 WorldView : WORLDVIEW; float4 viewPosition: VIEWPOSITION; float screenTexCoordScale ; // adjust by Browser.windowAspect float fraction ; // for water animation float disturbingScale ; // tweakables texture normalTexture : normalTexture< string UIName = "Normal Texture"; >; texture reflectionTexture : reflectionTexture< >; texture refractionTexture : refractionTexture< >; texture skyCubeTexture : skyCubeTexture< >; texture fresnelTable : fresnelTable< >; struct VS_OUTPUT { float4 oPos : POSITION; float3 oNormalTexCoord :TEXCOORD0; float3 oScreenTexCoord :TEXCOORD1; float3 oViewVec :TEXCOORD2; float3 oNormal :TEXCOORD3; }; VS_OUTPUT VS( float3 Pos : POSITION, float3 NormalTexCoord :TEXCOORD0, float3 ScreenTexCoord :TEXCOORD1, float3 Norm :NORMAL ) { VS_OUTPUT Out = (VS_OUTPUT)0; Out.oNormalTexCoord = NormalTexCoord ; Out.oNormal = float3 (0,1,0);//Norm ; Out.oScreenTexCoord.x = - ScreenTexCoord.x/screenTexCoordScale /2 ; // Out.oScreenTexCoord.y = ScreenTexCoord.y/screenTexCoordScale /2 ; Out.oScreenTexCoord.y = -ScreenTexCoord.y/screenTexCoordScale /2 ;//for debug texture flip bug in BS Contact 6.207 Out.oScreenTexCoord.z = ScreenTexCoord.z ; Out.oViewVec = normalize(Pos.xyz - viewPosition.xyz/viewPosition.w); float3 P = mul(float4(Pos, 1),(float4x4)WorldView); // position (view space) Out.oPos = mul(float4(P,1),Projection); return Out; } sampler reflmap = sampler_state { texture = ; MipFilter = NONE; // MINFILTER = LINEAR; // MAGFILTER = LINEAR; MinFilter = POINT; MagFilter = POINT; AddressU = CLAMP; AddressV = CLAMP; }; sampler refrmap = sampler_state { texture = ; MinFilter = LINEAR; MagFilter = LINEAR; AddressU = CLAMP; AddressV = CLAMP; }; sampler skyCube = sampler_state { texture = ; MINFILTER = LINEAR; MAGFILTER = LINEAR; }; sampler nmap = sampler_state { texture = ; AddressU = WRAP; AddressV = WRAP; MIPFILTER = POINT;//LINEAR; // MINFILTER = LINEAR; MAGFILTER = LINEAR; }; sampler fresnel= sampler_state { texture = ; MipFilter = NONE; MinFilter = LINEAR; MagFilter = LINEAR; AddressU = MIRROR; AddressV = MIRROR; }; float4 PS( float3 NormalTexCoord : TEXCOORD0 , float3 ScreenTexCoord : TEXCOORD1 , float3 ViewVec : TEXCOORD2 , float3 Norm : TEXCOORD3 ) : COLOR { float2 NormalTexCoordTemp; NormalTexCoordTemp.xy = NormalTexCoord.xy + fraction; float4 normalAnimMapColor = tex2D(nmap, NormalTexCoordTemp); //fetch normal from normalMap NormalTexCoordTemp.x = NormalTexCoord.x - fraction; NormalTexCoordTemp.y = NormalTexCoord.y + 0.1; //fetch and add normal from same normalMap but another direction normalAnimMapColor.rg = (normalAnimMapColor.rg + tex2D(nmap, NormalTexCoordTemp) -1 ) * 2; normalAnimMapColor.b = 1; float3 reflVec = normalize( reflect(ViewVec, normalAnimMapColor.rgb )); float4 sky = texCUBE(skyCube, reflVec.xyz); float f = tex1D(fresnel,dot(reflVec,Norm)); //ScreenTexCoord.y = -ScreenTexCoord.y ;//for debug texture flip bug in BS Contact 6.207 float4 refl = tex2D(reflmap, ScreenTexCoord.xy /ScreenTexCoord.z + 0.5 - normalAnimMapColor.rg * disturbingScale) ; refl =max (0, pow(sky.g,8)-0.5)+ lerp(sky, refl,refl.a);// float4 refr = tex2D(refrmap, ScreenTexCoord.xy /ScreenTexCoord.z + 0.5 + normalAnimMapColor.rg * disturbingScale) ; return lerp(refr,refl, f); } technique WaterRTT { pass P0 { // CullMode = None; // CullMode = CW; // CullMode = D3DCULL_CCW; VertexShader = compile vs_2_0 VS(); PixelShader = compile ps_2_0 PS(); //ZWriteEnable = false; //CullMode = None; // NormalizeNormals = true; // LocalViewer = true; // SrcBlend = SrcAlpha; // DestBlend = InvSrcAlpha; // AlphaBlendEnable = true; // ZWRITEENABLE = TRUE; //// SRCBLEND = SRCALPHA; //// DESTBLEND = INVSRCALPHA; // CULLMODE = CCW; //// ALPHABLENDENABLE = TRUE; } }