Skip to content

Use texture as shader prop - #842

Merged
jfboeve merged 4 commits into
mainfrom
feat/shader-texture-as-prop
Jul 20, 2026
Merged

Use texture as shader prop#842
jfboeve merged 4 commits into
mainfrom
feat/shader-texture-as-prop

Conversation

@jfboeve

@jfboeve jfboeve commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces support for a new beforeDraw lifecycle 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:

  • Added an optional beforeDraw method to the WebGlShaderType interface, 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).
  • Implemented logic in WebGlShaderNode and WebGlShaderProgram to call beforeDraw before rendering, and provided a bindTexture helper for texture binding (src/core/renderers/webgl/WebGlShaderNode.ts, [1]; src/core/renderers/webgl/WebGlShaderProgram.ts, [2].

API and Internal Changes:

  • Updated CoreShaderNode and WebGlShaderNode to store and manage the beforeDraw function, and track additional textures per draw (src/core/renderers/CoreShaderNode.ts, [1]; src/core/renderers/webgl/WebGlShaderNode.ts, [2].

Documentation:

  • Added a new section to the documentation explaining the usage and purpose of the beforeDraw property, including a code example (docs/webgl-shader-types.md, docs/webgl-shader-types.mdR164-R182).

Examples:

  • Added a new test example, shader-with-texture-prop.ts, demonstrating how to use the beforeDraw method 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:

Comment thread src/core/renderers/webgl/WebGlShaderNode.ts Outdated
Co-authored-by: Guilherme Simoes <guilherme.rdems@gmail.com>
@jfboeve
jfboeve merged commit 6c6e9cc into main Jul 20, 2026
2 checks passed
@jfboeve
jfboeve deleted the feat/shader-texture-as-prop branch July 20, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants