0
votes

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

1
Your normal transformation code is incorrect anyway. Should be normal = vec4(inverse(transpose(mat3(modelViewProjectionMatrix))) * vertexNormal.xyz, 0.0); in a vertex shader.kvark

1 Answers

0
votes

I think there is no way around using normals if you want to have lighting. I usually export the normals from my 3d package and use those, but you can always create them on the fly in your c++ code. http://www.codeguru.com/cpp/g-m/opengl/article.php/c2681