// STATIC: "BLEND" "0..1" #include "common_vs_fxc.h" struct VS_INPUT { float4 vPos : POSITION; float4 vNormal : NORMAL; float2 vNormalMapCoord : TEXCOORD0; float3 vTangentS : TANGENT; float3 vTangentT : BINORMAL; }; struct VS_OUTPUT { float4 projPos : POSITION; #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) float fog : FOG; #endif float4 worldVertToEyeVector_normalMapX : TEXCOORD1; float3x3 tangentSpaceTranspose : TEXCOORD2; float4 vRefract_W_ProjZ : TEXCOORD5; float4 vExtraBumpTexCoord : TEXCOORD6; float4 worldPos_normalMapY : TEXCOORD7; }; const float4 cNormalMapTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); const float4 TexOffsets : register( SHADER_SPECIFIC_CONST_3 ); VS_OUTPUT main( const VS_INPUT v ) { VS_OUTPUT o = ( VS_OUTPUT )0; float3 vObjNormal; DecompressVertex_Normal( v.vNormal, vObjNormal ); float4 projPos; float3 worldPos; worldPos = mul4x3( v.vPos, cModel[0] ); projPos = mul( float4( worldPos, 1 ), cViewProj ); o.projPos = projPos; #ifdef _PS3 // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1] o.projPos.y = -o.projPos.y; o.projPos.z = 2.0f * o.projPos.z - o.projPos.w; #endif // _PS3 #if BLEND // Map projected position to the reflection texture o.vRefract_W_ProjZ.x = projPos.x; o.vRefract_W_ProjZ.y = -projPos.y; // invert Y o.vRefract_W_ProjZ.xy = ( o.vRefract_W_ProjZ.xy + projPos.ww ) * float2( 0.5f, 0.5f ); o.vRefract_W_ProjZ.z = projPos.w; #endif o.vRefract_W_ProjZ.w = projPos.z; float3 worldTangentS = mul3x3( v.vTangentS, ( const float3x3 )cModel[0] ); float3 worldTangentT = mul3x3( v.vTangentT, ( const float3x3 )cModel[0] ); float3 worldNormal = mul3x3( vObjNormal, ( float3x3 )cModel[0] ); o.tangentSpaceTranspose[0] = worldTangentS; o.tangentSpaceTranspose[1] = worldTangentT; o.tangentSpaceTranspose[2] = worldNormal; float3 worldVertToEyeVector = VSHADER_VECT_SCALE * (cEyePos - worldPos); o.worldVertToEyeVector_normalMapX.xyz = worldVertToEyeVector; // FIXME: need to add a normalMapTransform to all of the water shaders. //o.worldVertToEyeVector_normalMapX.w = dot( v.vNormalMapCoord, cNormalMapTransform[0] ) + cNormalMapTransform[0].w; //o.worldPos_normalMapY.w = dot( v.vNormalMapCoord, cNormalMapTransform[1] ) + cNormalMapTransform[1].w; o.worldVertToEyeVector_normalMapX.w = v.vNormalMapCoord.x; o.worldPos_normalMapY.w = v.vNormalMapCoord.y; float f45x=v.vNormalMapCoord.x+v.vNormalMapCoord.y; float f45y=v.vNormalMapCoord.y-v.vNormalMapCoord.x; o.vExtraBumpTexCoord.x=f45x*0.1+TexOffsets.x; o.vExtraBumpTexCoord.y=f45y*0.1+TexOffsets.y; o.vExtraBumpTexCoord.z=v.vNormalMapCoord.y*0.45+TexOffsets.z; o.vExtraBumpTexCoord.w=v.vNormalMapCoord.x*0.45+TexOffsets.w; o.worldPos_normalMapY.xyz = worldPos; #if !defined( _X360 ) && !defined( SHADER_MODEL_VS_3_0 ) o.fog = CalcFixedFunctionFog( worldPos, FOGTYPE_RANGE ); #endif return o; }