André Puel
André Puel

Reputation: 9189

Drawing Outline with OpenGL ES

Every technique that I've found or tried to render outline in OpenGL uses some function that is not avaliable on OpenGL ES...

Actually what I could do is set depthMask to false, draw the object as a 3 pixels wide line wireframe, reenable the depthMask and then drawing my object. It doesnt work for me because it outline only the external parts of my object, not the internals.

The following image shows two outlines, the left one is a correct outline, the right one is what I got.

enter image description here

So, can someone direct me to a technique that doesn't is avaliable on OpenGL ES?

Upvotes: 4

Views: 2738

Answers (1)

Toji
Toji

Reputation: 34498

Haven't done one of these for a while, but I think you're almost there! What I would recommend is this:

  • Keep depthMask enabled, but flip your backface culling to only render the "inside" of the object.
  • Draw the mesh with that shader that pushes all the verts out along their normals slightly and as a solid color (your outline color, probably black). Make sure that you're drawing solid triangles and not just GL_LINES.
  • Flip the backface culling back to normal again and re-render the mesh like usual.

The result is that the outlines will only be visible around the points on your mesh where the triangles start to turn away from the camera. This gives you some nice, simple outlines around things like noses, chins, lips, and other internal details.

Upvotes: 4

Related Questions