Need to occlude objects without obstacle!

Started by
4 comments, last by someusername 18 years, 4 months ago
Hi all, I was hoping you could give me a hand with this problem I've been avoiding to deal with lately... I'm not that familiar with the sophisticated aspects yet, to be honest. I'm rendering my 3d scene with a stationary camera and I'm using a bitmap for background. (wallpaper style, nothing to do with cubic environments and stuff) The problem is, however, that I need my 3d objects to be occluded by a specific object which appears in the background bitmap. Of course things get rendered on top of it, and naturally, it looks... unnatural! I know how to recreate this object's geometry procedurally in d3d, so I'm thinking that the best solution would be to -somehow- render it directly in the z-buffer, without showing up in the viewport, so to force all other objects rendered in the same frame to be tested against it in the z comparison. This would do the job So, does anyone how to do this? Do I have to use a stencil? (these things seem pretty powerful if you get to understand how they work...) I don't want any source code. If you could just outline the steps in the procedure... Thanks in advance, all help is appreciated. Needless to point out, I'm trying to avoid the extra Clear() operation, of rendering the object normally, then Clear()ing the backbuffer without the z-buffer and then rendering my scene!
Advertisement
im going on a limb here but bair with me.

A Bitmap stores only colours specifically RGB so there is not enough information to do what you want to do.

If u had an ALPHA Channel or Colour map you can use that for the Z Buffer and simple say to yourself.

Black is Farplane (1000)
White is Nearplane (1000)

And now you can copy the pixels over pixel per pixel OR you can render a quad with a 2d texture and bump mapping enabled to set the Depth Buffer.

How ever im sure you can set your Target from a GrayScale image to GL_DEPTH_BUFFER instead of GL_ALPHA_BUFFER
----------------------------

http://djoubert.co.uk
I've read that post about six times and I'm still not sure I entirely understand.

Do you mean there is an object as part of this bitmap-backgorund that you would like to have rendered differently from the rest of the bitmap? i.e. It should appear in front of objects instead of behind?

If so, why not just use a paint program to 'cut-out' that object and then it can be rendered seperately. You can simply render the whole scene then turn off the z-buffer and render this object.

If not, please explain a little more. Maybe a screen shot of what you want and what you have would help.

Sorry if I'm a slow. I'm a bit tired.
Quote:Original post by dawidjoubert
A Bitmap stores only colours specifically RGB so there is not enough information to do what you want to do.

I'm trying to do this without using anything precalculated (like color channels), but it may become an option if things get ugly...
I had to look for a better way first, because, primarily, I have multiple views of this scene and, also, I wasn't quite sure I could blit directly to the Z buffer -just like that. Sounds reasonable, it should work fine if both surfaces have the same color format... I'll keep this in mind.

Quote:OR you can render a quad with a 2d texture and bump mapping enabled to set the Depth Buffer

I've never tried to implement bump mapping, can you be a little more specific? I'm not asking for the renderstates, but are you suggesting that I can render a bunch of pre-transformed XYZ_RHW vertices in screen coordinates and force their texture's alpha value into the z-buffer?

Quote:posted by lack o comments
Do you mean there is an object as part of this bitmap-backgorund that you would like to have rendered differently from the rest of the bitmap?
i.e. It should appear in front of objects instead of behind?

Well, sorta... this object doesn't have to be rendered and differently because I don't want it to render it in the viewport, in the place. It only exists in the background.
But it shouldn't *always* be in front of all objects. Imagine a vertical wall in my 3d scene that covers the half left part of my viewport (facing forward). Only this wall exists in the background image, its not actually rendered by the engine. Some objects in the scene should be behind it and thus occluded, others might be in front of the wall and should display properly. I can't just put the whole thing over my scene.


However, what I was talking about, is that -although my occluding object exists in the bitmap- I already have a mesh for it in direct3D. And I know exactly what its position/rotations etc should be in my d3d scene because, the background was computer generated in the first place. So I was hoping to only render its "z-imprint" on the buffer, without ever displaying it in the viewport...
Can't I make of use of the 3d geometry of the occluding object, in any way?
You can disable color channel writing via the D3DRS_COLORWRITEENABLE renderstate. While color writes are disabled, the depth buffer is still updated and taken into account.

Niko Suni

Thanks a bunch! This seems to be exactly what I was looking for.

This topic is closed to new replies.

Advertisement