Jump to content
  • Advertisement
Sign in to follow this  
Erzengeldeslichtes

Wrong objects visible through portal...

This topic is 3414 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'm using the Stencil Buffer to create portals so that I can see through into another scene through some portal object. It's all working great, except when there's an object in the other scene that's relatively between the camera and the portal. The object appears in the portal, even though only objects past the portal should appear in it. It looks very odd. I know why it's happening: I only have one depth buffer to work with, and I need to reset that to 1.0 so that objects on the other side will be clipped properly. I'm having trouble thinking of solutions to this problem. The projection matrix's near plane is always flat along the view, and there's no built in way to have two depth buffers to scissor between. Would using a pixel shader with a second depth buffer work? Or is there some way to mess around with clipping planes? Any help would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
You can set clipping planes. If you're using shaders there may be a few extra tricks to get them to work.

Alternatively you can do off screen rendering as you said with another depth buffer. Or both.

ogl:
glClipPlane(GL_CLIP_PLANE0, equation)
glEnable(GL_CLIP_PLANE0)


d3d:
D3DDevice->SetClipPlane(0, equation);
D3DDevice->SetRenderState( D3DRS_CLIPPLANEENABLE, D3DCLIPPLANE0 );

Share this post


Link to post
Share on other sites
if the object is really between camera and portal (and not touchting the portal), you could also use the portal plane to cull it.
you should anyway use the portal in the other room to generate a culling frustum with the portal as 'near plane'.

Share this post


Link to post
Share on other sites
Quote:
Original post by Krypt0n
if the object is really between camera and portal (and not touchting the portal), you could also use the portal plane to cull it.
you should anyway use the portal in the other room to generate a culling frustum with the portal as 'near plane'.


While I have a frustum clipping out objects that shouldn't be visible, it works on a Model level, and the static geometry is all one model. Granted I should probably use an octree or something, but at the moment it's a proof of concept.

Quote:
Original post by bzroom
You can set clipping planes. If you're using shaders there may be a few extra tricks to get them to work.


I feel like an idiot for not finding clipping planes before. It took me a while to figure out how to take a the plane I have and transform it to clip space (the standard Transform(plane, Transpose(Transform(View * Proj))) wasn't working with the Plane object, it apparently needs to be a Vector4), but now it seems to work great.

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!