Reputation: 83
I tried to make the ink lines (both outlines and inlines) by rendering the backfaces in wireframe mode, as suggested here: http://en.wikipedia.org/wiki/Cel_shading
The result with a line width of 1 is good enough:
However, when I set a thicker line width (> 3), this happens:
OpenGL render lines as quads, resulting in blank spaces between edges and a popping effect whenever the model is rotated. Also, these weird pointy edges appear when multisample is enabled:
I tried to fix the blank spaces problem by rendering vertexs as smooth points, but I cannot find a suitable way to do a depth independent blending correctly.
Can this method be improved to show nice-looking thick lines or I have to rely on shaders? If so, which is the preferred approach?
My current code:
glCullFace(GL_FRONT);
glColor3f(0,0,0);
glLineWidth(outlineWidth);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(1,1);
//draw model with GL_TRIANGLES (yeah, I know...)
glDisable(GL_POLYGON_OFFSET_LINE);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glCullFace(GL_BACK);
Upvotes: 4
Views: 3283
Reputation: 26
I think there is no easy way without shaders to achieve your goal. Usually for antialiased lines you can use glEnable(GL_LINE_SMOOTH) and glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST) (needs blending enabled as mentioned in the previous reply), but this won't render nice line caps.
You have two options:
Both solutions are much more complex that the few OpenGL lines you have above.
Upvotes: 1