This small demo project exploring stylized raytracing in the open source Godot engine was inspired by the game Mirror Drop and made over three days as a fun personal project.
The system consists of:
CanvasItem
nodes, as well as the camera's transform informationSince spheres are currently the only supported shape, the scene rendering shader is fairly simple:
SCREEN_UV
and provided camera informationOne nice thing about this setup is that all transformations of geometry are driven by standard Spatial
nodes (the default 3D object in Godot).
CanvasItem
node that is the 'viewport' into the raytraced scene.
Underneath is the output of a standard 3D camera showing what the scene looks like internally, using MeshInstance
nodes.
As such, the source spatial nodes can be messed with just like in a normal game.
For example the two smaller spheres in the demo are RigidBody
nodes and can be clicked on or run into to bump them around.
Physics, animation, etc. run exactly the same as always, and the resulting transformations are encoded into the scene texture which is in turn passed to the display shader.
As with Mirror Drop, the primary limitation here is having a limited set of primitive shapes to work with, so no complex models, rigs, etc. as each shape has to be mathematically defined in the display shader. However, as evidenced by that game's 2019 IGF win in the visual art category, you can still get beautiful results for a minimal aesthetic using only simple shapes and a good choice of colors.
As for future plans with this demo, I'll probably release the current version's source project once I can clean it up a little bit and document everything. I don't have any commercial aspirations for the project as is (especially since it's aiming to recreate Mirror Drop), but I hope it can serve as a learning tool for others looking to get into graphics programming, both in Godot and more generally.
That said, I do have some exciting ideas for further research and development that could potentially lead to an interesting game concept.
Don't forget to check out the in-browser demo if you want to play around with the system yourself! You can adjust the maximum number of bounces, as well as see various debug visualizations of the scene.
If you're interested in seeing more content like this, be sure to follow me on Twitter (@RajinShankar) to see whatever it is I'm up to at the moment!