View Full Version : Shader problem

03-22-2013, 08:40 AM
This is my first question here, i am using opengl es 2.0 and am currently working with a custom shader. My problem is that when i try to use the vertex normal attribute it shows nothing. I know that the normals are set correctly and the shader is seeing the normal because i can add it to position in the vertex shader and all faces will explode outward by 1.0. however if i do anything with it in anyway it simple shows nothing on screen.

below is the code for this i have commented out the parts to allow it to work. if i uncomment the normal part it simple doesn't show anything with no compile errors.

uniform mediump mat4 ModelViewMatrix;
uniform mediump mat4 ProjectionMatrix;
uniform mediump mat3 NormalMatrix;
uniform mediump vec3 LightPosition;

attribute mediump vec3 VertexPosition;
attribute lowp vec3 VertexNormal;

varying lowp vec3 LightColor;

void main(void)
mediump vec3 position = vec3(ModelViewMatrix * vec4(VertexPosition, 1.0));
//lowp vec3 normal = normalize(NormalMatrix * VertexNormal);

/* Calculate the light direction */
mediump vec3 lightdirection = normalize(LightPosition - position);

/* Calculate the intensity of the light with the dot product */
//lowp float ndotl = max(dot(normal, lightdirection), 0.0);

/* Light color = intensity * color of the light */
LightColor = vec3(1.0);

/* Transform the positions from eye coordinates to clip coordinates */
gl_Position = ProjectionMatrix * vec4(position, 1.0);

Please help!