Skip to content

Add mouse, resolution, and time-based uniforms to bloomShaderCallback #7999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev-2.0
Choose a base branch
from

Conversation

LalitNarayanYadav
Copy link
Contributor

Summary

This PR enhances the existing bloomShaderCallback in the preview/global/sketch.js example to demonstrate how commonly used uniforms can be integrated with p5.strands. The following uniforms were added:

  • mouse: current mouse position ([mouseX, mouseY])
  • resolution: current canvas size ([width, height])
  • millis: time in ms since the sketch started
  • frameCount: total number of frames rendered
  • deltaTime: time elapsed between frames

These values are passed into the shader using uniformVec2 and uniformFloat, then used in the bloom shader’s glow calculation.


This contribution addresses #7849, specifically the need to bridge p5.js values like mouseX, width, millis(), and frameCount into the p5.strands system.


Test Plan

  • Run preview/global/sketch.js
  • Observe an animated bloom glow effect modulated by:
    • Mouse X position
    • Time (millis)
    • Frame progression

The result should reflect both interactive and time-based changes.


cc: @davepagurek @ksen0 @lukeplowden

PR Checklist

@lukeplowden lukeplowden self-requested a review July 29, 2025 14:51
@lukeplowden
Copy link
Member

lukeplowden commented Jul 29, 2025

Hey Lalit! The idea for this issue is to add documentation to the reference. This is done by writing JSDoc comments which get pulled in when the p5.js website is built and reference pages are generated. Look here for the contributor guidelines for JS Doc:
https://github.com/processing/p5.js/blob/dev-2.0/contributor_docs/jsdoc.md

Once you've put this code into a JSDoc comment, commit and push the results, and then run the command npm run custom:dev your-branch-url in the p5.js-website repo again to build the site with the updated changes. You will have to clone the website repository here. This way you can also preview your documentation in the reference and make sure it all looks good there.

@davepagurek
Copy link
Contributor

Oh also in #7849 (comment) I was mentioning those uniforms as things that would be good to have as built-in nodes, so they don't need to be manually added to reference examples. So for those you'd probably need to modify the ShaderGenerator.js file like you were doing for noise and lerp.

@LalitNarayanYadav
Copy link
Contributor Author

Hi! While testing the changes locally using npm run custom:dev your-branch-url in the p5.js-website repo, I encountered schema validation errors in some .mdx tutorial files like:

  • tutorials/en/loading-and-selecting-fonts.mdx
  • tutorials/en/getting-started-with-nodejs.mdx

Just to clarify, I haven’t edited these files, the errors appeared during preview and seem unrelated to my PR. Thought I’d flag it here in case it's helpful. Thanks!

@perminder-17
Copy link
Collaborator

Hi! While testing the changes locally using npm run custom:dev your-branch-url in the p5.js-website repo, I encountered schema validation errors in some .mdx tutorial files like:

* `tutorials/en/loading-and-selecting-fonts.mdx`

* `tutorials/en/getting-started-with-nodejs.mdx`

Just to clarify, I haven’t edited these files, the errors appeared during preview and seem unrelated to my PR. Thought I’d flag it here in case it's helpful. Thanks!

Do you mind checking with the 2.0 branch of p5.js-website? That should probably work for you,
https://github.com/processing/p5.js-website/tree/2.0

Sorry, for the late response and also thanks for your patience and great work so far! :)

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.

4 participants