Light shader not working

Hi, I have a problem. I’m using single pass lighting and it works great. Directional lights, point lights and spotlights all work well - except when I have an ambient light in the scene. If i add an ambient light to the scene, everything using this shader turns black. Its like every other light is blocked out. Tho its turned off now, I did try the g_AmbientLightColor in the frag shader and it worked, but no other lights does.

I am aware single pass is not fully working (i read somewhere), but the reason I ask is I suspect this might be a simple light list issue, if its not just a simple misstake by me of course. Either way I’d like to find out.

The reason I suspect that is I have a spotlight from the camera that can be turned on and off (like a flashlight). If its off and there is an ambient light in the scene nothing works, but if I turn it on, the directional light kicks in instead of the spotlight.

Vertex shader:

It keeps erasing large portions of the code if i put it here, for some reason.

Fragment shader:

varying vec2 texCoord;


varying float fadeVal;


varying vec4 color;


varying vec3 light;


uniform sampler2D m_ColorMap;

uniform sampler2D m_AlphaNoiseMap;

void main() {

vec4 outColor = texture2D(m_ColorMap, texCoord);


outColor *= vec4(light,1.0);


outColor *= color;


if(fadeVal <= texture2D(m_AlphaNoiseMap, texCoord).x){




gl_FragColor = outColor;


Do all of your meshes have tangent buffers?

None of them have either tangent of normals. No angles are calculated, only attenuation. It works with no ambient light source in the scene, otherwise not.

The single pass rendering hasn’t been used in ages, so it doesn’t really work right now. You can take a look at Material.render() and see where the issue might be

thanks just checking.