Created
March 10, 2022 17:13
-
-
Save VehpuS/416ba299a41f0dafe1000ce8ae966e2c to your computer and use it in GitHub Desktop.
Calculating modulo with other arithmetic functions (thanks to https://stackoverflow.com/questions/35155598/unable-to-use-in-glsl for the idea)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// neither recursion nor looping is necessary to compute a mod b. That's easily done by a - (b * floor(a/b)). | |
const mod = (a, b) => a - (b * floor(a/b)) | |
// Simple, but powerful when running on platforms that lack the function but have the floor function (i.e. GLSL for deck.gl) | |
// Thanks to https://stackoverflow.com/questions/35155598/unable-to-use-in-glsl for the idea |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment