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 | S3D_BONE_DECL_STD(boneWgh, boneSubscr)
|
---|
23 | float2 tex0:TEXCOORD0;
|
---|
24 | float3 normal:NORMAL;
|
---|
25 | };
|
---|
26 |
|
---|
27 | struct VS_OUTPUT
|
---|
28 | {
|
---|
29 | float4 posScr : POSITION;
|
---|
30 | float3 worldV : TEXCOORD0;
|
---|
31 | float3 WNormal : TEXCOORD1;
|
---|
32 | float3 CUBEPos : TEXCOORD2;
|
---|
33 | float3 lastCenter :TEXCOORD3;
|
---|
34 | };
|
---|
35 |
|
---|
36 | ///////////////////////////////////////////////////////////////////////////////
|
---|
37 |
|
---|
38 | S3D_MATBONE_DECL_STD(matBone)
|
---|
39 |
|
---|
40 |
|
---|
41 | ///////////////////////////////////////////////////////////////////////////////
|
---|
42 | // Vertexshader
|
---|
43 | // Profile: 1x1
|
---|
44 | const float4x4 matView;
|
---|
45 | const float4x4 modelViewInv;
|
---|
46 | const float4x4 viewToWorld;
|
---|
47 | const float4x4 viewToWorldInv;
|
---|
48 | const float4x4 lightViewProj;
|
---|
49 | const float4 lastCenter;
|
---|
50 | const float4 lightPosView;
|
---|
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(matBoneFinal, matBone, input.boneWgh, input.boneSubscr);
|
---|
58 | // Transform vevertices by matBoneFinal ---> view space
|
---|
59 | float4 posView = mul(input.posObj, matBoneFinal);
|
---|
60 | // light position in world space
|
---|
61 | float3 lightWPos = mul(float4(lightPosView.xyz,1), viewToWorld).xyz;
|
---|
62 | // vertex position in world space
|
---|
63 | float3 WPos = mul(posView, viewToWorld).xyz;
|
---|
64 | // direction vector from light to shaded point in world space
|
---|
65 | output.worldV = WPos - lightWPos;
|
---|
66 | // vertex position in cubemap space
|
---|
67 | output.CUBEPos = WPos - lastCenter;
|
---|
68 | // vertex normal in world space
|
---|
69 | output.WNormal = mul(mul(viewToWorldInv, modelViewInv),input.normal);
|
---|
70 | // vertex position in light space
|
---|
71 | output.posScr = mul(posView, lightViewProj);
|
---|
72 |
|
---|
73 | output.lastCenter = WPos.xyz;
|
---|
74 |
|
---|
75 | return output;
|
---|
76 | }
|
---|
77 |
|
---|
78 | /////////////////////////////////////////////////////////////////////////////// |
---|