Use texture as shader prop - #842
Merged
Merged
Conversation
guilhermesimoes
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for a new
beforeDrawlifecycle method in WebGL shaders, allowing developers to bind additional textures and update uniforms immediately before the draw call. It includes updates to the core shader node, WebGL shader node, and documentation, as well as a new example demonstrating how to use this feature.New Shader Lifecycle Support:
beforeDrawmethod to theWebGlShaderTypeinterface, which can be used to bind extra textures or update uniforms before each draw call (src/core/renderers/webgl/WebGlShaderNode.ts, src/core/renderers/webgl/WebGlShaderNode.tsR40-R47).WebGlShaderNodeandWebGlShaderProgramto callbeforeDrawbefore rendering, and provided abindTexturehelper for texture binding (src/core/renderers/webgl/WebGlShaderNode.ts, [1];src/core/renderers/webgl/WebGlShaderProgram.ts, [2].API and Internal Changes:
CoreShaderNodeandWebGlShaderNodeto store and manage thebeforeDrawfunction, and track additional textures per draw (src/core/renderers/CoreShaderNode.ts, [1];src/core/renderers/webgl/WebGlShaderNode.ts, [2].Documentation:
beforeDrawproperty, including a code example (docs/webgl-shader-types.md, docs/webgl-shader-types.mdR164-R182).Examples:
shader-with-texture-prop.ts, demonstrating how to use thebeforeDrawmethod to bind an additional texture and pass uniforms to a custom shader (examples/tests/shader-with-texture-prop.ts, examples/tests/shader-with-texture-prop.tsR1-R157).Minor Refactoring:
glwa public property inWebGlShaderProgramto facilitate access from shader nodes (src/core/renderers/webgl/WebGlShaderProgram.ts, src/core/renderers/webgl/WebGlShaderProgram.tsL53-R49).WebGlShaderProgram.ts(src/core/renderers/webgl/WebGlShaderProgram.ts, src/core/renderers/webgl/WebGlShaderProgram.tsL23-R23).