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

Double precision support for all fundamental geometry classes (PShape, PVector ...) #893

Open
istinnstudio opened this issue Dec 20, 2024 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@istinnstudio
Copy link

istinnstudio commented Dec 20, 2024

Relevant sub-area for this feature?

Core/Environment/Rendering

Feature description

When using PShape and PVector calculations alongside with native Path2D.Double objects (using various conversions) there are obvious, randomly appeared but systematic rendering artifacts - rounding errors (same result when using same parameter values) upon all kinds of calculations, transformations etc. With all that CPU processing power around, I guess there is no practical reason of not adding Double coordinate support for all classes without braking compatibility with existing projects.

Benefits

Use PShape and PVector classes alongside with other classes that support natively double precision coordinates like Path2D without precision errors. Future proof Processing projects.

Possible challenges

I do not have a clue what might be the impact in codebase. I guess there should be a compatibility code care for all existing projects and default will be Float.

Additional context

An Article about the precision artifacts: https://blog.generativedarkroom.com/why-i-switched-from-processing-to-openrndr-b50c931d21ae

@SableRaf SableRaf added the enhancement New feature or request label Dec 20, 2024
@Stefterv Stefterv added the help wanted Extra attention is needed label Jan 14, 2025
@micycle1
Copy link

micycle1 commented Jan 26, 2025

There's a strong case for this change, for geometric and trigonometric operations. However it would break compatibility with older sketches if users have declared the results of PVector operations and such as float... Wouldn't bother me, but something to consider. Otherwise, it's an easy change to the codebase.

Amazingly, if you generate 100,000 floats between 0 and 1, you'll get about 300 pairs of value collisions! And 1,000,000 gives 30k collisions!

@istinnstudio
Copy link
Author

istinnstudio commented Jan 27, 2025

I have successfully created a double version of the library by brutally replacing "float" to "double" and then doing some polishing. At the end, using java2D renderer, all sketches I have tested, work ok by casting back to float or by replacing "float" to "double". As there are thousands of float references in codebase and some very common methods rely on them like "ramdom" it is a bit of an effort to support both without braking all existing sketches. Also there are color references that should, I guess, stay float as it is for native java, color bit depth is a different subject. But spatial data have a more profound prone to calculation artifacts. Also openGL renderers, I guess, should stay float anyway for the GPU internal architecture but I am not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants