Commit 1de39cde by Kai Westerkamp

rendering all patches from all Levels

parent 87d5c28e
......@@ -3,3 +3,4 @@
Q_LOGGING_CATEGORY(log_subdiv, "subdiv")
Q_LOGGING_CATEGORY(log_subdiv_trace, "subdiv.trace")
Q_LOGGING_CATEGORY(log_mesh, "mesh")
Q_LOGGING_CATEGORY(log_mesh_render, "mesh.render")
......@@ -7,5 +7,6 @@
Q_DECLARE_LOGGING_CATEGORY(log_subdiv)
Q_DECLARE_LOGGING_CATEGORY(log_subdiv_trace)
Q_DECLARE_LOGGING_CATEGORY(log_mesh)
Q_DECLARE_LOGGING_CATEGORY(log_mesh_render)
#endif
......@@ -459,14 +459,25 @@ void Mesh::renderMesh(QOpenGLShaderProgram *shader, int index, int subdivision,
// Draw Vertex Array
if(regular){
if (!entry->indices_regular.isEmpty()) {
f->glBindBuffer(GL_ARRAY_BUFFER, entry->VB_handle);
for (int depth = 0; depth < subdivision+1; ++depth) {
std::shared_ptr<SubdivEntry> depthEntry = entries[index].buffers[depth];
if (!depthEntry->indices_regular.isEmpty()) {
std::shared_ptr<SubdivEntry> depthEntryMinusOne = entries[index].buffers[depth];
if(depth > 0){
depthEntryMinusOne = entries[index].buffers[depth-1];
}
shader->setUniformValue("depth",depth);
f->glBindBuffer(GL_ARRAY_BUFFER, depthEntryMinusOne->VB_handle);
f->glVertexAttribPointer(positionIndex, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, entry->IB_regular_handle);
f->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, depthEntry->IB_regular_handle);
f->glPatchParameteri(GL_PATCH_VERTICES, 12);
f->glDrawElements(GL_PATCHES, entry->indices_regular.size(), GL_UNSIGNED_INT, 0);
//qCDebug(log_mesh)<<"Patches "<<entry->indices_regular.size()/12<<" Subdivision Level: "<< subdivision;
f->glDrawElements(GL_PATCHES, depthEntry->indices_regular.size(), GL_UNSIGNED_INT, 0);
qCDebug(log_mesh)<<"Patches "<<entry->indices_regular.size()/12<<" Subdivision Level: "<< subdivision;
}
}
} else {
if (!entry->indices_irregular.isEmpty()) {
......
......@@ -5,7 +5,6 @@ layout(vertices = 3) out;
in vec3 vPosition[];
out vec3 tcPosition[];
uniform float subdiv;
void main()
{
......
......@@ -6,17 +6,19 @@ in vec3 vPosition[];
out vec3 tcPosition[];
uniform int subdiv;
uniform int depth;
void main()
{
tcPosition[gl_InvocationID] = vPosition[gl_InvocationID];
float tesselation = subdiv;
float tesselation = subdiv-depth;
gl_TessLevelOuter[0] = exp2(tesselation);
gl_TessLevelOuter[1] = exp2(tesselation);
gl_TessLevelOuter[2] = exp2(tesselation);
gl_TessLevelInner[0] = exp2(tesselation+1);
gl_TessLevelInner[0] = exp2(tesselation);
}
......@@ -68,7 +68,7 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
input.index_buffer = entry->indices_irregular;
if (input.index_buffer.isEmpty()) {
current_mesh->update(input.vb_handle, input.vertex_buffer, input.index_buffer, entry->indices_regular);
// current_mesh->update(input.vb_handle, input.vertex_buffer, input.index_buffer, entry->indices_regular);
} else {
Tables tables = precomputeTables(input);
Result result = runShader(input, tables);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment