Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1452 chris 1
// Copyright (c) 2008 the OpenTK Team. See license.txt for legal bla
2
 
3
// custom vertex attribute
4
attribute vec3 AttributeTangent;
5
 
6
// world uniforms
7
uniform vec3 Light_Position;
8
uniform vec3 Camera_Position;
9
 
10
// MUST be written to for FS
11
varying vec3 VaryingLightVector;
12
varying vec3 VaryingEyeVector;
13
 
14
void main()
15
{
16
  gl_Position = ftransform();
17
  gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
18
 
19
  vec3 nor = normalize( gl_NormalMatrix * gl_Normal );
20
  vec3 tan = normalize( gl_NormalMatrix * AttributeTangent );
21
  vec3 bi = cross(nor, tan);
22
 
23
  // need positions in tangent space
24
  vec3 vertex = vec3( gl_ModelViewMatrix * gl_Vertex );
25
 
26
  vec3 temp = Light_Position - vertex;
27
  VaryingLightVector.x = dot(temp, tan); // optimization, calculate dot products rather than building TBN matrix
28
  VaryingLightVector.y = dot(temp, bi);
29
  VaryingLightVector.z = dot(temp, nor);
30
 
31
  temp = Camera_Position - vertex;
32
  VaryingEyeVector.x = dot(temp, tan);
33
  VaryingEyeVector.y = dot(temp, bi);
34
  VaryingEyeVector.z = dot(temp, nor);
35
}