Shader support #106
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#106
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
concept:
Will shaders be available from Python (string -> shader code) or is this a "compiled-only" feature?
SFML 2.6 Shader Research (January 2026)
Executive Summary
Shaders can be loaded at runtime from strings - no compilation into a library needed.
SFML's
sf::Shaderclass wraps OpenGL GLSL shaders with a simple API:Apply when drawing:
What Effects Are Possible
Current Architecture Status
The codebase already has infrastructure shaders need:
target.draw()which accepts an optional shader parameterProposed Python API
Option 1: Per-Drawable Shaders
Option 2: Scene Post-Processing
Implementation Components
Key sf::Shader API Methods
loadFromMemory(string, Type)loadFromFile(path, Type)setUniform(name, value)sf::Shader::isAvailable()Caveats
sf::Shader::isAvailable()- some old GPUs don't support shadersPrerequisite: Harden RenderTexture Systems
Before relying on RenderTexture for shader post-processing, the existing RenderTexture infrastructure should be hardened:
render_texture/cache_subtreesystemrenderTextureand chunk textures in GridLayersThese systems work but haven't been stress-tested for the kind of multi-pass rendering that advanced shader effects require.
References
POC Complete - Design Decisions for Uniform Binding
Commit
41d551eadds a workingshader_enabledproperty to UIFrame with a hardcoded test shader. Shaders work with all RenderTexture modes (basic, clip_children, cache_subtree).Answer to original question: Yes, shaders can be loaded from strings at runtime via SFML's
sf::Shader::loadFromMemory(). No compilation into the binary required.Uniform Binding System Design
1. Engine-Provided Uniforms (Auto-Managed)
Applied FIRST every frame to all shaders:
timedelta_timeresolutionmouse2. Static Uniforms (User-Defined Constants)
3. Dynamic Uniforms
Option A: Property Binding (C++ path, fast)
getProperty()infrastructureOption B: Callable Binding (Python path, explicit)
4. Animation Integration
Extend existing animation system to target shader uniforms:
Dynamic Flag for Dirty System Integration
Critical: Shaders using
timeordelta_timedefeat RenderTexture caching.When
dynamic=True:time/delta_timeuniformsRemaining Work
glGetActiveUniformfor validation and auto-detectionsf::err()for Python exceptions on compile failureArchitecture Design - Finalized
Shared Intermediate RenderTexture
All shader-enabled drawables will use a shared screen-resolution RenderTexture for shader processing:
Rationale:
User Optimization Pattern:
For performance-critical scenarios, users wrap shader content in caching Frames:
Dirty Flag Propagation
Critical: Shader
dynamicflag must propagate through the entire UI tree.Even though Grid rebuilds its composite from cached layers each frame, if Grid is a child of a caching Frame, that parent cache is invalidated by any dynamic shader in the subtree.
Implementation:
UIDrawable::markDynamic()- sets flag and propagates to parentUIEntityparticipates in dirty propagation through its parent GridShader / Uniforms Separation
mcrfpy.Shader- Compiled program (shareable, immutable)drawable.shader- Program reference onlydrawable.uniforms- Per-drawableUniformCollectiona.shader = b.shadercopies program reference only. Uniforms are independent per-drawable.Binding Objects with Immediate Validation
UniformCollection Implementation
Render Pipeline with Shaders
Remaining Implementation Tasks
src/PyShader.h/.cppsrc/PyUniformCollection.h/.cpp486087b9cb