Skip to content

feat(webgl): add texCoord parameter to getFinalColor hook#8706

Merged
davepagurek merged 7 commits intoprocessing:dev-2.0from
YuktiNandwana:feature/finalColor-texCoord-2.0
Apr 11, 2026
Merged

feat(webgl): add texCoord parameter to getFinalColor hook#8706
davepagurek merged 7 commits intoprocessing:dev-2.0from
YuktiNandwana:feature/finalColor-texCoord-2.0

Conversation

@YuktiNandwana
Copy link
Copy Markdown

Resolves #8667

Changes Made

  • Updated basic.frag, normal.frag, phong.frag, line.frag to pass texCoord to HOOK_getFinalColor()
  • Updated p5.RendererGL.js (4 places) with new hook signature
  • Updated WebGPU shaders: color.js, material.js, line.js
  • Updated p5.RendererWebGPU.js (3 places) with new hook signature
  • Updated JSDoc in p5.Shader.js
  • Added visual test (WIP - need help with correct p5.strands syntax for texCoord)

Testing

  • All existing tests pass
  • 1 pre-existing failure unrelated to this PR
  • Visual test added but needs review on correct strands syntax

cc @davepagurek - Could you help verify the correct way to access texCoord in the visual test?

@YuktiNandwana
Copy link
Copy Markdown
Author

Hi @davepagurek ! Just a gentle ping on this. All the unit tests are passing for the new texCoord parameter, but I'm currently blocked on the exact syntax for the p5.strands visual test.

Whenever you have a moment, I'd really appreciate a quick pointer on how to properly set up the visual test so I can get this PR finalized and ready for review!

@p5-bot
Copy link
Copy Markdown

p5-bot bot commented Apr 9, 2026

Continuous Release

CDN link

Published Packages

Commit hash: be41137

Previous deployments

d717067


This is an automated message.

p5.createCanvas(50, 50, p5.WEBGL);
const shader = p5.baseColorShader().modify(() => {
getFinalColor((color) => {
color = [texCoord[0], texCoord[1], 0, 1];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now this is referring to a global which I think will be undefined. I think we should try using the "flat" p5.strands api for tests here, using .begin() and .end() instead of a callback, which looks like this:

const testShader = myp5.baseFilterShader().modify(() => {
myp5.filterColor.begin();
for (let i = 0; i < 3; i++) {
if (i === 2) {
myp5.filterColor.set([i/2, 0, 0, 1]);
}
}
myp5.filterColor.end();
}, { myp5 });

Note that it also passes the p5 instance in as a parameter. In this case we'd add { p5 }, call p5.finalColor.begin(), and then set p5.finalColor.set([p5.finalColor.texCoord, 0, 1]).

@YuktiNandwana
Copy link
Copy Markdown
Author

Hi @davepagurek, thanks so much for the guidance! I've updated the visual test to use the flat API as you suggested. I also found and updated the remaining hook signatures in the framebuffer tests and missing .frag files.
All tests are now passing and fully green on my local machine!
Could you please approve the workflows so the CI can run? Ready for another look whenever you have time.

Copy link
Copy Markdown
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good now, thanks for making the updates!

@davepagurek davepagurek merged commit 5888d55 into processing:dev-2.0 Apr 11, 2026
3 checks passed
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