Last active
May 15, 2024 13:23
-
-
Save keijiro/ee7bc388272548396870 to your computer and use it in GitHub Desktop.
One liner pseudo random generator with HLSL
This file contains 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
float nrand(float2 uv) | |
{ | |
return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mikec316 ah ok yeah that is because its a well known function from long before @keijiro wrote it. Its a simple concept really, but for a more effective aproach make sure that if you are using the noise within a texture or some finite space that you divide the uv by a float2(width, height). Or multiply it, i forget. Its to make SURE there is no repeating pattern