Sign in to follow this  

teleporters which one can see the other side

This topic is 4727 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

Hi right now i want to do some fancy stuff with my engine, so one thing i was always quite interested in, were those portals which you can see through. So i'll give my thoughts of rendering them. So here goes my algorithm. #1 whenever a portal polygon is in the frustrum render the shape of the polygon to the Stencil Buffer( let's say fill with 1's ) #2 render the usual geometry, one places where te stencilbuffer are 0's #3 translate camere position to the place 'where the portal points' at' #4 render the geometry over there, where the stencil buffer is set to 1's #5 clear all, and do other fancy things can someone tell me if i'm doing things correct, or is there a much nicer solution for this? Cheers, Paul

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I always loved the see-though teleporters in Unreal, I never could understand why they ditched them in later versions...

Anyway, portal rendering info should be all over the 'net, I seem to remember a good article on flipcode.com on portal rendering. You've got the basic idea but you can still simplify it somewhat. I'd do:

0. Clear colour/depth/stencil buffers
1. Render current sector normally
2. Render portal poly to stencil
3. Apply portal transformation
4. Render sector seen though portal (but only where stencil is set).

Its fairly easy to get a recursive rendering method so that you start at one sector and then keep traversing though portals (rendering as you go). One easy optimisation is to keep incrementing the stencil values rather than clearing and re-setting them each time.

One thing to watch out for when doing your portal traversal is to discard portals that are back-facing (otherwise you end up in an infinite loop). For best results you keep clipping your frustum to the portal poly and test potential new portals against it before going down it (older docs will probably tell you to check all your polys against this frustrum as well but thats almost certainly a waste of time).

If you're feeling really fancy, use hardware occulsion tests to accept/discard portal polys as well. And as a fail-safe you probably want to put a maximum depth to your recursive rendering.

OT.

Share this post


Link to post
Share on other sites
Thanks, got to implement it today:)

For the rendering system, i'm only clipping the frustum to the portals, and not the polygons that are behind that portal. After the frustum has been clipped, i'm testing if the leafs(bounding box test) behind that portal are in the frustum( partially 'in' means add to rendering list )

Cheers,

Paul

Share this post


Link to post
Share on other sites
Here's another method that can do it as well:

1. Set the render target to be a renderable texture
2. Render the geometry that you see through the portal using the translated camera.
3. Set the render target to the back buffer.
4. Render the scene as usual. The portal will then use the previous render target as a texture.

This technique uses more memory, but doesn't require a stencil buffer (OK, all graphic cards supports it now...). One thing that is nice about that method is that you can apply all kind of effects to the portal, either by using some image based processing on the renderable texture between steps 2 & 3, or apply distortion by animating the texture coordinates of the portal, and so on.

Share this post


Link to post
Share on other sites
Quote:
Original post by Aldenar
One thing that is nice about that method is that you can apply all kind of effects to the portal, either by using some image based processing on the renderable texture between steps 2 & 3, or apply distortion by animating the texture coordinates of the portal, and so on.
Indeed. An EMBM bump map to peturb the per-pixel texture coordinates a bit can look really funky, allowing you to ripple or shimmer your portal.

Share this post


Link to post
Share on other sites

This topic is 4727 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this