A Metal Renderer in Swift Playgrounds (Part 13)
Button and Analog Stick Inputs
Button and analog stick inputs. The buttons don’t do anything yet, but this is part of setting up the next phase which is to introduce the ability to actually fly a spaceship!
This development prepares the foundation for more interactive gameplay elements by expanding the input system beyond just camera controls to include button-based interactions.
Downsample All The Things!
I’ve had a pixelated filter working for a while, and with anti-aliasing disabled it looks very retro, but there’s still that glorious 32 bit colour. One approach I’ve looked at to getting a vintage vibe is to posterize the colours to introduce noticeably fewer colours with distinct banding. This is what it looks like with pixelated and posterization filters, and anti-aliasing disabled. The posterization level is configurable in the settings I recently added.
The combination of pixelation and color posterization creates a distinctly retro aesthetic reminiscent of classic VGA-era gaming. Having these effects configurable through the settings system allows for real-time experimentation with different vintage visual styles.
Introducing Configuration
This change adds a Settings modal with some basic configuration options: enable “control” mode where the analog stick-style input allows movement of the camera, and toggle the pixelated filter, and anti-aliasing option. I’ve wanted to make dynamic changes for a while, but the overhead of introducing configuration has put me off. I wanted something Dear ImGui like that I could render myself, but short of writing one myself (which is an option…) the quickest way was to leverage SwiftUI.
Adding configuration capabilities marks an important milestone in the project’s development. By leveraging SwiftUI for the settings interface, it becomes possible to experiment with different rendering options dynamically without rebuilding the entire application.
This entry is part of a series on writing a Metal Renderer in Swift Playgrounds.