// this is a slighty modified version of the nvidia ocean.fx shader float4x4 worldMatrix : World; // World or Model matrix float4x4 wvpMatrix : WorldViewProjection; // Model*View*Projection float4x4 worldViewMatrix : WorldView; float4x4 viewInverseMatrix : ViewInverse; float time : Time; bool forRaytracer = false; float3 fSceneDimensions; texture normalMap : Normal; texture cubeMap : Environment; texture terrainTex; float FarPlaneMinusNearPlane; // Distance of the far plane minus distance of the near plane. sampler2D normalMapSampler = sampler_state { Texture = ; MagFilter = Linear; MinFilter = Linear; MipFilter = Linear; }; samplerCUBE envMapSampler = sampler_state { Texture = ; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = Clamp; AddressV = Clamp; }; sampler2D terrainSampler = sampler_state { Texture = ; minfilter = Linear; mipfilter = Linear; magfilter = Linear; addressu = BORDER; addressv = BORDER; addressw = BORDER; }; float bumpHeight = 0.5; float2 textureScale = {25.60, 12.80 }; float2 bumpSpeed = { -0.1, 0.1 }; float fresnelBias = 0.5; //float fresnelPower = 4.0; float fresnelPower = 12.0; float hdrMultiplier = 3.0; //float4 deepColor : Diffuse = {0.0f, 0.0f, 0.1f, 1.0f}; //float4 shallowColor : Diffuse = {0.0f, 0.5f, 0.5f, 1.0f}; float4 deepColor : Diffuse; float4 shallowColor : Diffuse; float4 reflectionColor : Specular = {0.5f, 0.5f, 0.5f, 1.0f}; float reflectionAmount = 1.0f; float waterAmount = 1.0f; float waveAmp = 0.0; float waveFreq = 0.1; struct a2v { float4 Position : POSITION; // in object space float2 TexCoord : TEXCOORD0; float2 terrainCoord : TEXCOORD1; float3 Tangent : TEXCOORD2; float3 Binormal : TEXCOORD3; float3 Normal : NORMAL; }; struct v2f { float4 Position : POSITION; // in clip space float2 TexCoord : TEXCOORD0; float3 TexCoord1 : TEXCOORD1; // first row of the 3x3 transform from tangent to cube space float3 TexCoord2 : TEXCOORD2; // second row of the 3x3 transform from tangent to cube space float3 TexCoord3 : TEXCOORD3; // third row of the 3x3 transform from tangent to cube space float2 bumpCoord0 : TEXCOORD4; float2 bumpCoord1 : TEXCOORD5; float2 bumpCoord2 : TEXCOORD6; float3 eyeVector : TEXCOORD7; float4 pos2 : COLOR0; float4 terrainCoord : COLOR1; }; struct v2fdepth { float4 HPosition : POSITION; float4 texCoord : TEXCOORD0; }; struct PS_OUTPUT { float4 diffuse : COLOR0; }; struct pixelOutput { float4 color : COLOR; }; struct depthVertexInput { float4 position : POSITION; float4 texCoord : TEXCOORD0; }; struct depthVertexOutput { float4 HPosition : POSITION; float4 texCoord : TEXCOORD0; }; // wave functions struct Wave { float freq; // 2*PI / wavelength float amp; // amplitude float phase; // speed * 2*PI / wavelength float2 dir; }; #define NWAVES 2 Wave wave[NWAVES] = { { 1.0, 1.0, 0.5, float2(-1, 0) }, { 2.0, 0.5, 1.3, float2(-0.7, 0.7) } }; float evaluateWave(Wave w, float2 pos, float t) { return w.amp * sin( dot(w.dir, pos)*w.freq + t*w.phase); } // derivative of wave function float evaluateWaveDeriv(Wave w, float2 pos, float t) { return w.freq*w.amp * cos( dot(w.dir, pos)*w.freq + t*w.phase); } v2f BumpReflectWaveVS(a2v IN, uniform float4x4 WorldViewProj, uniform float4x4 World, uniform float4x4 ViewIT, uniform float BumpScale, uniform float2 textureScale, uniform float2 bumpSpeed, uniform float time, uniform float waveFreq, uniform float waveAmp ) { v2f OUT; wave[0].freq = waveFreq; wave[0].amp = waveAmp; wave[1].freq = waveFreq*2.0; wave[1].amp = waveAmp*0.5; float4 P = IN.Position; // sum waves float ddx = 0.0, ddy = 0.0; for(int i=0; i