// VsCommon.hlsl // macros #define OSVecMatrixMul(vOut, vIn, m) vOut = mul(vIn, m); //#define OSVecMatrixMul(vOut, vIn, m) vOut.x = dot(vIn,m[0]); vOut.y = dot(vIn,m[1]); vOut.z = dot(vIn,m[2]); vOut.w = dot(vIn,m[3]); // ------------------------------------------------------------------------------------------------ // VARIABLES // ------------------------------------------------------------------------------------------------ uniform float4x4 g_mWorld; uniform float4x4 g_mInvTransWorld; uniform float4x4 g_mWorldViewProj; uniform float4x4 g_mWorldView; uniform float4x4 g_mViewProj; uniform float4x4 g_mView; uniform float4x2 g_mTextureTransform; // Diffuse uniform float4x2 g_mTextureTransform1; // Diffuse2 uniform float4 g_vViewerPosition; uniform float4 g_vViewerDirection; // Eye vector uniform float4 g_vAmbientColor; uniform float4 g_vSpecularColor; #ifdef _PS3 uniform float4 g_mSkinningMatrices[64*3] : C0; #else uniform float4 g_mSkinningMatrices[64*3]; #endif // Fog uniform float4 g_vFogConstants; #define g_fFogStart g_vFogConstants.x #define g_fFogEnd g_vFogConstants.y #define g_fFogDensity g_vFogConstants.z // Mixed uniform float4 g_vMixed1; #define g_fShininess g_vMixed1.x #define g_fSpecularStrength g_vMixed1.y // Shadow uniform float4x4 g_mShdWVPTMat; // Transfrom from Object space to Shadow Space uniform float3 g_vShdZAxis; // Projector ZAxis in Object Space // Mapping Scale & Bias uniform float4 g_vMappingScaleBias; // Next Gen Correction of mapping uniform float4 g_vMappingRotation; uniform float4 g_vMappingScaleBias2; // second set uniform float4 g_vMappingRotation2; uniform float4 g_vMappingScaleBias3; // third set uniform float4 g_vMappingRotation3; // Gloss Scale & Bias uniform float4 g_vMappingScaleBiasGloss; // Gloss setting uniform float4 g_vMappingRotationGloss; // Motionblur SFX uniform float4 g_vReposition; // transform to previous position uniform float4 g_vMovement; // movement vector between 2 positions uniform float4 g_vBlurFactor; // blur factor uniform float4 g_vForcedColor; // force color // Projective texture uniform float4x4 g_mProjectiveTexture; // Transform from Object space to Texture Space uniform float3 g_vProjectorPos; // Attenuated Shadow : Position of the projector uniform float3 g_vProjectorDir; // Attenuated Shadow : Direction of the projector uniform float2 g_vFadeOutParams; // Attenuated Shadow : FadeOutStart and FadeOutDist // Wind of SPG2 uniform float4 g_vSPG2Params1; uniform float4 g_vSPG2Params2; #define g_fGlobalPhase1 g_vSPG2Params1.x #define g_fGlobalPhase2 g_vSPG2Params1.y #define g_fGlobalWindStrength g_vSPG2Params1.z #define g_fYXRatio g_vSPG2Params1.w #define g_fSpatialFreq g_vSPG2Params2.x #define g_fRotationNoiseStrength g_vSPG2Params2.y // Billboard uniform float3 g_vBillboard_XAxis; uniform float3 g_vBillboard_YAxis; // ------------------------------------------------------------------------------------------------ // STRUCTURES // ------------------------------------------------------------------------------------------------ #if defined(INPUT_FORCE_COLOR1) # define INPUT_COLOR0 #endif // The common vertex input structure struct VSIN { float4 Position : POSITION; #if defined(INPUT_FORCE_COLOR1) float4 Color0 : COLOR1; #elif defined(INPUT_COLOR0) float4 Color0 : COLOR0; #endif #ifdef INPUT_BLENDINFO float4 BlendIndices : BLENDINDICES; float4 BlendWeights : BLENDWEIGHT; #endif #ifdef INPUT_NORMAL float3 Normal : NORMAL; #endif #ifdef INPUT_TANGENT float4 Tangent : TANGENT; #endif #ifdef INPUT_TEXCOORD0 # ifdef INPUT_TEXCOORD0_FLOAT4 float4 TexCoord0 : TEXCOORD0; # else float2 TexCoord0 : TEXCOORD0; # endif #endif #ifdef INPUT_TEXCOORD1 float2 TexCoord1 : TEXCOORD1; #endif #ifdef INPUT_TEXCOORD2 float4 TexCoord2 : TEXCOORD2; #endif #ifdef INPUT_TEXCOORD3 float4 TexCoord3 : TEXCOORD3; #endif #ifdef INPUT_TEXCOORD4 float4 TexCoord4 : TEXCOORD4; #endif }; // ------------------------------------------------------------------------------------------------ // FUNCTIONS // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ // Name : ComputeFog // Descr. : Calculates fog color. // ------------------------------------------------------------------------------------------------ #ifdef OUTPUT_FOG_COLOR void ComputeFog( float4 Position, out float FogDensity ) { // Fetch and adjust depth from the z-prepass texture float fZ = Position.w; // Calculate linear fog factor FogDensity = saturate((fZ - g_fFogStart) / (g_fFogEnd - g_fFogStart)); #if defined(USE_FOGDENSITY) FogDensity = saturate(FogDensity * g_fFogDensity); #endif } #endif