| 1 |
/// ============================================================================ |
| 2 |
/* |
| 3 |
Copyright (C) 2004 Robert Beckebans <[email protected]> |
| 4 |
Please see the file "AUTHORS" for a list of contributors |
| 5 |
|
| 6 |
This program is free software; you can redistribute it and/or |
| 7 |
modify it under the terms of the GNU General Public License |
| 8 |
as published by the Free Software Foundation; either version 2 |
| 9 |
of the License, or (at your option) any later version. |
| 10 |
|
| 11 |
This program is distributed in the hope that it will be useful, |
| 12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 14 |
|
| 15 |
See the GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with this program; if not, write to the Free Software |
| 19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 20 |
*/ |
| 21 |
/// ============================================================================ |
| 22 |
|
| 23 |
|
| 24 |
struct cg_app2vertex |
| 25 |
{ |
| 26 |
float4 position : POSITION; |
| 27 |
float4 tex0 : ATTR8; |
| 28 |
|
| 29 |
float3 tangent : ATTR9; |
| 30 |
float3 binormal : ATTR10; |
| 31 |
float3 normal : ATTR11; |
| 32 |
}; |
| 33 |
|
| 34 |
struct cg_vertex2fragment |
| 35 |
{ |
| 36 |
float4 hposition : POSITION; |
| 37 |
|
| 38 |
float4 position : TEXCOORD0; |
| 39 |
float4 tex_diffuse_bump : TEXCOORD1; |
| 40 |
float4 tex_specular : TEXCOORD2; |
| 41 |
float4 tex_atten_xy_z : TEXCOORD3; |
| 42 |
|
| 43 |
float3 tangent : TEXCOORD4; |
| 44 |
float3 binormal : TEXCOORD5; |
| 45 |
float3 normal : TEXCOORD6; |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
cg_vertex2fragment main(cg_app2vertex IN) |
| 51 |
{ |
| 52 |
cg_vertex2fragment OUT; |
| 53 |
|
| 54 |
// transform vertex position into homogenous clip-space |
| 55 |
OUT.hposition = mul(glstate.matrix.mvp, IN.position); |
| 56 |
|
| 57 |
// assign position in object space |
| 58 |
OUT.position = IN.position; |
| 59 |
|
| 60 |
// transform texcoords |
| 61 |
OUT.tex_diffuse_bump.xy = mul(glstate.matrix.texture[0], IN.tex0).xy; |
| 62 |
|
| 63 |
// transform texcoords |
| 64 |
OUT.tex_diffuse_bump.zw = mul(glstate.matrix.texture[1], IN.tex0).xy; |
| 65 |
|
| 66 |
// transform texcoords |
| 67 |
OUT.tex_specular = mul(glstate.matrix.texture[2], IN.tex0); |
| 68 |
|
| 69 |
// transform vertex position into light space |
| 70 |
OUT.tex_atten_xy_z = mul(glstate.matrix.texture[3], IN.position); |
| 71 |
|
| 72 |
// assign tangent space vectors |
| 73 |
OUT.tangent = IN.tangent; |
| 74 |
OUT.binormal = IN.binormal; |
| 75 |
OUT.normal = IN.normal; |
| 76 |
|
| 77 |
return OUT; |
| 78 |
} |