# Multiple light pixel Shader in GLSL

I have wirtten a fragment shader that works just fine with a single light. Now I am trying to adpat it to work with 8 lights, the implement it in Processing. Clearly I am doing something wrong in the math and I cannot see what it is... I have read other posts about this and try to adapt the answer to my problem, no luck though...

////Fragment/////

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

varying vec4 vertColor;
varying vec3 ecNormal;
varying vec3 lightDir;

void main() {
vec3 direction = normalize(lightDir);
vec3 normal = normalize(ecNormal);
float intensity = max(0.0, dot(direction, normal));
gl_FragColor = vec4(intensity, intensity, intensity, 1) * vertColor;
}

////vertex/////

uniform mat4 modelview;
uniform mat4 transform;
uniform mat3 normalMatrix;

uniform vec4 lightPosition;
uniform vec3 lightNormal;

attribute vec4 vertex;
attribute vec4 color;
attribute vec3 normal;

varying vec4 vertColor;
varying vec3 ecNormal;
varying vec3 lightDir;

void main() {
gl_Position = transform * vertex;
vec3 ecVertex = vec3(modelview * vertex);

ecNormal = normalize(normalMatrix * normal);
lightDir = normalize(lightPosition.xyz - ecVertex);
vertColor = color;
}

• show us what your output is and describe what you expect it to be – ratchet freak Jan 8 '16 at 14:33
• It just wont compile. It is a version of a basic pixel ilumination shader. The previous version just supports 1 light. I am trying to adapt it so that it can process 8 lights. – eneko Jan 8 '16 at 14:44
• we'll need to see the info log from the failed compilation/linking. It's a good practice to always log it while developing. – ratchet freak Jan 8 '16 at 14:55
• I am pretty much just starting with shaders... I do get : Cannot compile frgament shader: 0(24) : error C1101: ambiguous overloaded function reference "mul(mat4, vec3") (0): mat3x4 mul(mat3x1, mat1x4) (0): mat3 mul(mat3x1, mat1x3) (0): mat3x2 mul(mat3x1, mat1x2) ... – eneko Jan 8 '16 at 15:01

vec3 transformedNormal = normalize(normalMatrix * normal);

normalMatrix is a mat4 but normal is a vec3.