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 "levelutil/shader/prog/ogl_glsl/" \
|
---|
15 | "include_stddef_ogl_glsl_vs1x0.s3d_shadercode_run"
|
---|
16 |
|
---|
17 | ///////////////////////////////////////////////////////////////////////////////
|
---|
18 |
|
---|
19 | uniform vec4 lightCenRange;
|
---|
20 | uniform vec4 lightExtrude;
|
---|
21 |
|
---|
22 | S3D_BONE_DECL_STD(boneWgh, boneSubscr)
|
---|
23 | S3D_MATBONE_DECL_STD(matBone)
|
---|
24 |
|
---|
25 | ///////////////////////////////////////////////////////////////////////////////
|
---|
26 |
|
---|
27 | void main(void)
|
---|
28 | {
|
---|
29 | S3D_BONE_TRANSF_STD(matBoneFinal, matBone, boneWgh, boneSubscr);
|
---|
30 | vec4 posView = matBoneFinal * gl_Vertex;
|
---|
31 | vec3 normalView = normalize((matBoneFinal * vec4(gl_Normal, 0.0)).xyz);
|
---|
32 |
|
---|
33 | vec3 effLightCenRange = lightCenRange.xyz;
|
---|
34 |
|
---|
35 | @ifdef S3D_USE_BLOAT
|
---|
36 | // Bloat:
|
---|
37 | effLightCenRange.xyz -= normalView * lightExtrude.z;
|
---|
38 | @endif
|
---|
39 |
|
---|
40 | // Calculate normalized extrusion direction vector:
|
---|
41 | vec3 dirNrm = normalize(posView.xyz - effLightCenRange.xyz);
|
---|
42 |
|
---|
43 | // Extrude:
|
---|
44 | float prod = dot(dirNrm, normalView) * lightExtrude.w;
|
---|
45 | // Important! If the product is zero, extrusion must be off.
|
---|
46 | float sign = (prod > 0.0) ? 1.0 : 0.0;
|
---|
47 | float move = sign * lightExtrude.x + lightExtrude.y;
|
---|
48 | posView.xyz = move * dirNrm + posView.xyz;
|
---|
49 |
|
---|
50 | // Transform:
|
---|
51 | gl_Position = gl_ProjectionMatrix * posView;
|
---|
52 | }
|
---|
53 |
|
---|
54 | ///////////////////////////////////////////////////////////////////////////////
|
---|