- This repository contains a OpenGL / QT application where you can walk through portals, with each portal taking you to a new world, different from the original. The portal also previews the world you are about to be transported to.
- Note that each scene has an accompanying
.gif
, but it may take some time to load them on this page.
- Here, we see a simple portal, where the cat inside the world is somewhat bigger.
- Here, we see a world under some affine transformation. We support arbitrary affine transformations, when defining new worlds. In principle, you can even make a new transformation at runtime!
- Here, we see a world being rendered with a different shader. We support arbitrary shader definitions, though such shader definitions must be present at compilation.
- Here, we see that an arbitrary number of portals can be placed into a scene and each portal previews it's own respective world correctly.
- Here, we see that after entering a portal, all other portals preview (and take us back to) the home world.
- OpenGL (>=3.3)
- Qt (>= 6.2)
- QtCreator (Optional)
-
Make sure your shell's current directory is at the
src
directory. -
Run the following in your shell:
mkdir build cd build cmake .. make
-
Then run the executable that is created inside the build directory.
- Movement is with the traditional
WASD
keys with some extras:WASD
for forward, left, backward and right movement.ZX
to hover up and downQE
to pan left and rightRF
to tilt up and down
- To view scene
N
, changeMainView::currentScene
to be initialized toScene::createSceneN()
, whereN
is from0
to3
, inmainview.h
. - Moving through a portal places you inside that portal's world. Moving through any portal takes you back to the "home" (i.e: default) world.
-
The transformation itself is fairly simple, with
MainView::currentWorldEffectTransform
andMainView::currentShaderType
holding the transformation.Upon collision with the portal, these are updated appropriately, to reflect the new world we move to (either the portal world or the home world).
-
Movement involves setting a 60 FPS timer and capturing the keyboard input and updating
MainView::camera
. It creates a model transformation to be applied for other others. -
The real tricky stuff comes with rendering the portal preview. We use a stencil buffer and for each portal, run the shader. For each fragment shaded, the appropriate pixel in the stencil buffer get's set to the portal's id (essentially). Then for each portal, we render the world (after transformation) for the pixels in the stencil that are set to that portal's id.
Finally, we render any pixel that is not set in the stencil for the current world we are in.
- Currently, if there are objects within the world that are in front of the portal, the portal screen will render over it.
- There is a minor movement bug where after a 270 degree rotation, the left and right movement keys are swapped.
- The scene being rendered is hard-coded and defined at compile time.
- The code is not very pretty 😔
This project was made as part of the submission to the end-of-course competition for Computer Graphics, 2023/24.
The authors are: