Fix tessellation artifacts#36
Merged
Merged
Conversation
Contributor
Author
Collaborator
|
Looks much better with this patch, thanks a lot! |
Contributor
Author
Collaborator
|
#34 is not fixed yet. This can be addressed later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fix tessellation artifacts on empty/hollow faces
Following up on the conversation from the previous PR regarding the diagonal line artifacts appearing on the detector's empty/hollow faces.
As you correctly diagnosed, this is a side effect of the tessellation process. When the GLU tessellator breaks >3-sided polygons into triangles, OpenGL faithfully draws all those internal triangle edges because the polygon mode is set to
GL_LINE(for hollow faces).While your idea of treating the filling and borders separately with two rendering passes would definitely work, there is actually a built-in OpenGL solution that is much cleaner, more performant, and avoids having to rewrite the rendering pipeline for multi-pass drawing.
The Fix:
I have implemented a fix by utilizing the
GLU_TESS_EDGE_FLAGcallback in our GLU tessellator (wsgl_tess.c).When this callback is provided, the GLU tessellator automatically emits
glEdgeFlag(GL_TRUE)for the true outer boundaries of the original polygon, andglEdgeFlag(GL_FALSE)for the internal diagonal lines it generates. OpenGL's line rendering respects this state natively and automatically hides the internal diagonals while drawing the true borders, resulting in the exact clean output you showed in the expected image.The implementation details:
tessEdgeFlagCBthat passes the boolean edge flag directly to OpenGL viaglEdgeFlag().wsgl_draw_tess_polygon().glEdgeFlag(GL_TRUE)at the end of the tessellation function to ensure the global state is reset safely for subsequent rendering commands.Please test this and tell if there is error or not