Character Rendering System
Estimated reading time: 4 minutesThe Character module is responsible for PC (Player Character) rendering enhancement, including layer extension, facial styles, hair colour gradients, and mask generation.
Layer System
The framework intercepts the game's Renderer.CanvasModels.main model and deep-merges custom layers with the original layers.
Canvas Model Target
By default, use() targets the vanilla main model only. Pass target when a mod needs to patch another canvas model.
target accepts:
Built-in Layers
The framework provides the following layer overrides:
Custom Layers
Mod developers can add or override layers via the use() method:
Target a specific model:
Target multiple models:
Dynamic target:
Layer configuration supports the following properties:
Preprocessing and Postprocessing
Character supports registering pre- and post-processing functions that run in the rendering pipeline:
Target specific canvas models for handlers:
The second handler argument is the active CanvasModel instance. Ignore it when only the render options are needed.
The framework's built-in preprocessing functions will:
- Inject mask value into
options.maplebirch.char.mask - Process hair colour gradient filters
Facial Styles
The framework extends the game's facial style system, allowing Mods to add custom facial styles and variants.
Facial Style Image Path Resolution
Facial style images are resolved in the following priority order:
img/face/{facestyle}/{facevariant}/{image}.pngimg/face/{facestyle}/{image}.pngimg/face/default/{facevariant}/{image}.pngimg/face/default/{image}.pngimg/face/default/default/{image}.png
Auto-discovery
The framework scans all loaded Mod zip files to auto-discover facial styles and variants under the img/face/ directory, and updates setup.faceStyleOptions and setup.faceVariantOptions.
Mask Generator
The mask() function is used to generate canvas mask images:
Mask values are configured via V.options.maplebirch.character.mask and V.options.maplebirch.character.rotation. For NPC sidebar, use V.options.maplebirch.npcsidebar.mask and V.options.maplebirch.npcsidebar.rotation.
Hair Colour Gradients
The framework supports Hair Colour Gradients, providing multi-colour gradient effects for side hair and fringe.
Gradients are enabled via hair_colour_style: 'gradient' and hair_colour_gradient options, supporting:
- Custom position for multiple colour nodes (stored in
V.options.maplebirch.character) - Brightness adjustment
- Blend mode (hard-light)
- Adaptive by hairstyle and hair length
Transformation System
The Transformation system allows mod authors to add custom form changes (e.g. beast, divine, demon). See Transformation for full API and configuration.
Pet Model
The framework supports deriving a standalone pet canvas model from the PC, used to display a miniature character alongside the sidebar. The pet model retains only body-related layers (base, face, hair, limbs, etc.) and excludes clothing and equipment.
The Pet model is managed via the maplebirch.char.pet namespace and supports the following configuration:
mask: mask parameterrotation: rotation angleanimated: whether to play animationsfloating: whether to floatscale: scale factor (range 0.5 -- 1.0)
See the Pet API documentation for details.
Z-Index Reference
Access Z-Index constants for character rendering via maplebirch.char.ZIndices:
Notes
- Omit
targetto patch onlymain. - Use an array for a known list of models; use a predicate only for rule-based matching.
- Prefix custom layer names with your mod name to avoid collisions.
