728x90
Vec2-float noise.

#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
float random(vec2 st){
float c = fract(sin(dot(st*25., vec2(17.34,50.13)))*84239.523);
return c;
}
float noise(vec2 st){
vec2 i = floor(st);
vec2 f = fract(st);
vec2 v1 = i;
vec2 v2 = i + vec2(1., 0.);
vec2 v3 = i + vec2(0., 1.);
vec2 v4 = i + vec2(1., 1.);
float r1 = random(v1);
float r2 = random(v2);
float r3 = random(v3);
float r4 = random(v4);
f = smoothstep(0., 1., f);
float bot = mix(r1, r2, f.x);
float top = mix(r3, r4, f.x);
float ret = mix(bot, top, f.y);
return ret;
}
void main(){
vec2 coord = gl_FragCoord.xy/u_resolution;
coord.x *= u_resolution.x/u_resolution.y;
coord *= 10.;
vec3 col = vec3(noise(coord));
gl_FragColor = vec4(col, 1.0);
}

728x90
'College Study > GLSL' 카테고리의 다른 글
[GLSL] Voronoi (0) | 2022.01.06 |
---|---|
[GLSL] Gradient Noise (0) | 2022.01.06 |
[GLSL] Float-float Noise (0) | 2022.01.06 |
[GLSL] Maze and Glitch (0) | 2022.01.06 |
[GLSL] Random (0) | 2022.01.06 |
댓글