Skip to content
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

Bug fixes for Shader API #7675

Draft
wants to merge 37 commits into
base: dev-2.0
Choose a base branch
from
Draft

Conversation

lukeplowden
Copy link

@lukeplowden lukeplowden commented Mar 26, 2025

Changes:
I fixed several bugs I found in the Shader API. These include:

  1. The transpiler failing to wrap some non-nodes in dynamicNode(), i.e. if they were Identifiers.
  2. uniformVector2(() => [val1, val2]) was broken as the previous implementation was wrapping vector uniforms into arrays.
  3. Sometimes when accessing components of a binary operation we would accidentally generate something like 5.000x
  4. Input structs previously would break if you changed a component such as input.color = 1. This was inconsistent with hooks which expect a built in type such as vec4.
  5. I also added some more formatting to the generated code for ease of debugging.

As a note @davepagurek now that 2 and 4 above are fixed, [] as a vector constructor is now complete. Point 2 is also compatible with the current hooks and setUniform() which do take arrays to represent vecs.

@lukeplowden lukeplowden requested a review from davepagurek March 26, 2025 16:40
@@ -203,12 +213,19 @@ function shadergenerator(p5, fn) {
}

shouldUseTemporaryVariable() {
if (this.swizzleChanged) { return true; }
if (this.type === 'sampler2D') { return false; }
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking, did you want to leave this in?

@lukeplowden lukeplowden marked this pull request as draft March 27, 2025 17:56
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