본문 바로가기

쉐이더29

[GLSL] Fractal Brownian Motion https://thebookofshaders.com/13/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com 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*freq.. 2022. 1. 6.
[GLSL] Voronoi https://thebookofshaders.com/12/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com #ifdef GL_ES precision mediump float; #endif uniform vec2 u_resolution; uniform vec2 u_mouse; void main(){ vec2 coord = gl_FragCoord.xy/u_resolution; coord.x *= u_resolution.x/u_resolution.y; vec2 mouse = u_mouse.xy/u_resolution; mouse.. 2022. 1. 6.
[GLSL] Gradient Noise https://thebookofshaders.com/11/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com #ifdef GL_ES precision mediump float; #endif uniform vec2 u_resolution; // vec2 vec2 random vec2 random(vec2 st){ float x = fract(sin(dot(st*25., vec2(17.34,50.13)))*84239.523); float y = fract(cos(dot(st*25., vec2(28.13,39.49)))*94820.. 2022. 1. 6.
[GLSL] Value Noise https://thebookofshaders.com/11/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com 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.. 2022. 1. 6.
[GLSL] Maze and Glitch #ifdef GL_ES precision mediump float; #endif #define ROOT2 1.414 uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; float random(float f); float random(vec2 f); float random(vec3 f); float line(vec2 coord, bool dir){ float y; float thc = .2; if(dir){ y = coord.x; }else{ y = 1. - coord.x; } return smoothstep(y-thc, y, coord.y) - smoothstep(y, y+thc, coord.y); } void main(){ ve.. 2022. 1. 6.
[GLSL] Random https://thebookofshaders.com/10/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com Let's write the function 'random' that returns randomed-float data. float random(float st); float random(vec2 st); float random(vec3 st); float random(float f){ float y = fract(sin(f*100.)*100.); return y; } The function 'dot' downgrad.. 2022. 1. 6.
[GLSL] Patterns https://thebookofshaders.com/09/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com For the first, let's make a circle. #ifdef GL_ES precision mediump float; #endif uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; void main(){ vec2 coord = gl_FragCoord.xy/u_resolution; coord.x *= u_resolution.x/u.. 2022. 1. 6.
[GLSL] Rotate and Scale https://thebookofshaders.com/08/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com https://en.wikipedia.org/wiki/Rotation_matrix Rotation matrix - Wikipedia en.wikipedia.org mat2 rotate2d(float _angle){ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)); } #ifdef GL_ES precision mediump float; #endif unif.. 2022. 1. 6.
[GLSL] Translate https://thebookofshaders.com/08/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com #ifdef GL_ES precision mediump float; #endif uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; float bar (vec2 loc, vec2 size, vec2 coord){ vec2 lb = loc - size/2.; vec2 rt = loc + size/2.; vec2 st = step(lb, coord.. 2022. 1. 6.