Today, I managed to perform contour/suggestive contour rendering in imagespace – thus working on a rendered diffuse shaded image. After using the Sobel edge detection filter to detect regular contours, I looked for an efficient algorithm to detect valleys and creases, in order to draw suggestive contours as well.
As the original paper from D. Decarlo indicates, I needed to exploit the fact that the algorithm should just work for smooth rendered images, whereas most valley detection algorithms are complicated because they provide noise robustness.
While a pixel in a valley is not necessarily the minimum intensity value in a neighborhood, it will be among a thin set of dark pixels that cuts across the neighborhood.If the valley is steep, the neighborhood will also contain significantly brighter pixels away from the valley; We can require a sufficient intensity difference that the surface must be turned meaningfully away.
The good news is that this method also detects regular contours, thus eliminating the need for the seperate sobel filter pass! GLSL code and results behind the cut.
Continue reading »
After squashing a rather nasty bug this morning (GLSL shader memory alloc is tricky), I made some renders to demonstrate the algorithm.
The algorithm is an object-space algorithm. This has some implications: Operations are performed with direct vertex info. No intermediate rendering+signal filtering is done. Rendering it on the GPU makes it hard to control line width. This is the main disadvantage in using this algorithm over a CPU-implemented one. The main advantage is – of course – significant speedup in rendering.
The current version computes info for all vertices. I think I can speed things up a bit more by adding some additional tests in the vertex shader, which could signal the fragment shader that the fragment is unlikely to have contours. Whether or not the additional overhead of these tests is worth it, we’ll see. Pretty images behind the cut.
Continue reading »
I don’t know what just happened to my shader, but this sure looks funky.

Because my current Suggestive Contours/Suggestive Highlights implementation is written using OpenGL calls for rendering, it was best to start work on the vertex/fragment shaders for a GPU implementation in the OpenGL shading language (GLSL). This would reduce OS/Platform dependency too. Another option was using Nvidia’s Cg, which claims to be compatible with an OpenGL renderer too, but documentation about this was scarce Continue reading »