Sign in to follow this  
W3bbo

Doing 2D "Portal rendering" in XNA

Recommended Posts

W3bbo    116

I'm not talking about the 3D culling technique, but like the game Portal, but in 2D.

 

What I'm wanting to do has already been done by a couple of really simple games: ASCIIPortal ( http://cymonsgames.com/asciiportal/ ) and Portile ( http://www.increpare.com/2008/11/portile/ ), however they are both limited... ASCIIPortal is text-mode (but an amazing achievement nonetheless) and Portile which tessellatess the game world - I'm interested in duplicating ASCIIPortal's 2D "viewport" concept. Is anyone aware of any other similar games/concepts?

 

(Note that I'm not actually going to make a platformer)

 

I'm wondering what the best way to implement this is. The simplest would be to just have a single sprite surface and do all of the rendering in software, but that's just hackish.

 

I was thinking I could render the "original" 2D world to a full-screen sprite surface, then each 2D portal is a blitted copy of the original world that is  renderedto a new sprite surface layered on top of the original world but with an alpha channel that forms the "view cone" of the portal, the process is repeated as necessary in case the portal copy of a portal is visible.

 

...if I phrased that correctly.

 

I'm using XNA, if it helps.

 

Thanks in advance!

 

EDIT: I juust found out about Gateways for the Xbox ( http://marketplace.xbox.com/en-US/Product/Gateways/66acd000-77fe-1000-9115-d80258550bea ), which does the rendering effect I'm after. So at least I know it's possible, but what's the best way to do it?

Edited by Dai++

Share this post


Link to post
Share on other sites
Seabolt    781

You should be able to do it the same way portal does:
 

a.) Designate a portal

b.) Place a camera looking out from that portal

c.) Bind portal render target

d.) Draw the world using that camera. (Could be expensive, try to keep the Fov small and frustum cull)

e.) Unbind portal target

f.) Draw world

  - If you're drawing a portal surface, draw the sprite using the portal render target as the texture

  - Then draw your portal border

Share this post


Link to post
Share on other sites

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