Archived

This topic is now archived and is closed to further replies.

Proper Silhouette Determination

This topic is 5514 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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??

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites