outline a model
I have models of tanks and stuff in my game and want there to be a thin green outline around them when they're selected. I thought about drawing each model again in GL_LINE mode but that draws all the polys as lines, not just the outline so it looks more like a net. How can I do it?
Thanks.
(please ask if I wasn't clear)
Thanks for that link.
So if I have code that draws a 3D model: DrawModel();
to get the outline I'd do:
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);
glPolygonMode (GL_BACK, GL_LINE);
glLineWidth (outlineWidth);
glCullFace (GL_FRONT);
glDepthFunc (GL_LEQUAL);
glColor3fv (&outlineColor[0]);
DrawModel();
and I'd get the outline?
Thanks.
So if I have code that draws a 3D model: DrawModel();
to get the outline I'd do:
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);
glPolygonMode (GL_BACK, GL_LINE);
glLineWidth (outlineWidth);
glCullFace (GL_FRONT);
glDepthFunc (GL_LEQUAL);
glColor3fv (&outlineColor[0]);
DrawModel();
and I'd get the outline?
Thanks.
On a similar note... are lines the "accepted" way to apply outlines to cell shading (to produce a cartoonish image)? Or is it a screen space normal direction test? (ie see which pixels are within a certain degree of perpendicular to the view direction)?
thanks
-Dan
thanks
-Dan
I tried and it didn't work. I did:
were Display() renders a model. But instead of drawing a green outlin the whole tank cameout green, it eas even textured? It was like the front facing culling wasn't working or something.
What did I do wrong?
Thanks.
Display(tank,0,false); //outline: glDisable(GL_TEXTURE_2D); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA); glPolygonMode (GL_BACK, GL_LINE); glLineWidth (5); glCullFace (GL_FRONT); glDepthFunc (GL_LEQUAL); glColor3f (0,1,0); Display(tank,0,false); glDepthFunc (GL_LESS); glCullFace (GL_BACK); glPolygonMode (GL_BACK, GL_FILL); glLineWidth (1); glDisable (GL_BLEND); glEnable(GL_TEXTURE_2D);
were Display() renders a model. But instead of drawing a green outlin the whole tank cameout green, it eas even textured? It was like the front facing culling wasn't working or something.
What did I do wrong?
Thanks.
daniel_i_l,
The other simple method is shifting(shaking) the object slightly left/right/up/down, then drawing it 4 times on the stencil buffer to make a silhouette. There is an old example at SGI site, silhouette.c It resizes glViewport instead moving the object. The result is not same as nehe lessen #37. It creates the outlines only, not all edges of the object.
The other simple method is shifting(shaking) the object slightly left/right/up/down, then drawing it 4 times on the stencil buffer to make a silhouette. There is an old example at SGI site, silhouette.c It resizes glViewport instead moving the object. The result is not same as nehe lessen #37. It creates the outlines only, not all edges of the object.
The way i did it is similar to songho's method, but without drawing it 4 times. The process goes like this:
1. Disable color writes and draw (filled) to create a mask in the stencil buffer
2. Enable color writes, set linewidth to something big (like 7) and draw again in wireframe where the stencil is not set.
This produces the same effect as his method, ie only the outline.
1. Disable color writes and draw (filled) to create a mask in the stencil buffer
2. Enable color writes, set linewidth to something big (like 7) and draw again in wireframe where the stencil is not set.
This produces the same effect as his method, ie only the outline.
Gaenor, that method sounds good. I don't know much about the stencil buffer though. Do you think that you (or someone else) could explain more? Maybe with a little code?
Thanks.
Thanks.
http://www.opengl.org/resources/features/StencilTalk/
can also be gotten as a pdf in one file
can also be gotten as a pdf in one file
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement