Jump to content
  • Advertisement
Sign in to follow this  
adawg1414

silhouette drawing

This topic is 4287 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've read all of the theories but I'm wondering if anyone can give me a really good way of drawing the silhouette outline on my models? I know that I can draw the model and then draw the wireframe, hence creating a fake silhouette but the problem with that is iterating through the vertices twice and drawing unnecessary lines that are not just the outer edges. Please point me in the right direction, preferably with code examples. I would love some great GLSL examples too! Thanks Aaron

Share this post


Link to post
Share on other sites
Advertisement
a difficult problem
one method similar to what u said would be set linewidth to 3 + draw the wireframe with a slight negative polygon offset , then redraw the model over the top

anothe possibilty is what i do here (orange outlines over some faces)
draw the model blurred in a color + then redraw the model over it
www.zedzeek.com/conquest_SS.jpg

another method which doesnt give a true siloette is do a
dotproduct( campos-vert, -cam forward ) if its > 0.95

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
a difficult problem
one method similar to what u said would be set linewidth to 3 + draw the wireframe with a slight negative polygon offset , then redraw the model over the top

anothe possibilty is what i do here (orange outlines over some faces)
draw the model blurred in a color + then redraw the model over it
www.zedzeek.com/conquest_SS.jpg

another method which doesnt give a true siloette is do a
dotproduct( campos-vert, -cam forward ) if its > 0.95


Understood but still not anything that I'm not already doing. There has to be a way to draw the silhouette without completely drawing all of the polygons.

Anyone?

Share this post


Link to post
Share on other sites
Which bits are you worried about? The bandwidth of supplying the polygon data twice or the pixel processing waste of overdrawing so much?

You could fix the latter with a shading program that ditches points whose camera normal is more "forward/backward" than "left/right". The result would be that only polgons which are nearly edge on would have their edges rendered.


Not sending polygons could be done in two ways -- one would be to cull by the polygon normal (in the same way that back-facing polygons are culled, you could cull ones which are front facing before sending.)

Another might be to segment your model geometry, and have a "segment normal". So a cylinder might have eight segments for each octant around its edge. And you turn the segments on and off based on how well the segment normal is aligned with the camera X axis. So you'd render between two and four segments, and lose the remainder. The remaining faces have edges which should still get you a silhouette.

Share this post


Link to post
Share on other sites
What are you trying to do? Are you trying to do Cel-Shading? There are plenty of examples on cel-shading. Try [google]

try this.
And there is some code here.

cel shading uses silhouette outlines, so you can maybe adapt it for your use.
Hope that helps.

Share this post


Link to post
Share on other sites
Not sure if this is what you were looking for... but I stumbled across this so I figured id post it.

http://www.gamedev.net/columns/hardcore/silhouettes/

Share this post


Link to post
Share on other sites
Quote:
Original post by _neutrin0_
What are you trying to do? Are you trying to do Cel-Shading? There are plenty of examples on cel-shading. Try [google]

try this.
And there is some code here.

cel shading uses silhouette outlines, so you can maybe adapt it for your use.
Hope that helps.


I've done the research and I've used the code from the Nehe link ... that's the problem, not the solution. In that simplistic example they show the thing I'm trying to avoid ... rendering the mesh twice. There HAS to be a better way. I've done the Google research, I've been to Nehe and Paul's Project.

I'm a GLSL guy too so if you know how to do it shaders, let me know.

Quote:
Original post by Katie
Which bits are you worried about? The bandwidth of supplying the polygon data twice or the pixel processing waste of overdrawing so much?

You could fix the latter with a shading program that ditches points whose camera normal is more "forward/backward" than "left/right". The result would be that only polgons which are nearly edge on would have their edges rendered.


Not sending polygons could be done in two ways -- one would be to cull by the polygon normal (in the same way that back-facing polygons are culled, you could cull ones which are front facing before sending.)

Another might be to segment your model geometry, and have a "segment normal". So a cylinder might have eight segments for each octant around its edge. And you turn the segments on and off based on how well the segment normal is aligned with the camera X axis. So you'd render between two and four segments, and lose the remainder. The remaining faces have edges which should still get you a silhouette.


Sorry, I'll explain better and leave screenshots ...

here's the code

glPushMatrix();
{
glPolygonMode(GL_BACK,GL_LINE); // Draw Lines
glCullFace(GL_FRONT); // Draw backfacing edges only

glMultMatrixf(*m_mMat.array);

// get everything ready to draw the edges
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glEnable(GL_BLEND); // Enable Blending
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Set The Blend Mode
glDepthFunc(GL_LEQUAL); // Change The Depth Mode
glPolygonMode(GL_BACK, GL_LINE); // Draw Backfacing Polygons As Wireframes
glCullFace(GL_FRONT); // Don't Draw Any Front-Facing Polygons
// set the line width and color
glLineWidth(5); // Set The Line Width
glColor3f(0.0, 0.0, 0.0); // Set The Outline Color

glBegin(GL_TRIANGLES); // Tell OpenGL What We Want To Draw
for(int j = 0; j < this->m_nNumMesh; j++)
{
unsigned short * index = (unsigned short *)Meshs[j].uIdxs.pIndices;
for(unsigned int i = 0; i < Meshs[j].nNumIndices; i++)
{
glVertex3f(m_pDeformer.m_pSkin[*index].pos.fx, m_pDeformer.m_pSkin[*index].pos.fy, m_pDeformer.m_pSkin[*index].pos.fz);
index++;
}
}
glEnd(); // Tell OpenGL We've Finished

// reset everything
glDepthFunc(GL_LESS); // Reset The Depth-Testing Mode
glCullFace(GL_BACK); // Reset The Face To Be Culled
glPolygonMode(GL_BACK, GL_FILL); // Reset Back-Facing Polygon Drawing Mode
glEnable(GL_LIGHTING);

}
glPopMatrix();










[Edited by - adawg1414 on January 31, 2007 5:56:43 PM]

Share this post


Link to post
Share on other sites
Quote:
cel shading uses silhouette outlines
I think he wants a REAL silhouette without any internal edges lines showing inside the mesh itself (judging by the screenshot). cel shading doesn't really use proper silhouettes, for info on those you might want to search for info on shadow volumes...

To get rid of those internal edge lines, you could render the outline first (back faces only, thick lines) with depth writing disabled (glDepthMask), then draw the normal mesh over it. This might cause problems if you then draw something behind the object (the edge lines would be overwritten) - you could solve this with a third pass where you draw the outlines with depth writing on, but color writing disabled (glColorMask).

Why are you so paranoid about drawing the mesh more than once? It's a hell of a lot easier than calculating which edges are part of the silhouette. On the other hand if you want stencil shadows you would need to do that anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by zppz
Quote:
cel shading uses silhouette outlines
I think he wants a REAL silhouette without any internal edges lines showing inside the mesh itself (judging by the screenshot). cel shading doesn't really use proper silhouettes, for info on those you might want to search for info on shadow volumes...

To get rid of those internal edge lines, you could render the outline first (back faces only, thick lines) with depth writing disabled (glDepthMask), then draw the normal mesh over it. This might cause problems if you then draw something behind the object (the edge lines would be overwritten) - you could solve this with a third pass where you draw the outlines with depth writing on, but color writing disabled (glColorMask).

Why are you so paranoid about drawing the mesh more than once? It's a hell of a lot easier than calculating which edges are part of the silhouette. On the other hand if you want stencil shadows you would need to do that anyway.


Ok, for one cell shading != outlines. Outlines can be put on any kind of rendering technique. I know you didn’t post that zppz but I had to address that from the other ‘poster’.

Now to address the ‘paranoia’ for rendering meshes more than once … I think it’s sad that people are ok with rendering entire meshes more than once considering that in a game you have to worry about your FPS. The game really needs to worry about collision checks, AI calculations, shadow rendering, and polygon rendering. With all of those calculations happening why would you want to add more polygon rendering on top of that? If in my game I want to render multiple characters with outlines and multiple items with outlines that could quickly drop the FPS 10+ each time something enters the view frustum because I’m rendering everything twice.

A great game example of great outlines is the Xbox360 game Crackdown. Does anyone know how they did it?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!