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 | float3 normalObj: NORMAL;
|
---|
24 | };
|
---|
25 |
|
---|
26 | struct VS_OUTPUT
|
---|
27 | {
|
---|
28 | float4 posScr: POSITION;
|
---|
29 | };
|
---|
30 |
|
---|
31 | ///////////////////////////////////////////////////////////////////////////////
|
---|
32 |
|
---|
33 | const float4x4 projMat;
|
---|
34 | const float4x4 matView;
|
---|
35 |
|
---|
36 | S3D_MATBONE_DECL_STD(matBone)
|
---|
37 |
|
---|
38 | const float4 lightCenRange;
|
---|
39 | const float4 lightExtrude;
|
---|
40 |
|
---|
41 | ///////////////////////////////////////////////////////////////////////////////
|
---|
42 | // Vertexshader
|
---|
43 | // Profile: 1x1
|
---|
44 |
|
---|
45 | VS_OUTPUT main(VS_INPUT input)
|
---|
46 | {
|
---|
47 | VS_OUTPUT output = (VS_OUTPUT)0;
|
---|
48 |
|
---|
49 | float4x4 matBoneFinal;
|
---|
50 | S3D_BONE_TRANSF_STD(
|
---|
51 | matBoneFinal, matBone, input.boneWgh, input.boneSubscr);
|
---|
52 | // Transform vectors by matBoneFinal
|
---|
53 | float4 posView = mul(input.posObj, matBoneFinal);
|
---|
54 | float3 normalView = normalize(mul(input.normalObj, matBoneFinal).xyz);
|
---|
55 |
|
---|
56 | float3 effLightCenRange = lightCenRange;
|
---|
57 |
|
---|
58 | #ifdef S3D_USE_BLOAT
|
---|
59 | // Bloat:
|
---|
60 | effLightCenRange.xyz -= normalView * lightExtrude.z;
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | // Calculate normalized extrusion direction vector:
|
---|
64 | float3 dirNrm = normalize(posView.xyz - effLightCenRange.xyz);
|
---|
65 |
|
---|
66 | // Extrude:
|
---|
67 | float prod = dot(dirNrm, normalView) * lightExtrude.w;
|
---|
68 | // Important! If the product is zero, extrusion must be off.
|
---|
69 | float sign = (prod > 0) ? 1 : 0;
|
---|
70 | float move = sign * lightExtrude.x + lightExtrude.y;
|
---|
71 | posView.xyz = move * dirNrm + posView;
|
---|
72 |
|
---|
73 | // Transform:
|
---|
74 | output.posScr = mul(posView, projMat);
|
---|
75 | return output;
|
---|
76 | }
|
---|
77 |
|
---|
78 | ///////////////////////////////////////////////////////////////////////////////
|
---|