   Wrong objects visible through portal...
  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.   
  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 );   ;  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'.;Quote:Original post by Krypt0nif 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 bzroomYou 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.   ;  It's even easier and more efficient to just set the near clipping plane as the plane of the portal.   