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

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