728x90
float amplitude = 1.;
float frequency = 1.;
y = sin(x * frequency);
float t = 0.01*(-u_time*130.0);
y += sin(x*frequency*2.1 + t)*4.5;
y += sin(x*frequency*1.72 + t*1.121)*4.0;
y += sin(x*frequency*2.221 + t*0.437)*5.0;
y += sin(x*frequency*3.1122+ t*4.269)*2.5;
y *= amplitude*0.06;
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform float u_time;
vec2 random(vec2 st){
float x = fract(sin(dot(st, vec2(75.8,48.6)))*1e5);
float y = fract(cos(dot(st, vec2(28.13,39.49)))*1e5);
return vec2(x, y) *2. -1.;
}
float noise(vec2 st){
vec2 i = floor(st);
vec2 f = fract(st);
f = f*f*f*(f*(f*6.-15.)+10.);
vec2 v1 = i;
vec2 v2 = i + vec2(1., 0.);
vec2 v3 = i + vec2(0., 1.);
vec2 v4 = i + vec2(1., 1.);
vec2 r1 = random(v1);
vec2 r2 = random(v2);
vec2 r3 = random(v3);
vec2 r4 = random(v4);
float d1 = dot(r1, st-v1);
float d2 = dot(r2, st-v2);
float d3 = dot(r3, st-v3);
float d4 = dot(r4, st-v4);
float bot = mix(d1, d2, f.x);
float top = mix(d3, d4, f.x);
float ret = mix(bot, top, f.y);
return ret*0.5+0.5;
}
float fbm(vec2 st){
float value = 0.0;
float amp = 0.5;
float frq = 0.0;
const int octave = 6;
for (int i=0; i<octave; i++){
value += amp * noise(st);
amp *= 0.5;
st *= 2.0;
}
return value;
}
void main(){
vec2 coord = gl_FragCoord.xy/u_resolution;
coord.x *= u_resolution.x/u_resolution.y;
vec3 col = vec3(fbm(coord*6.000));
gl_FragColor = vec4(col, 1.0);
}

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