0
votes

When I try and use gl_Normal in my GLSL vertex shader, it stays a vec3 with a 0 for the x and y components, and a 1.0 for the z component. Is there some openGL statement that enables normal calculation? I am trying to acomplish a simple shading program, I have imported a model into the world, but for some reason the built-in variable gl_Normal is not working.

1

1 Answers

4
votes

You're supposed to pass the vertex normals together with vertex positions, using glNormalPointer (or glNormal).

I suggest to import your model in a 3D modelling tool (like Blender) - it can generate the normal vectors automatically for you. Then just save it and import in your application with normals.