Page 1 of 2
[HELP] How to do this portal view effect??
Posted: Thu Jul 18, 2013 5:36 pm
by XHH
I've been looking all over for the name of this game that I saw some time ago. Gateways. Randomly just remembered the name, just like that. :'D
Anyways, there's a cool effect when you make a portal in the game. You can see a view of what's in the portal even though this is a 2D game.
Here is an image:
Can this effect be acheived in Love2D and how?!?
Re: [HELP] How to do this portal view effect??
Posted: Thu Jul 18, 2013 6:14 pm
by Murii
I cant help you but i can say that this is achivable because mari0 aleardy done this.
Re: [HELP] How to do this portal view effect??
Posted: Thu Jul 18, 2013 7:44 pm
by Xgoff
my guess would be canvases + stencils + math
Re: [HELP] How to do this portal view effect??
Posted: Sat Jul 20, 2013 11:02 pm
by XHH
Xgoff wrote:my guess would be canvases + stencils + math
What is a stencil?
Re: [HELP] How to do this portal view effect??
Posted: Sun Jul 21, 2013 1:35 am
by veethree
XHH wrote:Xgoff wrote:my guess would be canvases + stencils + math
What is a stencil?
https://www.love2d.org/wiki/love.graphics.newStencil
Re: [HELP] How to do this portal view effect??
Posted: Sun Jul 21, 2013 2:12 am
by XHH
Ok but that doesn't quite explain what a stencil is and how it can be used for something like this.
Re: [HELP] How to do this portal view effect??
Posted: Sun Jul 21, 2013 2:50 am
by Davidobot
XHH wrote:Ok but that doesn't quite explain what a stencil is and how it can be used for something like this.
You would use it as a mask for the rendering.
Re: [HELP] How to do this portal view effect??
Posted: Mon Jul 22, 2013 12:35 am
by Jasoco
It's very complicated. But in simple terms, the stencil masks the drawing area and you'd have to draw everything that's supposed to be in the portal view as well as everything else that's in the camera view. Plus all the math of figuring out where the portal is and should be showing.
Re: [HELP] How to do this portal view effect??
Posted: Mon Jul 22, 2013 7:05 am
by Bobbias
You'd need to check if there are any portals that they player could see through.
Then you'd have to calculate all the angles for those lines on either side of the portal opening based on the angle between your character and the portal edges.
Then you'd have to create a stencil based on the where those lines are and stuff, so you can draw only to the parts of the screen that are "inside the portal".
Then you'd need to figure out how to draw what your character is supposed to see when he looks through the portal. Figuring this part out and actually drawing it is probably a real pain in the ass.
Re: [HELP] How to do this portal view effect??
Posted: Mon Jul 22, 2013 8:01 am
by Jasoco
Especially if you have the portals facing each other so you see yourself in both and you end up with a recursion loop where it's just mirrored you's over and over. Like when you point a video camera at a monitor that's displaying what the video camera sees.