The current plan for my thesis is to compare several implementations I made, which all have the same purpose: draw contours and suggestive contours on a given mesh, as fast as possible, as correct as possible. It’s time to review the status of the current builds of these different tools. All of them are written in C++ using OpenGL. Additional libraries are (free)GLUT (for windowing), GLEW (for extension loading) and Trimesh2 (for efficient vertex/mesh operations).
Read more behind the cut.
Worldspace, CPU-based implementation (95% finished)
- This technique works in world space. It thus operates on the vertices in 3d.
- It calculates the ndotv product, the radial curvature and the second derivative of the radial curvature for every vertex.
- Acceleration techniques:
- Ordering of tests to break quickly if no contours can be found
- Backface culling for suggestive contours
- Positive Gaussian faces are pre-filtered
- (optional) Markosian Face Picking: pick random faces. This is currently a seperate implementation, but I’m planning to incorporate it in this one.
- Performance has improved since I’m using vertexpointers instead of glVertex3fv calls, but I think I can improve it some more using Vertex Buffer Objects.
- FPS Counter and Performance Counter included.
Worldspace, GPU-based implementation (85% finished)
- This implemenation computes everything using a vertex shader program. This speeds up calculations, but by using a fragment shader program to draw the lines, we lose control over line width.
- Speeding this up over the past weeks using texture coordinates to transfer the needed data, instead of using GLSL uniforms at every vertex. This allowed me to draw using t-strips too, insted of vertex-per-vertex.
- Acceleration techniques:
- I’ve tried implementing an alternative technique using a texture map, with coordinates ranging with the radial curvature in the x direction and the second derivative of the radial curvature in the y-direction. This works too, but it is in fact a dirty hack to fake the computation.
- Optimizing GLSL shaders is not easy, since debugging GLSL is nigh impossible. I’m thinking of swapping some primitives (float32 to float16) to get faster results with acceptable quality loss.
- Some additional work is required to make the parameters controllable by the user here.
Imagespace, GPU-based implementation (60% finished)
- This technique works in image space, so on a rendered version of the mesh.
- It silently renders the mesh to the back buffer, extracts the depth map and performs Sobel Edge Detection on it, which is mighty fast.
- I still have to implement some way to detect valleys and ridges on a rendered diffuse map/normal map … Pointers welcome!
This image might not look so spectucular, but the last implementation renders the contours of this heavy (+300k faces) Armadillo model at a very interactive 10 frames/second. Vrrrrroum.