Skip to content

Conversation

@adroitwhiz
Copy link
Contributor

@adroitwhiz adroitwhiz commented Apr 25, 2020

Resolves

Resolves #589
Resolves #595

Proposed Changes

This PR tweaks the "epsilon" logic used in the shaders to avoid numerical instability and division by zero on low-precision hardware.

Reason for Changes

If you revert #586, the commit message will be dangerously long

iOS Safari treats "medium precision" as much lower precision than other browsers, causing some of the pen line formulas to bug out and pen dots to not be drawn. This PR tweaks those formulas to avoid such numerical issues.

As a nice side effect, pen dots' quads will now be rectangular rather than diamond-shaped, which may provide a very slight speed boost.

There's another issue on some??? GPUs where certain calculations in the line shader could overflow the floating-point range if the lines are long enough. I confirmed this on a OnePlus 6T with an Adreno 630 GPU, and someone else reported this on an ARM Chromebook on the Bugs and Glitches forum; not sure where else it may occur.

Test Coverage

Right now there's no way to test shaders across different hardware. It might be a good idea to look into whether that can be done.

I've manually tested this on an iPhone that was buggy before, and it fixes the issue.

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.

👍

@cwillisf cwillisf merged commit 4b03eb2 into scratchfoundation:develop May 6, 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 lines over ~100 pixels long will not render on (some?) Android devices Pen dots in the lower right quadrant are not drawn on iOS Safari

3 participants