Skip to content

Instantly share code, notes, and snippets.

@wewindy
Created February 17, 2022 06:57
Show Gist options
  • Select an option

  • Save wewindy/7d87088c4a767bac0577c1e5d9769153 to your computer and use it in GitHub Desktop.

Select an option

Save wewindy/7d87088c4a767bac0577c1e5d9769153 to your computer and use it in GitHub Desktop.
shader-useful-function
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);
}
@wewindy
Copy link
Author

wewindy commented Feb 17, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment