- Home /
How do I draw lines on the edges of meshes?
I simply want to draw custom lines on the edges of meshes, for example on a cube, while hiding the segments that are invisible to the game's camera. To create a toony look. A bit like the standard toon shader that's included, but I also want to draw lines on edges that you see in the middle of the mesh, not only at the currently visible borders.
Answer by jonas-echterhoff · Jan 17, 2010 at 03:14 PM
The standard toon shaders approach to drawing the outlines is to draw the backfacing triangles of the shape in the outline color, and scale them up a little using the normals. This won't work for drawing edges in the middle of the mesh, though.
One approach to do that is to render the normals to the screen color buffer (using shader replacement, and a custom shader to render the normals to the screen), and then, using an image post-processing effect, to detect pixels where the normals are very different from the neighbor pixels, and draw those in the outline color.
Your answer
Follow this Question
Related Questions
How do I make a boat that doesn't let water enter?,How do I make a boat that water cant get in to 2 Answers
Complex Depth Shader 0 Answers
double-sided plane with texture? 4 Answers
my game texture not rendering on android and ıos devices unity 2019.2 version 0 Answers
Force a custom surface shader to not compile a deferred pass? 0 Answers