Skip to content

[p5.strands] A bug which allows GLSL wrapper functions to infer genType to be int #7900

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
1 of 17 tasks
lukeplowden opened this issue Jun 10, 2025 · 0 comments
Open
1 of 17 tasks

Comments

@lukeplowden
Copy link
Member

lukeplowden commented Jun 10, 2025

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • p5.strands
  • WebGL
  • DevOps, Build process, Unit testing
  • Internationalization (i18n)
  • Friendly Errors
  • Other (specify if possible)

p5.js version

2.0

Steps to reproduce this

Steps:

Use a GLSL function such as mix(x, y, z) with a mix of floats and integer types.

Snippet:

Broken version of @davepagurek's original sketch which uncovered the issue

I wrote an explanation of the bug in the parent issue. Essentially, GLSL has built in functions for common operations, some of which have various overloads for different datatypes. In cases where a float or a vector of floats could be used, GLSL calls this genType in the documentation. There are also genIType, genBType, etc for vectors of types apart from float - see the spec here on page 146 for more details if curious.

Currently, here, p5.strands wrongly allows genType to be inferred as a type int, when only valid types should be float, vec2, vec3, vec4. This causes a misleading error message to print, but even if it didn't it would cause a GLSL error down the line.

If genType is deduced to be an integer, the FunctionCallNode will then later try to convert all of the arguments which aren't integers to be them, which is not good.

The fix should be to stop genType ever being inferred to be int. This is the only place where code needs to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Work
Development

No branches or pull requests

1 participant