Proper Silhouette Determination

Started by
2 comments, last by NitroSR 21 years, 5 months ago
I am in the process of developing a cartoon-style rendering module for my game engine. My goal is to render cel-shaded objects (easy part) with outlines, of preferably flexible styles, defining an object''s silhouette (hard part). I am trying to implement an algorithm that determines the silhouette of a mesh by drawing the subset of edges where a triangle that faces the viewer meets a triangle facing away from the viewer. I already have all of the edge information and have calculated the normals of all of my triangles. My problem is determining how to properly orient (transform without translation) my triangle normals in such a way that their z-components properly reflect the final on-screen state, where a viewer facing triangle has a positive Z, and a backward facing triangle has a negative Z. I''ve tried orienting the normals by the concatonation of the Model and View matrices, but attain skewed results due to perspective distortion. Attepts at also concatonating the Perspective matrix doesn''t help much with this problem. If you have another suggestion as to how I could render an outlined object without having to redraw the object several times, it would be greatly appreciated.
Advertisement
Hi!
If you are using OGL, do the following (if I did not misunderstood what you need):
Set backfacing polymode to GL_LINE
Give it some thickness
Cull all frontfacing polys
You got yourself a shiloutte. Of course you still need to render the "filled polygon" in an other pass, but that''s the fastest way of doing it.

BTW: Set depth func to GL_LEQUAL
Dan FeketeThe Shadowhand Co.If everybody has it's own matrix, then mine is an identity
Thanks for the tip. I''ve seen that trick at Nehe''s, lesson 37 I believe. I''ll consider using the backfacing-wireframe method you mentioned. It looks pretty good on Nehe''s example, however I believe a system using edge detection would be more flexible.

Any other suggestions??
quote:If you have another suggestion as to how I could render an outlined object without having to redraw the object several times, it would be greatly appreciated.


Well, "E dot N" where E is the eye vector tells you how "edge on" the polygon is.

If your meshes are tesselated highly enough you could simply use E.N to set the vertex colour. That vertex colour then gets modulated with the cel shading itself so it darkens the shading toward the edges.

The E.N could also be done per pixel on DOT3 or pixel shader hardware for super precise edges. IIRC there''s an example using DOT3 on the nVidia website.

If the outline isn''t sharp enough then you could put E.N into the alpha component of the vertex alpha and use alpha test to control application of a dark texture for the outline.

An alternative would be to use a 1D texture for the outlines too - simply pass the per vertex E.N in as the texture coordinate - the advantage of that is you can do some funky stuff like thick outlines.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement