Jump to content
  • Advertisement
Sign in to follow this  

Doing 2D "Portal rendering" in XNA

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

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!