At the moment I have one vertex/fragment shader, but I am looking to add another shader program to deal with shadow maps. In my "final" shader I have VAO which define positions, normals, texcoords, tangents, bitangents, etc and in my shadow map shader I only need the positions...
Final pass shader:
layout(location = 0) in vec3 vert_position; \n \
layout(location = 1) in vec3 vert_normal; \n \
layout(location = 2) in vec2 vert_texcoord; \n \
layout(location = 3) in vec3 vert_tangent; \n \
layout(location = 4) in vec3 vert_bitangent; \n \
Shadow map shader:
layout(location = 0) in vec3 vert_position; \n \
Code for creating VAOs
OpenGLRenderer::VAO SetupVAO(OpenGLMeshPtr mesh)
{
OpenGLRenderer::VAO vao;
GLCALL(glGenVertexArrays(1, &vao));
GLCALL(glBindVertexArray(vao));
GLCALL(glBindBuffer(GL_ARRAY_BUFFER, mesh->mVBO));
GLCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->mIndexBuffer));
GLCALL(glEnableVertexAttribArray(0));
GLCALL(glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0));
GLCALL(glEnableVertexAttribArray(1));
GLCALL(glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)(mesh->mVertexDataSize)));
GLCALL(glEnableVertexAttribArray(2));
GLCALL(glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, (GLvoid*)(mesh->mVertexDataSize + mesh->mNormalDataSize)));
GLCALL(glEnableVertexAttribArray(3));
GLCALL(glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)(mesh->mVertexDataSize + mesh->mNormalDataSize + mesh->mTexCoordsSize)));
GLCALL(glEnableVertexAttribArray(4));
GLCALL(glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)(mesh->mVertexDataSize + mesh->mNormalDataSize + mesh->mTexCoordsSize + mesh->mTangentsSize)));
GLCALL(glBindBuffer(GL_ARRAY_BUFFER, 0));
GLCALL(glBindVertexArray(0));
return vao;
}
Thus my question is - should I create two VAOs per mesh, one for the shadow map and one for the final pass, or should I use the same VAO in both shaders, leaving all but position parameters unused but avoid creating/binding a new VAO? Does it have any implications doing so?
Thanks
EDIT: In short, is it detrimental to performance to supply the 5 attribute indices and their data to my shadowmap shader but only use the positions?