/////////////////////////////////////////////////////////////////////////////// // // ## ###### // ###### ### // ## ############### Shark 3D Engine (www.shark3d.com) // ########## # # # // ######## Copyright (c) 1996-2006 Spinor GmbH. // ######### # # # All rights reserved. // ## ########## // ## // /////////////////////////////////////////////////////////////////////////////// #include \ /////////////////////////////////////////////////////////////////////////////// #ifndef S3D_LIGHT_CT #define S3D_LIGHT_CT 4 #endif /////////////////////////////////////////////////////////////////////////////// struct VS_INPUT { float4 posObj: POSITION; float3 normalObj: NORMAL; float4 diffuse: COLOR0; }; struct VS_OUTPUT { float4 posScr: POSITION; float2 mainTexCoord: TEXCOORD0; float4 diffuse: COLOR0; float fogCoord: TEXCOORD1; }; /////////////////////////////////////////////////////////////////////////////// const float4x4 projMat; const float4x4 matView; const float4 mtrlPower; const float4 mtrlEmissive; const s3d_StdProgLight lightArray[S3D_LIGHT_CT]; const int activeLights; /////////////////////////////////////////////////////////////////////////////// // Vertexshader // Profile: 2x0 VS_OUTPUT main(VS_INPUT input) { VS_OUTPUT output = (VS_OUTPUT)0; float4 posView = mul(input.posObj, matView); float3 normalView = normalize(mul(input.normalObj, matView).xyz); output.posScr = mul(posView, projMat); output.fogCoord = posView.z / posView.w; float4 colDiffuse = mtrlEmissive; float4 colSpecular = (float4)0; for(int i = 0; i < activeLights; i++) { s3d_ColPair lightCol = s3d_calcPointLightTerm( posView.xyz, normalView, mtrlPower.w, lightArray[i]); colDiffuse += lightCol.diffuse; colSpecular += lightCol.specular; } output.diffuse = input.diffuse; output.mainTexCoord = dot(colDiffuse.xyz, float3(0.3, 0.5, 0.2)); return output; } ///////////////////////////////////////////////////////////////////////////////