i've got three glsl attributes in my vertex shader
attribute highp vec4 Position;
attribute mediump vec4 UV;
attribute mediump vec3 Normal;
that im binding using
glBindAttribLocation(program, 0, "Position");
glBindAttribLocation(program, 1, "Normal");
glBindAttribLocation(program, 2, "UV");
However, i'm getting an error
Could not find vertex shader attribute 'Normal' to match BindAttributeLocation request.
Why can it find the Position and UV attributes but not the Normal attribute.
Any help would be highly appreciated as i'm pretty confused.
Cheers
Edit: I have the same issue on Android OpenGLES20. I'll add sample code : the rest of the class is the official GLSurfaceView tutorial
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
String mVertexShader = "uniform mat4 uMVPMatrix;\n " +
"attribute vec4 aPosition;\n " +
"attribute vec4 aNormal; \n " + //this is the line I added
"attribute vec2 aTextureCoord;\n " +
"varying vec2 vTextureCoord;\n " +
"void main() {\n " +
"gl_Position = uMVPMatrix * aPosition;\n" +
" vTextureCoord = aTextureCoord;\n" +
"}\n";
mProgram = createProgram(mVertexShader, mFragmentShader); // cf tutorial
if (mProgram == 0) {
return;
}
initShaderHandles(); //initializes the rest of the handles (cf tutorial)
// my little additional code
int maNormalHandle = GLES20.glGetAttribLocation(mProgram, "aNormal");
Log.d("ATTRIB LOCATION Normal: ", maNormalHandle + "");
checkGlError("glGetAttribLocation normal");
if (maNormalHandle == -1) {
throw new RuntimeException(
"Could not get attrib location for normal");
}
// ...and we crash.
}
Are you using the normal in the shader or else it can be optimized out by the glsl-compiler. If it is something else please show us your shaders
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With