   GLSL gl_LightSource[i].position
  I keep reading that gl_LightSource.position is supposed to be in eye space, but this does not seem to be the case for me. I have an ATI card (Mobility Xpress 200). Has anyone else had this issue?Also, my program freezes up when I try to use varying matrices or arrays. I want to interpolate an array of light directions and half vectors to the pixel shader. Any idea on how I would do this? Or do I have to resort to lightDir0, lightDir1...
Quote:I keep reading that gl_LightSource.position is supposed to be in eye space, but this does not seem to be the case for me. I have an ATI card (Mobility Xpress 200). Has anyone else had this issue?It depends on when you set your light's position.  I.e., before or after gluLookAt(...).Quote:Also, my program freezes up when I try to use varying matrices or arrays.If that's the only thing that causes the crash, check your shaders' errors.  Remember that broken shaders don't work.  Also, (at least on NVIDIA) the compiler is smart enough to excise variables and routines that have no effect on the final color of the fragment.  Be sure you're using the variables in the shader before you try passing to them, or you'll wind up with -1.Quote:I want to interpolate an array of light directions and half vectors to the pixel shader. Any idea on how I would do this? Or do I have to resort to lightDir0, lightDir1...Varyings.  Use "varying float blah;" to carry information.  Arrays are probably not a good idea (and actually might not be supported).  You'll mostly want to use vec3s and vec4s.In case you haven't found this, here is a good tutorial on lighting in GLSL: http://www.lighthouse3d.com/opengl/glsl/index.php?pointlightG;  Thanks for the reply.Quote:It depends on when you set your light's position. I.e., before or after gluLookAt(...).I'm setting the light position after gluLookAt (actually I'm computing my own view matrix and using glLoadMatrix, but that's beside the point). Fixed function lighting does work correctly, which implies that it isn't an issue with when I set the light position.Quote:If that's the only thing that causes the crash, check your shaders' errors. Remember that broken shaders don't work. Also, (at least on NVIDIA) the compiler is smart enough to excise variables and routines that have no effect on the final color of the fragment. Be sure you're using the variables in the shader before you try passing to them, or you'll wind up with -1.I'm doing a check for this already. It's no longer freezing up, but it still isn't working. If I don't use an array (that is, I just compute lighting for a single light, namely gl_LightSource[0], and pass the light direction and half vectors to the fragment shader through varying vec3s) it works. If I use vec3 arrays of 1 or 2 elements (that is, I compute lighting for 1 or 2 lights and pass it to the fragment shader using the array), the object shows up, but it is black. I'm guessing this is because the variable arrays didn't get interpolated or something. If I use arrays of 3 or more elements, no compile errors are returned, but all the varyings just return -1, and the object doesn't draw at all.Quote:Varyings. Use "varying float blah;" to carry information. Arrays are probably not a good idea (and actually might not be supported). You'll mostly want to use vec3s and vec4s.That's my goal, but I need data for multiple lights to be passed to the fragment shader, and it would be much nicer to use an array than to copy and paste the code for each different variable (lightDir1, lightDir2, etc.).Quote:In case you haven't found this, here is a good tutorial on lighting in GLSL: http://www.lighthouse3d.com/opengl/glsl/index.php?pointlightI've looked at that, but unfortunately it only goes over using one light.   ;  I recommend not using built ins at all (gl_LightSource.position).Make your own uniforms, position the lights yourself.;  Thanks - I'd definitely agree with that =bOnly reason I'm using built ins (and in fact, the only reason I'm using GLSL - normally I use Cg) is because I have to extend some already existing code for a class project. They weren't very clear about where the light positions were being set - turns out they actually weren't, which was my problem. Anyway, I got that part solved. As for varying arrays, I used arrays for the loops, then at the end of my shader I just manually set each element to its own varying.   