We are back, and today... Portals.
So, let's break this down.
Portals are actually a pretty simple concept. You get a camera and project what it sees into a plane. However, for our project, we are attempting to make these portals seamless.
This brings a few challenges, but thanks to my man Sebastian Lague we managed to achieve something.
So, the trick is all on making the portals' camera position and rotation relative to the position and rotation the players camera is from its linked portal. And that was a pain to understand(I suck at maths).
But after a bit of trial and error, we had a prototype that looked promising.
So I started to convert everything to C++ and that took a while. I'm still learning a lot about C++ and Unreal Engine but, after a week or so, I got my first ever portal in C++ working.
Now, all we had to do was make the character go from one side to the other. Simple right?
Wrong! This took a while, not because it wasn't working, but because it wasn't seamless when moving to another portal. I made it so you could teleport to any other actor on the scene(an actor is any object in the level), but when this actor was a Portal, you would always see it for a frame.
You could notice a flicker whenever you changed portal. One way to fix this is making the portal not a plane, but a cube and enable culling. However, I found another way, made by Froyok where you created a plane and distorted it so the player would actualy never touch it. and this seemed to fix the problem.
At this moment it was starting to look really nice and seamless. There were some times when it would flicker and I still don't know what caused it, but it was mostly working.
And that's our portal.
It's still a WIP and extremely limited. No recursion and only one portal can work at a time. Also only the character can move through it. But it was a lot of fun to work on and can be used to really confuse the player.
I also came into some limitations with the engine. If you look closely towards the shadows when looking through the portal you can see they loose a lot of definition. I think it's because the type of camera used to render the portal projection can't capture them correctly.
Thanks for reading and see you next week.