tags:

views:

525

answers:

3

I've got a pretty simple situation that calls for something I don't know how to do without a stencil buffer (which is not supported on the iPhone).

Basically, I've got a 3D model that gets drawn behind an image. I want an outline of that model to be drawn on top of it at all times. So when it's behind the image, you can see its outline, and when its not behind the image you can see a model with an outline.

An option to simply get an outline working would be to draw a wireframe of the model with thick lines and a z offset, then draw the regular model on top of it. The problem with this is obviously that I need the outline to be drawn after the model.

This method needs to be fast, as I'm already pushing a lot of polygons around - full-on drawing of the model again in one way or another is not really desired.

Also, is there any way to find out whether my model can be seen at the moment? That is, whether or not the image over top has an opaque section at the position of the model, or if it has a transparent section. If I can figure this out (again, very quickly), then I can just draw a wireframe instead of a textured model, depending on if it's visible.

Any ideas here? Thanks.

A: 

http://research.microsoft.com/en-us/um/people/hoppe/proj/silmap/ Is a technical paper on the matter. Hopefully there's an easier way for you to accomplish this ;)

Walt W
This is beyond me. :-) Thanks a lot for the suggestion, though.
Eli
A: 

Here is a general option that might produce the effect you want (I have experience with OGL, but not iPhone):

Method 1

  1. Render object to texture as pure white, separate from scene. This will produce a white mask where the object would be rendered.

  2. Either draw this directly to the screen with alpha fade for a "full object", or if you're intent on your outlines, you could try rendering THIS texture to another texture, slightly enlarged, then render the original "full object" shading over this enlarged texture as pure black. This will create a sort of outline texture that you could render over the top of the scene.

Method 2

Edit out. Just read the "no stencil buffer" stipulation.

Does that help?

Walt W
A: 

most of the time you can re-create stencil effects using the alpha channel and render-to-texture if you think about it ...

Goz
That works, actually. Thanks.
Eli