I'm developing an Android 2.2 application with OpenGL ES 2.0 stuff in C++.
Here are my vertex and fragment shader:
static const char* cubeMeshVertexShader = "
attribute vec4 vertexPosition;
attribute vec4 vertexNormal;
attribute vec2 vertexTexCoord;
varying vec2 texCoord;
varying vec4 normal;
uniform mat4 modelViewProjectionMatrix;
void main()
{
gl_Position = modelViewProjectionMatrix * vertexPosition;
normal = vertexNormal;
texCoord = vertexTexCoord;
}
";
static const char* cubeFragmentShader = "
precision mediump float;
varying vec2 texCoord;
varying vec4 normal;
uniform sampler2D texSampler2D;
void main()
{
gl_FragColor = texture2D(texSampler2D, texCoord);
}
";
I'm very new on OpenGL ES 2.0 development.
Someone told me that if I want lights on my render I have to make some complicates modification on vertex and fragment shader. So, I don't how to do that, normals are not necessary.
My question is:
How do I modify vertex and fragment shaders for not using normals?
Thanks
normal = vec4(inverse(transpose(mat3(modelViewProjectionMatrix))) * vertexNormal.xyz, 0.0);
in a vertex shader. – kvark