arkavo-org / arkavo-org/VRMMetalKit
MToon: demote fragment shader intermediates to half precision
- Dominant language
- Swift
- Stars
- 6
- Forks
- 2
- Avg merge
- 18h 51m
- Merged PRs (30d)
- 26
Description
## Source
Romero perf review, item 7.
## Problem
MToon's output is LDR, non-photorealistic, clamped to [0, 1]. Fragment shader intermediates run in `float`, but Apple GPUs execute `half` at roughly 2× the throughput at no visible cost for this lighting model.
## Proposed change
Audit `MToon.metal` fragment functions and demote everything that is not position or depth to `half` / `half3` / `half4`. Keep alpha comparisons in `float` to preserve cutout edges. Gate via a strict-mode toggle so regressions can be A/B-tested.
## Affected
- `Sources/VRMMetalKit/Shaders/MToon.metal`
## Related
- #125 (per-light dedup; coordinate to avoid churn)
- #155 (MToon shader maintenance)
- #156 (CI gate to measure)
Contributor guide
Research direction
Start in Sources/VRMMetalKit/Shaders/MToon.metal and audit its fragment functions. Keep position, depth, and alpha comparisons in float as specified, demote other intermediates to half types, and add the strict-mode toggle for A/B testing. Check #125, #155, and #156 before changing the shader so the work coordinates with related maintenance and measurement.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100