Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

For RenderToTexture/Camera based portal rendering, the basics seems simple enough.

However, with a free camera, most of the time it is going to be looking at such portals at an angle:

view volumes

Now a regular near clipping plane will not always work here, it will either intersect with the wall the portal is sitting on, or possibly with objects in front of the wall.

The desired near clipping plane would be aligned like the portal, producing a view volume more like this:

enter image description here

or this in 3D: enter image description here

So here is my question:

How does one construct or "truncate" a view/projection matrix to achieve such an off-camera-normal (near) clipping plane?

share|improve this question
    
Would it work to simply contain the room in a bounding box and cull everything not in the box rather than mess with an angled near plane? –  Steve H Nov 6 '12 at 13:23
    
I don't think so, as the problem is with the near plane intersecting the wall of the room or objects inside it. –  melak47 Nov 6 '12 at 17:17
    
I don't understand that statement. None of your diagrams show the near plane intersecting a wall. –  Steve H Nov 8 '12 at 0:18

2 Answers 2

You want to use the following technique to modify the projection matrix. It moves the near plane to a given location (like the plane of the portal).

http://www.terathon.com/lengyel/Lengyel-Oblique.pdf

share|improve this answer
    
Can you please outline the most central parts directly in your answer, as link-only answers are not optimal. Thank you. –  Philip Allgaier Nov 17 at 10:20

I have not implemented this myself, but I would imagine using the the stencil buffer would solve your problem. Render the portal to the stencil buffer and then render the objects in the portal's frustum. You will then get pixel-perfect culling of the object.

Here's a website with some details:

http://th0mas.nl/2013/05/rendering-recursive-portals-with-opengl/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.