SDF Shaders & Rendering
Relevant source files
The following files were used as context for generating this wiki page:
The Signed Distance Field (SDF) Shaders system provides high-quality rendering capabilities for the project, specifically focused on specialized visual effects and text rendering. Unlike standard rasterized textures, SDF shaders allow for smooth scaling and advanced graphical effects such as blurring and dynamic outlines by calculating the distance to the nearest edge of a shape at the pixel level.
In this project, the SDF system is implemented as a GameMaker prefab, providing a suite of shaders used for standard rendering, blur effects, and specialized visual enhancements. This system is critical for maintaining visual clarity across different resolutions and for rendering complex psychic and environmental effects.
Sources: prefabs/io.gamemaker.sdfshaders-1.0.0/prefab.json:1-15, prefabs/io.gamemaker.sdfshaders-1.0.0/yymanifest.xml:1-16
Shader Architecture and Components
The rendering system is comprised of three primary shader assets, each consisting of a fragment shader (.fsh) and a vertex shader (.vsh). These components are exported as GMShader resources within the GameMaker environment.
Core Shader Modules
| Asset Name | Display Name | Description |
|---|---|---|
__yy_sdf_shader | SDF Shader | The base shader for standard Signed Distance Field rendering. |
__yy_sdf_blur_shader | SDF Blur Shader | Specialized SDF shader incorporating blur algorithms. |
__yy_sdf_effect_shader | SDF Effect Shader | Advanced shader for rendering SDF-based visual effects. |
Sources: prefabs/io.gamemaker.sdfshaders-1.0.0/prefab.json:6-12, prefabs/io.gamemaker.sdfshaders-1.0.0/yymanifest.xml:5-15
Component Relationship
The following diagram illustrates the relationship between the prefab metadata and the underlying shader files.
The diagram shows how the prefab.json metadata links high-level GameMaker assets to specific vertex and fragment shader source files defined in the manifest.
Sources: prefabs/io.gamemaker.sdfshaders-1.0.0/prefab.json:1-15, prefabs/io.gamemaker.sdfshaders-1.0.0/yymanifest.xml:1-16
Visual Effects and Psychic Power Rendering
The SDF system is used to render various psychic effects defined in the game's data. These powers use specific visual tags and descriptions that correlate with the rendering styles provided by the shaders.
Visual Tags and Categories
Psychic disciplines utilize tags to define the visual "flavor" of the rendered effects:
- GLOW/GOLD: Bright, luminous effects likely utilizing the base SDF or effect shaders.
- BUR/SAL: Fire-based effects associated with the Pyromancy discipline.
- TENTACLES/THI: Distorted or organic-looking effects used in Occultism and Biomancy.
Sources: datafiles/data/psychic_disciplines.json:44-51, datafiles/data/psychic_disciplines.json:101-105
Effect Data Structure
Rendering logic for powers like "Avenge" or "Molten Beam" depends on the magnitude and range defined in the psychic data, which likely influences shader uniforms such as intensity or spread.
The flow represents how game data determines which SDF shader is invoked and how its parameters are set.
Sources: datafiles/data/psychic_powers.json:16-30, datafiles/data/psychic_disciplines.json:1-15
Console and Debug Rendering
The rendering system also interacts with the stitch configuration for console output styling. Patterns in the game console are styled with hex colors, ensuring that debug information regarding the swapchain or rendering errors is visually distinct.
| Pattern | Style (Color) | Context |
|---|---|---|
^Not recreating swapchain | #4A4A4A | Low-level rendering event |
\\berror\\b | #FF0000 | Critical rendering failure |
\\bwarn(ing)?\\b | #FFD900 | Rendering performance or asset warning |
Sources: stitch.config.json:7-22
Integration with Prefab Metadata
The system versioning and authoring are managed via prefab.json, ensuring the GameMaker IDE correctly identifies the SDF resources.
- Package ID:
io.gamemaker.sdfshaders - Version:
1.0.0 - Author: GameMaker
- Resource Type:
GMShader(Resource Version 0)
Sources: prefabs/io.gamemaker.sdfshaders-1.0.0/prefab.json:2-14
Summary
The SDF Shaders & Rendering system provides the technical foundation for high-fidelity visual effects within the ChapterMaster project. By utilizing Signed Distance Fields, the system enables smooth, scalable rendering of both UI elements and complex combat effects like psychic conflagrations. The architecture is modular, separating standard rendering from specialized blur and effect modules to optimize performance across different visual contexts.