2 ===========================================================================
3 Copyright (C) 2006 Robert Beckebans <trebor_7@users.sourceforge.net>
5 This file is part of XreaL source code.
7 XreaL source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
12 XreaL source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with XreaL source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
23 attribute vec4 attr_TexCoord0;
24 attribute vec3 attr_Tangent;
25 attribute vec3 attr_Binormal;
27 varying vec3 var_Vertex;
28 varying vec2 var_TexDiffuse;
29 varying vec2 var_TexBump;
30 varying vec4 var_TexAtten;
31 varying mat3 var_OS2TSMatrix;
35 // transform vertex position into homogenous clip-space
36 gl_Position = ftransform();
38 // assign position in object space
39 var_Vertex = gl_Vertex.xyz;
41 // transform diffusemap texcoords
42 var_TexDiffuse = (gl_TextureMatrix[0] * attr_TexCoord0).st;
44 // transform bumpmap texcoords
45 var_TexBump = (gl_TextureMatrix[1] * attr_TexCoord0).st;
47 // calc light xy,z attenuation in light space
48 var_TexAtten = gl_TextureMatrix[3] * gl_Vertex;
50 // construct object-space-to-tangent-space 3x3 matrix
51 var_OS2TSMatrix = mat3( attr_Tangent.x, attr_Binormal.x, gl_Normal.x,
52 attr_Tangent.y, attr_Binormal.y, gl_Normal.y,
53 attr_Tangent.z, attr_Binormal.z, gl_Normal.z );