arkavo-org / arkavo-org/VRMMetalKit
Renderer: merge color + outline + silhouette into a single tile-memory render pass
- Dominant language
- Swift
- Stars
- 6
- Forks
- 2
- Avg merge
- 18h 51m
- Merged PRs (30d)
- 26
Description
## Source
Triaged from an external Romero / id Software-style perf review. Combines two report items: outline pass merge (#2) and tile-memory exploitation (#8).
## Problem
MToon outlines are rendered as a second inverted-hull pass (`renderMToonOutlines()`), and silhouette is its own pass. On Apple Silicon's TBDR, each render pass flushes tile memory to device memory and back. Tile memory is the platform's biggest perf lever and is currently underused.
## Proposed change
Collapse color + outline (and, when active, silhouette) into a single `MTLRenderCommandEncoder`. Two complementary techniques:
1. **Single-draw outline via instancing.** Use `[[instance_id]]` in the MToon vertex shader so `instance_id == 1` produces the inverted-hull outline geometry. One `drawIndexed(..., instanceCount: 2)` call replaces two passes. (Guilty Gear Strive technique.)
2. **Programmable blending / multi-attachment** to keep silhouette and post-process intermediates in tile memory.
## Affected
- `Sources/VRMMetalKit/Renderer/VRMRenderer.swift` (`renderMToonOutlines` and pass setup)
- `Sources/VRMMetalKit/Shaders/MToon.metal`
## Related
- #88 — alternative path: outlines via Indirect Command Buffers
- #91 — crowd scalability (depth-prepass overlap)
- #164 — silhouette snapshot/restore
- #156 — must land first to measure the win
Contributor guide
Research direction
Start with Sources/VRMMetalKit/Renderer/VRMRenderer.swift, especially renderMToonOutlines and pass setup, then inspect Sources/VRMMetalKit/Shaders/MToon.metal. Review #156 before measuring, and compare the alternatives in #88 and #91. Done means color, outline, and active silhouette rendering share one MTLRenderCommandEncoder while preserving the intended output and improving tile-memory use.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- computer-graphics, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100