[p5.js 2.0+ Bug Report]: Floats in strands shaders are always rounded to 4 decimals
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- WebGPU
- p5.strands
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.3.0
Web browser and version
All
Operating system
All
Steps to reproduce this
In strands_glslBackend.js, we do this when converting number literals into shader code:
https://github.com/processing/p5.js/blob/a5c9056fa2b3fb829a4e0187a9a9b1d7ad3700ab/src/webgl/strands_glslBackend.js#L273-L274
This means that if you include 0.00001 in your strands code, your shader code would be 0.0000. That seems like a problem. Is there any way we can do this in a more context-dependent way where we don't just add more decimals across the board for everything?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/webgl/strands_glslBackend.js at the number-literal conversion around lines 273–274, and reproduce the issue with a strands literal such as 0.00001. Trace how literals become shader code and check related coverage; done means small values retain usable precision without unnecessarily changing the formatting of other literals.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100