/////////////////////////////////////////////////////////////////////////////// // // ## ###### // ###### ### // ## ############### Shark 3D Engine (www.shark3d.com) // ########## # # # // ######## Copyright (c) 1996-2006 Spinor GmbH. // ######### # # # All rights reserved. // ## ########## // ## // /////////////////////////////////////////////////////////////////////////////// #include \ /////////////////////////////////////////////////////////////////////////////// struct VS_INPUT { float4 posObj: POSITION; S3D_BONE_DECL_STD(boneWgh, boneSubscr) float2 tex0:TEXCOORD0; float3 normal:NORMAL; }; struct VS_OUTPUT { float4 posScr : POSITION; float3 worldV : TEXCOORD0; float3 WNormal : TEXCOORD1; float3 CUBEPos : TEXCOORD2; float3 lastCenter :TEXCOORD3; }; /////////////////////////////////////////////////////////////////////////////// S3D_MATBONE_DECL_STD(matBone) /////////////////////////////////////////////////////////////////////////////// // Vertexshader // Profile: 1x1 const float4x4 matView; const float4x4 modelViewInv; const float4x4 viewToWorld; const float4x4 viewToWorldInv; const float4x4 lightViewProj; const float4 lastCenter; const float4 lightPosView; VS_OUTPUT main(VS_INPUT input) { VS_OUTPUT output = (VS_OUTPUT)0; float4x4 matBoneFinal; S3D_BONE_TRANSF_STD(matBoneFinal, matBone, input.boneWgh, input.boneSubscr); // Transform vevertices by matBoneFinal ---> view space float4 posView = mul(input.posObj, matBoneFinal); // light position in world space float3 lightWPos = mul(float4(lightPosView.xyz,1), viewToWorld).xyz; // vertex position in world space float3 WPos = mul(posView, viewToWorld).xyz; // direction vector from light to shaded point in world space output.worldV = WPos - lightWPos; // vertex position in cubemap space output.CUBEPos = WPos - lastCenter; // vertex normal in world space output.WNormal = mul(mul(viewToWorldInv, modelViewInv),input.normal); // vertex position in light space output.posScr = mul(posView, lightViewProj); output.lastCenter = WPos.xyz; return output; } ///////////////////////////////////////////////////////////////////////////////