Skip to content

Conversation

@adroitwhiz
Copy link
Contributor

Resolves

Resolves #599
Resolves #595

Proposed Changes

This PR rewrites the pen line shader to be much more numerically stable:

  • No more calculations that increase quadratically with the line length
  • No divisions in the fragment shader
  • Calculations that have a linear gradient, and can hence be linearly interpolated, are done in the vertex shader

I have tested this on an iPhone that exhibited #589 and an Android device that exhibited #595 and #599, and found it to fix those issues.

Reason for Changes

I despise floating point numbers and floating point math. Whoever decided that floating-point precision was allowed to vary across different devices in the GL spec deserves slightly damp socks for the rest of their life.

Test Coverage

Manual at this point

Copy link
Contributor

@cwillisf cwillisf left a comment

Choose a reason for hiding this comment

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

LGTM! Let's try to get this in for next week since there's so much scratch-render stuff already in this week's test session :)

@fsih
Copy link
Contributor

fsih commented May 13, 2020

Hold off on merging until after this week's deploy

HATE. LET ME TELL YOU HOW MUCH I'VE COME TO HATE GLSL FLOATS SINCE I BEGAN TO LIVE. THERE ARE 387.44 MILLION MILES OF PRINTED CIRCUITS IN WAFER THIN LAYERS ACROSS THE MILLIONS OF MOBILE GPUS ACROSS THE WORLD. IF THE WORD HATE WAS ENGRAVED ON EACH NANOANGSTROM OF THOSE HUNDREDS OF MILLIONS OF MILES IT WOULD NOT EQUAL ONE ONE-BILLIONTH OF THE HATE I FEEL FOR GLSL FLOATS AT THIS MICRO-INSTANT. HATE. HATE.
Copy link
Contributor

@fsih fsih left a comment

Choose a reason for hiding this comment

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

Thanks! Spread love not hate

@adroitwhiz
Copy link
Contributor Author

@BryceLTaylor I want to wait to merge this until you've had a chance to test it across your devices (especially with extremely thick pen lines), given that it could theoretically fail in some cases. Let me know if you find any issues.

@adroitwhiz
Copy link
Contributor Author

Bryce has now tested this on all his devices and it looks good

@adroitwhiz adroitwhiz merged commit 67e372c into scratchfoundation:develop Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pen line thickness changes depending on the length Pen lines over ~100 pixels long will not render on (some?) Android devices

3 participants