arkavo-org / arkavo-org/VRMMetalKit
Deduplicate skinning logic across 3 vertex shaders
- Dominant language
- Swift
- Stars
- 6
- Forks
- 2
- Avg merge
- 18h 51m
- Merged PRs (30d)
- 26
Description
## Problem
`SkinnedShader.metal` contains three vertex shaders that each duplicate ~35 lines of identical skinning logic:
- `skinned_mtoon_vertex`
- `skinned_vertex`
- `skinned_mtoon_outline_vertex`
The duplicated code includes: weight normalization, 4-weight joint matrix accumulation, NaN/explosion safety checks, and fallback to `safeJoints[0]`.
## Impact
- Maintenance burden: any fix to skinning must be applied in 3 places
- Instruction cache pollution from the inflated shader binary
- Higher register pressure per function
## Fix
Extract a shared inline helper function:
```metal
static inline float4x4 computeSkinMatrix(
uint4 joints, float4 weights,
const device float4x4* jointMatrices,
const device float4x4* safeJoints
);
```
Call it from all three vertex shaders.
## Location
- `SkinnedShader.metal` — all three vertex functions
Contributor guide
Research direction
Open SkinnedShader.metal and compare the skinning sections in skinned_mtoon_vertex, skinned_vertex, and skinned_mtoon_outline_vertex. Confirm the shared helper preserves the listed normalization, accumulation, safety checks, and fallback behavior, and that all three vertex functions use it.
Written by the indexing model from the issue text.
Assessment
- Domain
- computer-graphics
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100