   GLSL error
  Heyim stil new to shaders and im having trouble understanding this error i get from the following fragment shader im busy writing (its not complete yet, im probely using some bad naming conventions and the logic might stil be flawed but for now my only concern is the error its giving me)uniform sampler2D tex;uniform int textureMode;uniform int lightMode;varying vec3 normal;uniform float l1_constantAttenuation,l1_linearAttenuation,l1_quadraticAttenuation;varying vec4 l1_diffuse;varying vec3 l1_lightDir;varying float l1_dist;uniform float l0_constantAttenuation,l0_linearAttenuation,l0_quadraticAttenuation;varying vec4 l0_diffuse;varying vec3 l0_lightDir;varying float l0_dist;void main (void){vec4 l0_contribution;vec4 l1_contibution;if (textureMode == 0){l0_contibution = l0_diffuse;l1_contibution = l1_diffuse;}if (textureMode == 1){vec4 texColor = texture2D(tex,gl_TexCoord[0].st);l0_contibution = texColor;l1_contibution = vec4(0,0,0,0);}else if (textureMode == 2){vec4 texColor = texture2D(tex,gl_TexCoord[0].st);l0_contibution = texColor*l0_diffuse;l1_contibution = texColor*l1_diffuse;}   if (lightMode == 0){gl_FragColor = l0_contribution;}else if (lightMode == 1){    vec3 n;   float NdotL;    n = normalize(normal); NdotL = max(dot(n,l1_lightDir),0.0);  float att = 1.0 / (l1_constantAttenuation +l1_linearAttenuation * l1_dist +l1_quadraticAttenuation * l1_dist * l1_dist);l1_contribution = vec4(att*l1_contribution.r*NdotL,att*l1_contribution.g*NdotL,att*l1_contribution.b*NdotL,0.0);   n = normalize(normal); NdotL = max(dot(n,l0_lightDir),0.0);  att = 1.0 / (l0_constantAttenuation +l0_linearAttenuation * l0_dist +l0_quadraticAttenuation * l0_dist * l0_dist);l0_contribution = vec4(att*l0_contribution.r*NdotL,att*l0_contribution.g*NdotL,att*l0_contribution.b*NdotL,1.0);gl_FragColor = l0_contribution+l1_contribution; }   else if (lightMode == 2)   {    float att = 1.0 / (l1_constantAttenuation +l1_linearAttenuation * l1_dist +l1_quadraticAttenuation * l1_dist * l1_dist);l1_contribution = vec4(att*l1_contribution.r*NdotL,att*l1_contribution.g*NdotL,att*l1_contribution.b*NdotL,0.0);    att = 1.0 / (l0_constantAttenuation +l0_linearAttenuation * l0_dist +l0_quadraticAttenuation * l0_dist * l0_dist);l0_contribution = vec4(att*l0_contribution.r*NdotL,att*l0_contribution.g*NdotL,att*l0_contribution.b*NdotL,1.0);gl_FragColor = l0_contribution+l1_contribution;   }}here is the code for the vertice shader. its probely irrelevent but im pasting it for just in caseuniform mat4 completeMatrix;uniform mat3 normalMatrix;uniform mat4 modelMatrix;uniform int lightMode;varying vec3 normal;uniform vec3 l1_pos;uniform vec4 l1_color;varying vec4 l1_diffuse;varying vec3 l1_lightDir;varying float l1_dist;uniform vec3 l0_pos;uniform vec4 l0_color;varying vec4 l0_diffuse;varying vec3 l0_lightDir;varying float l0_dist;void main(){gl_Position = completeMatrix * gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0;vec4 pos = modelMatrix * gl_Vertex;if (lightMode == 0){l0_diffuse = gl_Color;}else if (lightMode == 1){normal = normalize(normalMatrix*gl_Normal);vec3 aux = vec3(l1_pos.x-pos.x,l1_pos.y-pos.y,l1_pos.z-pos.z);l1_dist = length(aux);l1_lightDir = normalize(aux);l1_diffuse = gl_Color * l1_color;;aux = vec3(l0_pos.x-pos.x,l0_pos.y-pos.y,l0_pos.z-pos.z);l0_dist = length(aux);l0_lightDir = normalize(aux);l0_diffuse = gl_Color * l0_color;;}else if (lightMode == 2){vec3 aux = vec3(l1_pos.x-pos.x,l1_pos.y-pos.y,l1_pos.z-pos.z);l1_dist = length(aux);l1_diffuse = gl_Color * l1_color;;aux = vec3(l0_pos.x-pos.x,l0_pos.y-pos.y,l0_pos.z-pos.z);l0_dist = length(aux);l0_diffuse = gl_Color * l0_color;;}}and here's the errors it gives me (29) : error C1008: undefined variable "l0_contibution"(35) : error C1008: undefined variable "l0_contibution"(42) : error C1008: undefined variable "l0_contibution"(65) : error C1008: undefined variable "l1_contribution"(65) : error C1008: undefined variable "l1_contribution"(65) : error C1008: undefined variable "l1_contribution"(65) : error C1008: undefined variable "l1_contribution"(79) : error C1008: undefined variable "l1_contribution"(88) : error C1008: undefined variable "l1_contribution"(88) : error C1008: undefined variable "l1_contribution"(88) : error C1008: undefined variable "NdotL"(88) : error C1008: undefined variable "l1_contribution"(88) : error C1008: undefined variable "NdotL"(88) : error C1008: undefined variable "l1_contribution"(88) : error C1008: undefined variable "NdotL"(94) : error C1008: undefined variable "NdotL"(94) : error C1008: undefined variable "NdotL"(94) : error C1008: undefined variable "NdotL"(96) : error C1008: undefined variable "l1_contribution"Thnx in Advance!   
  these are syntax errors. for example you declared l0_contribution and l1_contibution and used l1_contribution and l0_contibution! NdotL is declared but is not visible in the block code after "if (lightMode == 2)" where it's used. You should declare it before "if (lightMode == 2)" or redeclare it in every code block where it's used.Like in C++ when you declare a variable in a block it will only be visible in that block and the nested blocks inside it. Quote:im probely using some bad naming conventions and the logic might stil be flawed but for now my only concern is the error its giving me.The answer is in your question! [smile];  thnx for pointing that out... i gues i was a bit too hasty with this and then decided to blame the driver for giving me bad error messegas :P since i dont have as much faith in it yetEDIT: with this i finaly got rid of all fixed functionality in my engine. i use my own matrix and quaternion math and i got per pixel lights working( might not be much but its a lot for me), thnx for all the help from everyone (for whoever actualy read this far and helped me with the all the questions ive asked in the gamedev.net forums up til now :P)[Edited by - EternityZA on May 2, 2009 6:26:37 PM]