   Can you spot why my per pixel lighting glsl shader only work on solids, not levels.
  It's a simple per pixel lighting vertex and frag shader.In the vertex shader I pass the raw vertex position into vertex coord 0 and the surface normal into texcoord 1.in the pixel shader I pass the light position and get a dot product on the light to pixel vector and then light it.On solid objects like a character/head it works fine, but on any level(i.e inside the geo rather than looking at from the outside) the shader completely fails resulting in either full bright sections of compeltely dark. parts that should be alight appear not to be.Here's the vert shader,void main(void){vec4 vFinalPosition = vec4( gl_Vertex.x, gl_Vertex.y, gl_Vertex.z , gl_Vertex.w);gl_Position = gl_ModelViewProjectionMatrix * vFinalPosition;gl_TexCoord[0].x = gl_Vertex.x;gl_TexCoord[0].y = gl_Vertex.y;gl_TexCoord[0].z = gl_Vertex.z;gl_TexCoord[1].x = gl_Normal.x;   gl_TexCoord[1].y = gl_Normal.y;   gl_TexCoord[1].z = gl_Normal.z;}Here's the frag shader,uniform vec3 lightPos;void main(void){vec3 point = gl_TexCoord[0].xyz;vec3 normal = normalize( gl_TexCoord[1].xyz);vec3 dir = normalize(lightPos-point);float dp = dot( normal,dir );vec4 final;if(dp>0){final.r = 255.0 * dp;final.g = 255.0 * dp;final.b = 255.0 * dp;}final.a = 1.0;gl_FragColor = final;}
  This might not be the cause, but why are you passing the values in the texture coordinates from the vert to the frag shader. That's what varying variables are for.It might be that your normal vectors are not pointing torwards the camera and the lighting model changes dramatically.-Riku   ;Quote:Original post by RichardoXThis might not be the cause, but why are you passing the values in the texture coordinates from the vert to the frag shader. That's what varying variables are for.Yeah. The way you're using those variables is just confusing! [smile]//// Vertex shadervarying vec3 point;varying vec3 normal;void main(void){  vec4 vFinalPosition = vec4( gl_Vertex.x, gl_Vertex.y, gl_Vertex.z , gl_Vertex.w);  gl_Position = gl_ModelViewProjectionMatrix * vFinalPosition;  // Note that you can set multiple components in a single operation.  // This may even be more efficient, depending upon how smart the GLSL compiler is.  point.xyz = gl_Vertex.xyz;  // I think you'll need to multiply by the normal matrix to get the normal  // in eye coordinates. Otherwise the lighting may break badly when you start  // moving around. (This is another possible cause of your bug.)  normal.xyz = normalize(gl_NormalMatrix * gl_Normal.xyz);}//// Fragment shadervarying vec3 point;varying vec3 normal;void main(void){  float dp = dot(normal, normalize(lightPos - point));  vec4 final;  if (dp > 0)    final.rgb = vec3(255.0 * dp);  final.a = 1.0;  gl_FragColor = final;}Quote:It might be that your normal vectors are not pointing torwards the camera and the lighting model changes dramatically.That'd be my guess. Your normals are probably pointing out of the scenery.   ;  Thanks for the suggestions. I tried your new shader code and although it compiles and still works fine on the solid meshes, it has exactly the same result on the level geo. Which is one single white plane visible for a bit then nothing. (The light is circling the scene)I just tried flipping the normals to see if they were pointing out. the only difference being the whine plane changes to a dark one much quicker. I'm lost here, it's such a simple shader and the normals are correct. makes no sense.;  screen shots might help?also, relivent drawing code... (and don't leave out things you 'think' arent' important or do 'code like this' and then give code which isnt' causing the problem as its impossible to catch errors like that...)   ;  why final.rgb = 255.0 * dp; ???try final.rgb = dp;   ;  don't use this if statement and use max(dot(n,l),0.0) to calculate diffuse intensity   