It’s been a few months since I’ve updated this site, and this is because I’ve been busy preparing to start a new job overseas! That’s right, I’m moving to Prague tomorrow. I’m very excited, and expect to be even more busy for the next few months as I get settled in a new city and undergo the work on-ramping process.
As such, I thought now would be a good time to show off some of the projects and experiments that I have been working on in my spare time.
The project I’ve spent the most time on is a portal rendering system. This is an off-shoot from my time working on Liminal. For Liminal, we used the render texture method to implement our portals. This is the most common approach. For those unfamiliar with it, it uses extra cameras to capture an image of the view out of the other side of a portal, then draws that image onto the near-surface of the portal.
Render-texture portals are great for most applications, but they have some performance limitations, Each portal in view requires you to render at least one additional camera. This isn’t too bad if you are only rendering one or two portals, but the rendering costs can rise steeply when you start rendering portals “nested“ within other portals. Furthermore, this approach can also require you to disable your engine’s occlusion culling, which can be another big efficiency hit.
The alternative approach that I’ve been playing with instead makes use of a rendering feature called the stencil buffer. The stencil buffer allows shaders to mask areas of the screen, such that later shader passes can be made to behave differently on pixels inside or outside of masked areas. My system works by simply rendering copies of the rooms seen through portals. These duplicate objects are rendered with a special shader that is configured to duplicate the lighting on the original objects, but also makes them invisible unless rendered in an area of the screen covered by the correct mask. The shaders on the portal planes write to the stencil buffer, masking objects behind them on the nearside of the portal but revealing the objects and nested portals keyed to the appropriate mask layer.
This approach has the advantage that performance mostly scales in a linear fashion as portals are nested, since each nested portal more or less adds a set of copied objects to the scene. The same limitations apply as would to simply adding a lot of conventional objects to the scene. In the example video I have the maximum nesting limit turned down to four, but I’ve found that I can easily run it at 50 or 100 without a detectable dip in frame rate.
There is still a lot to do. Besides various performance optimizations, I still need to add support for dynamic objects and dynamic lighting, improve the realism of my shaders, and support for per-portal skyboxes, and implement a system to allow flicker-less camera transitions through portals.
Besides this portal system, I’ve experimented in two other areas. One is procedural generation of organic tile sets. You can see an example image in the banner’s on this site. I will try to produce better images in the future. The second project was a short game jam where I messed around with Wang tiles. I didn’t really have a game at the end of it, but I did get the tiling system operational and had some success with some visual style experiments.
It may be a while before I have time to work on these projects again, but I learned a lot from each of them and certainly plan to do more with them when I have the opportunity.