Original Post
Hi I got some problems with a simple shader, maybe you can see whats wrong with the code. I am running a 6800GT SLI system I just wanted to ask what is wrong with the code, right in the moment I figured it out on my own. I'll post it anyways for the case someone is looking for a solution on his own vertex shader code(incorrect) vertex shader (correct!!!!!!!) Problem: I didn t set the gl_TexCoord in each case, which caused and linking error. Thats why I added the else part Maybe I should just set it to vec4(0.0,0.0,0.0,0.0), but I am not using it anyways if the u_numlayers > x condition fails
9 //number of additional layers
10 uniform int u_numlayers;
11
12 varying vec3 v_normal;
13 varying vec3 v_blend;
14
15 void main()
16 {
17 gl_Position = ftransform();
18
19 //send front and back colors
20 gl_FrontColor = gl_Color;
21 gl_BackColor = gl_Color;
22
23 //set the blending weights and let it be interpolated
24 v_blend = gl_MultiTexCoord1.stp;
25
26 //set the surface normal
27 v_normal = gl_Normal;
28
29 //set texture coordinates
30 gl_TexCoord[0] = gl_MultiTexCoord0;
31
32 if(u_numlayers > 0)
33 {
34 gl_TexCoord[1] = gl_MultiTexCoord2;
35 }
36 if(u_numlayers > 1)
37 {
38 gl_TexCoord[2] = gl_MultiTexCoord3;
39 }
40 if(u_numlayers > 2)
41 {
42 gl_TexCoord[3] = gl_MultiTexCoord4;
43 }
44
45 }
9 //number of additional layers
10 uniform int u_numlayers;
11
12 varying vec3 v_normal;
13 varying vec3 v_blend;
14
15 void main()
16 {
17 gl_Position = ftransform();
18
19 //send front and back colors
20 gl_FrontColor = gl_Color;
21 gl_BackColor = gl_Color;
22
23 //set the blending weights and let it be interpolated
24 v_blend = gl_MultiTexCoord1.stp;
25
26 //set the surface normal
27 v_normal = gl_Normal;
28
29 //set texture coordinates
30 gl_TexCoord[0] = gl_MultiTexCoord0;
31
32 if(u_numlayers > 0)
33 {
34 gl_TexCoord[1] = gl_MultiTexCoord2;
35 }
36 else
37 {
38 gl_TexCoord[1] = gl_MultiTexCoord0;
39 }
40 if(u_numlayers > 1)
41 {
42 gl_TexCoord[2] = gl_MultiTexCoord3;
43 }
44 else
45 {
46 gl_TexCoord[2] = gl_MultiTexCoord0;
47 }
48 if(u_numlayers > 2)
49 {
50 gl_TexCoord[3] = gl_MultiTexCoord4;
51 }
52 else
53 {
54 gl_TexCoord[3] = gl_MultiTexCoord0;
55 }
56
57 }