Hey
I’m trying to understand how I could create/access a multi UV coordinate data in my batch render.
Esentially when I create buffers it goes something like this:
glBuffer vertex = glBuffer(args);
glBuffer normals = glBuffer(args);
glBuffer indices = glBuffer(args);
glBuffer uv = glBuffer(args); /// working idea?
std::vector<vertor3> vertexList;
std::vector<vertor3> normalsList;
std::vector<int> indicesList;
std::vector<vertor2> uvList ;
for (auto *mesh:meshList){
vertexList.emplace_back(mesh->vertexList);
normalsList.emplace_back(mesh->normalsList);
indicesList.emplace_back(mesh->indicesList);
for (auto &uvData:mesh->uvList){ /// 1 mesh can have 2 channels, second mesh can have 12 channels , other mesh can have 10 channels of uv coordinates.
uvList.emplace_back(uvData);
}
}
vertex.allocate(args);
normals.allocate(args);
indices.allocate(args);
uv.allocate(args);
Bonding goes something like :
vertex.bind();
indices.bind();
shader->enableAttributeArray("position");
shader->setAttributeBuffer("position", GL_FLOAT, 0, 3, sizeof(QVector3D));
normals.bind();
shader->enableAttributeArray("color");
shader->setAttributeBuffer("color", GL_FLOAT, 0, 3, sizeof(QVector3D));
uv.bind();
shader->enableAttributeArray("uvTexCord");
shader->setAttributeBuffer("uvTexCord", GL_FLOAT, 0, 2, sizeof(QVector2D));
The rendering would go something like this :
for (auto *mesh:meshList){
shader->setUniformData(camMatrix*mesh->transform) /// for mesh position in scene;
/// I could pass here something like shader->setUniformData(mesh->uvList.size()) to pass how many uv channels that given mesh has. Then in fragment shader, I could "somehow" - thats the question here, pick the corrct uv coordinate ?
glDrawElementsBaseVertex(); //// to draw the mesh with correct offset of vertex/etc data.
Qustion is as commented above, how can I access that uv coordinate in fragment shader/vertex shader. Or else, if this is wrong, how can I do it in general? I’m lost…
Regards
Dariusz