blob: d3d19f62ac36be3cf77fb4e850545389a5aa4731 [file] [log] [blame]
Brianf44ba112007-01-16 14:55:43 -07001//
2// Vertex shader for procedural bumps
3//
4// Authors: Randi Rost, John Kessenich
5//
6// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
7//
8// See 3Dlabs-License.txt for license information
9//
10
11varying vec3 LightDir;
12varying vec3 EyeDir;
13
14uniform vec3 LightPosition;
15
16attribute vec3 Tangent;
17
18void main()
19{
20 EyeDir = vec3(gl_ModelViewMatrix * gl_Vertex);
21 gl_Position = ftransform();
22 gl_TexCoord[0] = gl_MultiTexCoord0;
23
24 vec3 n = normalize(gl_NormalMatrix * gl_Normal);
25 vec3 t = normalize(gl_NormalMatrix * Tangent);
26 vec3 b = cross(n, t);
27
28 vec3 v;
29 v.x = dot(LightPosition, t);
30 v.y = dot(LightPosition, b);
31 v.z = dot(LightPosition, n);
32 LightDir = normalize(v);
33
34 v.x = dot(EyeDir, t);
35 v.y = dot(EyeDir, b);
36 v.z = dot(EyeDir, n);
37 EyeDir = normalize(v);
38}