Skip to content

About

Was a metal renderer with meshlets, now with an RHI for cross platform

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Another Renderer + pre-pre-pre-alpha game engine

I've been working on this renderer to enlighten myself on the wonders of the Metal, meshlets, RHIs, probably more when this README becomes out of date.

Then, after getting meshlet occlusion culling etc going, I decided to attempt the beginnings of a real engine, heavily AI agent written. My role for the engine aspect is more planning/reviewing/refactoring than writing everything line by line like I did for the renderer.

Meshlet Occlusion Culling YouTube Demo

The deal (explanation for renderer RHI etc)

The main branch is an ongoing project with an render hardware interface (RHI) wrapping Metal and eventually Vulkan to enable a single renderer frontend to run on multiple platforms. The approach compiles HLSL with DXC to either SPIRV directly for use with Vulkan, or dxil, which is converted directly to Metal IR using metal-shaderconverter. After half-arsing abstractions in my previous renderer iterations, VkRender2 and VulkanRenderer, it's incredibly satisfying to write a renderer without any "metal" or "vulkan" keywords.

The initial hard-coded Metal pipeline was written in Metal 3. I switched to Metal 4 for the first implementation of the RHI, only to realize it's practically unusable for anything beyond basic rendering due to a lack of GPU debugging support. I'm now supporting both Metal 3 and 4, since working without a GPU debugger/profiler is mega cursed. Update: I might be dropping Metal 3 out of laziness. Update 2: no more Metal 3 LOL.

Here's an outdated screenshot of many Sponzas culled aggressively. At time of last update, it renders ~2000 sponzas in view at ~19 ms/frame on Macbook M4 Pro at full resolution, with ~90% geometry culled, one GBuffer pass and one shading pass that applies diffuse shading.

Many Sponzas

Here's some out-of-date random Suzanne meshlets rendered with the old Metal 3 hard-coded pipeline:

Suzanne Meshlets

Here's the first meshlet-rendered Suzanne with the new RHI, with a transparent window and Comic Sans memery as a bonus:

Suzanne Meshlets New RHI

Running locally

git clone https://github.com/tonadr1022/metalrender
cd metalrender
git submodule update --init --recursive
cmake --workflow --preset release

# Optional broader demo assets: https://github.com/KhronosGroup/glTF-Sample-Assets
./scripts/download_gltf_models.sh $HOME/gltf_sample_assets
# symlink so the default config file can find the models
ln -s $HOME/gltf_sample_assets/models/gltf ./resources/models/gltf

# Run the runtime app. Without --scene it loads resources/project.toml
# startup_scene, currently resources/scenes/demo_00_cube.tscene.json.
./build/Release/bin/metalrender

# Override the startup scene explicitly.
./build/Release/bin/metalrender --scene resources/scenes/demo_cube.tscene.json

# Bounded smoke run
./build/Release/bin/metalrender --quit-after-frames 30

# Regenerate checked-in demo scene data
./scripts/generate_demo_scene_assets.py

Current Features (probably out of date)

  • RHI without API specific leaks
  • GPU driven rendering (no for loops on the CPU, (looking at you MoltenVK))
  • meshlets
  • meshlet-level and object-level occlusion culling, frustum and cone culling
  • dynamic model loading/unloading
  • Other random niceties (CVars, object pools, etc)
  • Vulkan and Metal support via the RHI

References

Third Party Libraries

Thoughts on AI Dev

Half the reason I'm writing this is for my own future reference when AI does or does not take over software dev more than it already has. During the first 6 months of work on this project, I purely hand-wrote code the artisan way in Neovim with at most Github Copilot for AI support. Then, after being exposed to the insanity of Claude Code and Cursor at work, I took the dive and got 6 months of Cursor for free. LLMs have improved substantially at graphics programming since the old days of pasting snippets into a textbox in the browser but don't seem to be at the level of fully taking over the artisan-hand-crafted approach. Thus, as of April 2026, I've moved to using Cursor Tab, which is pretty OP in itself, with Cursor agents and the occasional Codex prompt for simpler changes. I'm actively avoiding any possibility for this repo to become something that I didn't create or understand deeply. Who knows how much better coding agents will be in the future.

TODO

  • everything else

About

Was a metal renderer with meshlets, now with an RHI for cross platform

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages