Introduction
(you can skip this part)
It's been three days I've been trying to implement a "portal" system, think stuff like mirrors, portals, or the anti-chamber magic cubes (which is actually closer to what I want to make): https://www.youtube.com/watch?v=lFEIUcXCEvI&t=540
I don't know how shaders and stencil buffer work so I took another approach from the video above, I first tried doing my own projection to project exactly the view through the square from the camera and use that as a texture. After many many many attempts and getting a result that is close to what I want but not perfect ( https://assets.octodon.social/media_attachments/files/110/131/577/276/727/398/original/dca92e31c6baf718.mp4 ) I realised what I wanted to do was a projection on a near plane that is tilted and not orthogonal to the camera direction. There is no shorthand for that and it would have involved me messing with 4x4 matrixes (something like this I guess, but not only for the frustum, for the whole projection: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf ), which I considered for a short time but I was like "nah"
Then I took a different approach, the one described in this video/article:
https://www.youtube.com/watch?v=cWpFZbjtSQg
https://tomhulton.blogspot.com/2015/08/portal-rendering-with-offscreen-render.html
It involves rendering everything and then cropping the result using UV-mapping
I arrived again at a result that is close to what I want but not exactly, I tried many different variations, I found the result that I had before with the projection even, but when I did things properly (either calculating things myself or using camera.world_to_ndc) I had a weird artifact: https://assets.octodon.social/media_attachments/files/110/137/465/669/386/893/original/25b308cc270d1ac4.mp4 (ignore the fact that the cube texture looks crispier, I just changed linear interpolation to nearest in between)
I'm a professional programmer who works on games, web and VR/AR applications. With my videos I like to share the wonderful world of programming with everyone!
What are "non-euclidean" games and how do they work? We'll discuss the inner workings of games like Antichamber and Superliminal as well as discussing the theory behind non-euclidean geom...
Experimenting with portals, for science.
The project is available here: https://github.com/SebLague/Portals/tree/master
If you'd like to get early access to new projects, or simply want to support me in creating more videos, please visit https://www.patreon.com/SebastianLague
Resources I used:
http://tomhulton.blogspot.com/2015/08/portal-rende...