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 | @ifdef S3D_LIGHT_PROJ
|
---|
21 | uniform mat4 lightProjMat;
|
---|
22 | @endif
|
---|
23 | @ifdef S3D_LIGHT_SHMAP
|
---|
24 | uniform mat4 lightShmapMat;
|
---|
25 | @endif
|
---|
26 |
|
---|
27 | S3D_BONE_DECL_STD(boneWgh, boneSubscr)
|
---|
28 | S3D_MATBONE_DECL_STD(matBone)
|
---|
29 |
|
---|
30 | ///////////////////////////////////////////////////////////////////////////////
|
---|
31 |
|
---|
32 | @define S3D_NORMALIZE(v) normalize(v)
|
---|
33 | //@define S3D_NORMALIZE(v) (v)
|
---|
34 |
|
---|
35 | ///////////////////////////////////////////////////////////////////////////////
|
---|
36 |
|
---|
37 | void main(void)
|
---|
38 | {
|
---|
39 | S3D_BONE_TRANSF_STD(matBoneFinal, matBone, boneWgh, boneSubscr);
|
---|
40 |
|
---|
41 | vec4 posView = matBoneFinal * gl_Vertex;
|
---|
42 | vec3 normalView = (matBoneFinal * vec4(gl_Normal, 0.0)).xyz;
|
---|
43 | vec3 tangentUObj = S3D_NORMALIZE(gl_MultiTexCoord1.xyz);
|
---|
44 | vec3 tangentVObj = S3D_NORMALIZE(gl_MultiTexCoord2.xyz);
|
---|
45 | vec3 tangentUView = (matBoneFinal * vec4(tangentUObj, 0)).xyz;
|
---|
46 | vec3 tangentVView = (matBoneFinal * vec4(tangentVObj, 0)).xyz;
|
---|
47 |
|
---|
48 | gl_Position = gl_ProjectionMatrix * posView;
|
---|
49 | gl_TexCoord[0] = gl_MultiTexCoord0;
|
---|
50 |
|
---|
51 | gl_FogFragCoord = posView.z / posView.w;
|
---|
52 |
|
---|
53 | @ifdef S3D_LIGHT_PROJ
|
---|
54 | gl_TexCoord[1] = lightProjMat * posView;
|
---|
55 | @endif
|
---|
56 | @ifdef S3D_LIGHT_SHMAP
|
---|
57 | gl_TexCoord[2] = lightShmapMat * posView;
|
---|
58 | @endif
|
---|
59 |
|
---|
60 | vec3 camToVertView = posView.xyz;
|
---|
61 | vec3 vertToLightView = lightCenRange.xyz - camToVertView;
|
---|
62 |
|
---|
63 | // Lightrange-factor: 1 - (lightpos - surfacepos)^2 / range^2
|
---|
64 | gl_TexCoord[3].xyz = vertToLightView / lightCenRange.w;
|
---|
65 |
|
---|
66 | @ifdef S3D_PARALLAX_MAPPING
|
---|
67 | gl_TexCoord[4].x = dot(tangentUView, camToVertView);
|
---|
68 | gl_TexCoord[4].y = dot(tangentVView, camToVertView);
|
---|
69 | gl_TexCoord[4].z = dot(normalView, camToVertView);
|
---|
70 | @endif
|
---|
71 |
|
---|
72 | vec3 vertToLightDirView = S3D_NORMALIZE(vertToLightView);
|
---|
73 | vec3 halfDirView = S3D_NORMALIZE(vertToLightDirView - camToVertView);
|
---|
74 | // ATI workaround: Don't use x component of gl_TexCoord[2]:
|
---|
75 | s3d_calcBump(
|
---|
76 | gl_TexCoord[1].xyz, gl_TexCoord[2].yzw,
|
---|
77 | normalView, vertToLightDirView, halfDirView,
|
---|
78 | tangentUView, tangentVView);
|
---|
79 |
|
---|
80 | @ifdef S3D_LIGHT_BRIGHT
|
---|
81 | gl_TexCoord[5] = gl_TextureMatrix[2] * posView;
|
---|
82 | gl_TexCoord[6] = gl_Position;
|
---|
83 | @endif
|
---|
84 | }
|
---|
85 |
|
---|
86 | ///////////////////////////////////////////////////////////////////////////////
|
---|