source: GTP/trunk/App/Demos/Illum/Shark3D/version164x12u/IllumDemo/src/res/levelutil/shader/prog/ogl_glsl/shvol_og.s3d @ 2196

Revision 2196, 1.6 KB checked in by szirmay, 17 years ago (diff)
Line 
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        "stddef_ogl_glsl_vs1x0.s3d_shadercode_run"
16
17///////////////////////////////////////////////////////////////////////////////
18
19uniform vec4 lightCenRange;
20uniform vec4 lightExtrude;
21
22S3D_BONE_DECL_STD(boneWgh, boneSubscr)
23S3D_MATBONE_DECL_STD(matBone)
24
25///////////////////////////////////////////////////////////////////////////////
26
27void 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    // Calculate normalized extrusion direction vector:
34    vec3 dirNrm = normalize(posView.xyz - lightCenRange.xyz);
35
36    // Extrude:
37    float prod = dot(dirNrm, normalView) * lightExtrude.z;
38    // Important! If the product is zero, extrusion must be off.
39    float sign = (prod > 0.0) ? 1.0 : 0.0;
40    float move = sign * lightExtrude.x + lightExtrude.y;
41    posView.xyz = move * dirNrm + posView.xyz;
42
43    // Transform:
44    gl_Position = gl_ProjectionMatrix * posView;
45}
46
47///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.