We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I do have a working processing script but the shader that I want to use (Multiple Lights with just color) returns errors:
Cannot link Shader program: Vertex info: 0(45) error C7623: implicit narrowing of type vec4 to float
I have no idea how I can fix this as I do not understand the error in this program. Thanks for help!
#define PROCESSING_LIGHT_SHADER
#define NUM_LIGHTS 8
uniform mat4 modelview;
uniform mat4 transform;
uniform mat3 normalMatrix;
uniform int lightCount;
uniform vec4 lightPosition[8];
// focal factor for specular highlights (positive floats)
uniform vec4 AmbientContribution;
in vec4 vertex;//attribute same as "in"
in vec4 color;
in vec3 normal;
varying vec4 vertColor;
void main(){
//Vertex normal direction
float light;
for (int i = 0; i < lightCount; i++){
gl_Position = transform*vertex;
vec3 vertexCamera = vec3(modelview * vertex);
vec3 transformedNormal = normalize(normalMatrix * normal);
light = 0.0f;
vec3 dir = normalize(lightPosition[i].xyz - vertexCamera); //Vertex to light direction
float amountDiffuse = max(0.0, dot(dir, transformedNormal));
// calculate the vertex position in eye coordinates
vec3 vertexViewDir = normalize(-vertexCamera);
// calculate the vector corresponding to the light source reflected in the vertex surface.
// lightDir is negated as GLSL expects an incoming (rather than outgoing) vector
vec3 lightReflection = reflect(-dir, transformedNormal);
//color=clamp(color,0.0f,1.0f);
// calculate actual light intensity
light += AmbientContribution;
light += 0.25 * amountDiffuse;
}
vertColor = vec4(light, light, light, 1) * color;
}
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
varying vec4 vertColor;
void main() {
gl_FragColor = vertColor;
}
Answers
Line 44, you are adding a vec4 to a float
It's the glsl equivalent of trying to squeeze a float array into a single float.
Don't know a fix, not enough context...
I start to question this my self. It's not my shader though.
what are you setting AmbientContribution to in the calling code?
I dumped the shader alltogether since there were many more bugs and some things just did not work out!