1 | ///////////////////////////////////////////////////////////////////////////////
|
---|
2 | //
|
---|
3 | // ## ######
|
---|
4 | // ###### ###
|
---|
5 | // ## ############### Shark 3D Engine (www.shark3d.com)
|
---|
6 | // ########## # # #
|
---|
7 | // ######## Copyright (c) 1996-2006 Spinor GmbH.
|
---|
8 | // ######### # # # All rights reserved.
|
---|
9 | // ## ##########
|
---|
10 | // ##
|
---|
11 | //
|
---|
12 | ///////////////////////////////////////////////////////////////////////////////
|
---|
13 |
|
---|
14 | #include \
|
---|
15 | <levelutil/shader/prog/d3d9_hlsl/include_stddef_d3d9_hlsl.s3d_shadercode_run>
|
---|
16 |
|
---|
17 | ///////////////////////////////////////////////////////////////////////////////
|
---|
18 |
|
---|
19 | struct VS_INPUT
|
---|
20 | {
|
---|
21 | float4 posObj: POSITION;
|
---|
22 | float3 normalObj: NORMAL;
|
---|
23 | S3D_BONE_DECL_STD(boneWgh, boneSubscr)
|
---|
24 | float2 mainTexCoord: TEXCOORD0;
|
---|
25 | };
|
---|
26 |
|
---|
27 | struct VS_OUTPUT
|
---|
28 | {
|
---|
29 | float4 posScr: POSITION;
|
---|
30 | float2 mainTexCoord: TEXCOORD0;
|
---|
31 | float4 diffuse: COLOR0;
|
---|
32 | float4 specular: COLOR1;
|
---|
33 | float fogCoord: TEXCOORD2;
|
---|
34 | };
|
---|
35 |
|
---|
36 | ///////////////////////////////////////////////////////////////////////////////
|
---|
37 |
|
---|
38 | const float4x4 projMat;
|
---|
39 |
|
---|
40 | S3D_MATBONE_DECL_STD(matBone)
|
---|
41 |
|
---|
42 | const float4 mtrlPower;
|
---|
43 | const float4 mtrlEmissive;
|
---|
44 |
|
---|
45 | const s3d_StdProgLight lightArray[S3D_LIGHT_CNT];
|
---|
46 | const int activeLights;
|
---|
47 |
|
---|
48 | ///////////////////////////////////////////////////////////////////////////////
|
---|
49 | // Vertexshader
|
---|
50 | // Profile: 2x0
|
---|
51 |
|
---|
52 | VS_OUTPUT main(VS_INPUT input)
|
---|
53 | {
|
---|
54 | VS_OUTPUT output = (VS_OUTPUT)0;
|
---|
55 |
|
---|
56 | float4x4 matBoneFinal;
|
---|
57 | S3D_BONE_TRANSF_STD(
|
---|
58 | matBoneFinal, matBone, input.boneWgh, input.boneSubscr);
|
---|
59 | // Transform vectors by matBoneFinal
|
---|
60 | float4 posView = mul(input.posObj, matBoneFinal);
|
---|
61 | float3 normalView = normalize(mul(input.normalObj, matBoneFinal).xyz);
|
---|
62 |
|
---|
63 | output.posScr = mul(posView, projMat);
|
---|
64 | output.mainTexCoord = input.mainTexCoord;
|
---|
65 | output.fogCoord = posView.z / posView.w;
|
---|
66 |
|
---|
67 | float4 colDiffuse = mtrlEmissive;
|
---|
68 | float4 colSpecular = (float4)0;
|
---|
69 | for(int i = 0; i < activeLights; i++)
|
---|
70 | {
|
---|
71 | s3d_ColPair lightCol = s3d_calcPointLightTerm(
|
---|
72 | posView.xyz, normalView, mtrlPower.w, lightArray[i]);
|
---|
73 | colDiffuse += lightCol.diffuse;
|
---|
74 | colSpecular += lightCol.specular;
|
---|
75 | }
|
---|
76 |
|
---|
77 | output.diffuse = colDiffuse;
|
---|
78 | output.specular = colSpecular;
|
---|
79 |
|
---|
80 | return output;
|
---|
81 | }
|
---|
82 |
|
---|
83 | ///////////////////////////////////////////////////////////////////////////////
|
---|