   Per-pixel lighting won't show textures
  I am using per-pixel lighting in my game but it causes the textures to not show up.This is what I mean:Any ideas? By the way, I am using multi-texturing for the textures if that has any effect on per-pixel lighting.   
  As soon as you start using shaders for anything, you have to replace your entire rendering pipeline with shaders.Therefore you will need to add in the texturing code into your shader in order to have textures working.Lighthouse3D have a good tutorial on shaders which should point you in the right direction.   ;  Is it as easy as adding a few lines to these shaders?Fragment shader:varying vec3 normal, lightDir, halfVector;void main(){vec4 diffuseLight, specularLight;float shine = 64.0;vec3 n = normalize(normal);float lightIntensity = max(dot(n, normalize(lightDir)), 0.0);diffuseLight = lightIntensity * gl_LightSource[0].diffuse;specularLight = pow(max(dot(n, normalize(halfVector)), 0.0), shine) * gl_LightSource[0].specular;gl_FragColor = diffuseLight + specularLight + gl_LightSource[0].ambient;}Vertex shader:varying vec3 normal, lightDir, halfVector;void main(){vec4 worldPos;normal = normalize(gl_NormalMatrix * gl_Normal);worldPos = gl_ModelViewMatrix * gl_Vertex;lightDir = normalize(vec3(gl_LightSource[0].position - worldPos));halfVector = normalize(gl_LightSource[0].halfVector.xyz);gl_Position = ftransform();} ;  In your Vertex Shader add:gl_TexCoord[0] = gl_MultiTexCoord0;gl_TexCoord[1] = gl_MultiTexCoord1;Add a new line, and increment the number at the end accordingly, for each texture you are using.You will need to add the following line at the top of your Pixel Shader:uniform sampler2d tex0, tex1,... ;   - Add a new sampler for each texture you are usingThen, at the end of your Pixel Shader:vec4 texel;texel = texture2D(tex0, gl_TexCoord[0].st) + texture2D(tex1, gl_TexCoord[1].st)... ; add each part of each texture;;  Woohoo! The textures now show up. But I don't have per-pixel lighting yet, only per-vertex lighting. And I'm getting an error from glGetError().Is this correct:varying vec3 normal, lightDir, halfVector;void main(){vec4 worldPos;normal = normalize(gl_NormalMatrix * gl_Normal);worldPos = gl_ModelViewMatrix * gl_Vertex;lightDir = normalize(vec3(gl_LightSource[0].position - worldPos));halfVector = normalize(gl_LightSource[0].halfVector.xyz);gl_Position = ftransform();gl_TexCoord[0] = gl_MultiTexCoord0;gl_TexCoord[1] = gl_MultiTexCoord1;} And:varying vec3 normal, lightDir, halfVector;uniform sampler2d tex0, tex1;void main(){vec4 diffuseLight, specularLight;float shine = 64.0;vec3 n = normalize(normal);float lightIntensity = max(dot(n, normalize(lightDir)), 0.0);diffuseLight = lightIntensity * gl_LightSource[0].diffuse;specularLight = pow(max(dot(n, normalize(halfVector)), 0.0), shine) * gl_LightSource[0].specular;gl_FragColor = diffuseLight + specularLight + gl_LightSource[0].ambient;vec4 texel;texel = texture2D(tex0, gl_TexCoord[0].st) + texture2D(tex1, gl_TexCoord[1].st);};  You need to add texel to your gl_FragColor line at the end, so move those two lines before it, and then put + texel at the end.   ;  Nope, I'm still getting an error from glGetError() and I'm still only getting per-vertex lighting. :/varying vec3 normal, lightDir, halfVector;void main(){vec4 worldPos;normal = normalize(gl_NormalMatrix * gl_Normal);worldPos = gl_ModelViewMatrix * gl_Vertex;lightDir = normalize(vec3(gl_LightSource[0].position - worldPos));halfVector = normalize(gl_LightSource[0].halfVector.xyz);gl_Position = ftransform();gl_TexCoord[0] = gl_MultiTexCoord0;gl_TexCoord[1] = gl_MultiTexCoord1;} varying vec3 normal, lightDir, halfVector;uniform sampler2d tex0, tex1;void main(){vec4 diffuseLight, specularLight;float shine = 64.0;vec3 n = normalize(normal);float lightIntensity = max(dot(n, normalize(lightDir)), 0.0);diffuseLight = lightIntensity * gl_LightSource[0].diffuse;specularLight = pow(max(dot(n, normalize(halfVector)), 0.0), shine) * gl_LightSource[0].specular;vec4 texel;texel = texture2D(tex0, gl_TexCoord[0].st) + texture2D(tex1, gl_TexCoord[1].st);gl_FragColor = diffuseLight + specularLight + gl_LightSource[0].ambient + texel;};  You will be getting an Error as a result of the Shader not compiling for whatever reason. This will be the reason that it is reverting back to fixed function pipeline, hence the per-vertex lighting.Try removing the code you added so that it works for just a single texture.Once that's done, try adding it back in line-by-line and see where the problem is.   ;  I found that changing sampler2d to sampler2D made the error go away but now I'm back where I started and I'm not getting any texture, but this is what it looks like now:varying vec3 normal, lightDir, halfVector;uniform sampler2D tex0, tex1;void main(){vec4 diffuseLight, specularLight;float shine = 64.0;vec3 n = normalize(normal);float lightIntensity = max(dot(n, normalize(lightDir)), 0.0);diffuseLight = lightIntensity * gl_LightSource[0].diffuse;specularLight = pow(max(dot(n, normalize(halfVector)), 0.0), shine) * gl_LightSource[0].specular;vec4 texel;texel = texture2D(tex0, gl_TexCoord[0].st) + texture2D(tex1, gl_TexCoord[1].st);gl_FragColor = diffuseLight + specularLight + gl_LightSource[0].ambient + texel;}varying vec3 normal, lightDir, halfVector;void main(){vec4 worldPos;normal = normalize(gl_NormalMatrix * gl_Normal);worldPos = gl_ModelViewMatrix * gl_Vertex;lightDir = normalize(vec3(gl_LightSource[0].position - worldPos));halfVector = normalize(gl_LightSource[0].halfVector.xyz);gl_Position = ftransform();gl_TexCoord[0] = gl_MultiTexCoord0;gl_TexCoord[1] = gl_MultiTexCoord1;} [edit]Oops, I had the diffuse and ambient light set too high.I now set it lower and set ambient light to 0, but no matter how low I set the diffuse light I get this:I have the diffuse light set to:Quote:float whiteDiffuse[] = {0.005f, 0.005f, 0.005f, 1.0f};[Edited by - polyfrag on April 15, 2009 3:48:46 PM];  It's:gl_FragColor = texel * (diffuseLight + gl_LightSource[0].ambient) + specularLight;I think.Emiel1   