Created
February 17, 2022 06:57
-
-
Save wewindy/7d87088c4a767bac0577c1e5d9769153 to your computer and use it in GitHub Desktop.
shader-useful-function
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
| uniform vec2 u_resolution; | |
| // 接受一个二维向量,返回一个伪随机值 | |
| float rand(const vec2 seed) { | |
| float t = dot(vec2(12.9898, 78.233), seed); | |
| return fract(sin(t) * (4375.85453 + t)); | |
| } | |
| void main() { | |
| vec2 st = gl_FragCoord.xy / u_resolution.xy; | |
| float rnd = random( st ); | |
| gl_FragColor = vec4(vec3(rnd),1.0); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://thebookofshaders.com/10/