我正在用C++開發一個帶有OpenGL ES 2.0東西的Android 2.2應用程序。從頂點和片段着色器中刪除法線
這裏是我的頂點和片段着色器:
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);
}
";
對OpenGL ES 2.0的發展我很新。
有人告訴我,如果我想渲染燈光,我必須對頂點和片段着色器進行一些複雜的修改。所以,我不怎麼做,法師是沒有必要的。
我的問題是:
如何修改頂點和片段着色器不使用法線?
謝謝
無論如何,您的正常轉換代碼是不正確的。應`正常= vec4(逆(轉置(MAT3(modelViewProjectionMatrix)))* vertexNormal.xyz,0.0);`在頂點着色器。 – kvark 2011-02-11 16:32:53