Brian | f44ba11 | 2007-01-16 14:55:43 -0700 | [diff] [blame] | 1 | // |
| 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 | |
| 11 | varying vec3 LightDir; |
| 12 | varying vec3 EyeDir; |
| 13 | |
| 14 | uniform vec3 LightPosition; |
| 15 | |
| 16 | attribute vec3 Tangent; |
| 17 | |
| 18 | void 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 | } |