/////////////////////////////////////////////////////////////////////////////// // // ## ###### // ###### ### // ## ############### 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) float3 normalObj: NORMAL; }; struct VS_OUTPUT { float4 posScr: POSITION; }; /////////////////////////////////////////////////////////////////////////////// const float4x4 projMat; const float4x4 matView; S3D_MATBONE_DECL_STD(matBone) const float4 lightCenRange; const float4 lightExtrude; /////////////////////////////////////////////////////////////////////////////// // Vertexshader // Profile: 1x1 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 vectors by matBoneFinal float4 posView = mul(input.posObj, matBoneFinal); float3 normalView = normalize(mul(input.normalObj, matBoneFinal).xyz); float3 effLightCenRange = lightCenRange; #ifdef S3D_USE_BLOAT // Bloat: effLightCenRange.xyz -= normalView * lightExtrude.z; #endif // Calculate normalized extrusion direction vector: float3 dirNrm = normalize(posView.xyz - effLightCenRange.xyz); // Extrude: float prod = dot(dirNrm, normalView) * lightExtrude.w; // Important! If the product is zero, extrusion must be off. float sign = (prod > 0) ? 1 : 0; float move = sign * lightExtrude.x + lightExtrude.y; posView.xyz = move * dirNrm + posView; // Transform: output.posScr = mul(posView, projMat); return output; } ///////////////////////////////////////////////////////////////////////////////