Skip to content

Fix build*Shader methods to pass context parameter for instance mode#8537

Closed
esca-A wants to merge 1 commit intoprocessing:dev-2.0from
esca-A:fix-shader-context
Closed

Fix build*Shader methods to pass context parameter for instance mode#8537
esca-A wants to merge 1 commit intoprocessing:dev-2.0from
esca-A:fix-shader-context

Conversation

@esca-A
Copy link

@esca-A esca-A commented Feb 18, 2026

Resolves #8520

Changes

Updated the following shader builder methods in src/webgl/material.js to accept and forward a context parameter to .modify():

  • buildMaterialShader
  • buildNormalShader
  • buildColorShader
  • buildStrokeShader

Each method now accepts (cb, context) and forwards context to the corresponding base*Shader().modify(cb, context) call.

Additionally, the related load*Shader methods were updated to correctly pass this as the context when invoking the builder methods.

Why This Fix Is Needed

In the case of callback shaders, in order for the callbacks to operate in an instance (i.e., to have access to instance-specific functions), they need a reference to the correct p5 instance. This is lost if context isn't passed as an argument when calling build*Shader since it breaks instance-mode operation, so callbacks cannot be made to work with the same level of instance-specific functionality.

Therefore, by propagating the context argument throughout the build methods and their associated load functions, we restore the proper behavior for the build methods in instance mode.

Testing

  • Project builds successfully
  • No syntax errors introduced
  • Verified that context is correctly forwarded to .modify()

@esca-A esca-A closed this Feb 18, 2026
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.

1 participant