I recently started working on a 3d game prototype featuring portals, which would ideally work like in the game of the same name. I eventually managed to get the rendering of portals to work more or less properly (even recursive portals), but I have the following two issues:
- I initially wanted to apply the algorithm described here, but at the very end (before the "Code" section), it requires testing the geometry that will be drawn to the stencil against the current stencil values. It seems two people have asked about this before (link 1, link 2), but with no conclusive answers. I have done tests, and it seems that calling love.graphics.setStencilTest within the callback passed to love.graphics.stencil does not work, and looking at the LÖVE source code (specifically Graphics::setStencilTest in this file) seems to confirm this.
My question is: is there a sneaky way to do this, or is it impossible with the current LÖVE API, and should I file a bug report/feature request or not?
(FYI, I went around this issue by allocating a different stencil buffer for each possible visible portal instance, but that's increeeedibly inefficient.)
- This is unrelated to LÖVE specifically, but since I'm posting my code here, I might as well ask; in my current implementation, the stencil pattern marking portals within portals seems to partially disappear under certain viewing angles, and I can't for the life of me figure out what is erasing it. If anyone wants to take a stab at it, they are very welcome to.
Screenshot of the problem:
The .love is attached. To move, use WASD and the mouse. You can grab and move the cubes, as well as the portal in front of the starting position.
The most relevant file is 3d.lua, especially the renderView function, as well as shaders.lua for the GLSL code. I apologize in advance for the uncommentated code.