/*============================================================================= OfWaterVertexFactory.cg: for grid water rendering Copyright UbiSoft, Inc. All Rights Reserved. =============================================================================*/ float4 CornerPoint00; float4 CornerPoint10; float4 CornerPoint01; float4 CornerPoint11; float InvTillSize; float EnableWaterMaterial; float ReflectionDistortionStrength; float RefractionDistortionStrength; #define HEIGHT_TEXTURE_SIZE 128.0f #define VERTEX_HEIGHT_MAP_OFFSET 0.5 #define VERTEX_HEIGHT_MAP_SCALE 6553.5 struct vertexInput { float2 Position : POSITION; }; struct vertexFactoryInterpolants { float2 TexUV : TEXCOORD0; }; userShaderInput getUserShaderInputs(vertexFactoryInterpolants Interpolants) { userShaderInput Result; #if NUM_USER_TEXCOORDS for(int CoordinateIndex = 0;CoordinateIndex < NUM_USER_TEXCOORDS;CoordinateIndex++) Result.UserTexCoords[CoordinateIndex] = float4(Interpolants.TexUV, 0, 1); #endif Result.UserVertexColor = 1; Result.TangentSkyVector = Result.TangentNormal = Result.TangentCameraVector = Result.TangentReflectionVector = Result.TangentLightVector = Result.ScreenPosition.xyz = 0; #if WORLD_SPACE_VECTOR Result.WorldReflectionVector = Result.WorldCameraVector = 0; #endif return Result; } float4 vertexFactoryGetWorldPosition(vertexInput Input,out vertexFactoryInterpolants Interpolants,out float outFadeFactor) { float4 WorldPosition = (1.0f-Input.Position.y)*((1.0f-Input.Position.x)*CornerPoint00+Input.Position.x*CornerPoint10) +Input.Position.y*((1.0-Input.Position.x)*CornerPoint01+Input.Position.x*CornerPoint11); WorldPosition /= WorldPosition.w; Interpolants.TexUV = WorldPosition.xy*InvTillSize; outFadeFactor = 255; return WorldPosition ; } float4 vFGetWorldPositionTangentMat(vertexInput Input, out vertexFactoryInterpolants Interpolants, out float3x3 WorldToTangent,out float outFadeFactor) { float4 WorldPosition = vertexFactoryGetWorldPosition(Input, Interpolants, outFadeFactor); WorldToTangent = float3x3(float3(1,0,0),float3(0,1,0),float3(0,0,1)); return WorldPosition; }