본문 바로가기

함수20

[그래픽스] line.cpp 만들기 vec.h #pragma once #include #include #define M_PI 3.14159265358979323846 #define radians(x) x*M_PI/180.0 #define degrees(x) x*180.0/M_PI ////////////////////////////////////////////////////////////////////////////// // // 2D vector // ///////////////////////////////////////////////////////////////////////////// class vector2D { float x; float y; public: // // --- Constructors and Destructors ---.. 2022. 1. 28.
[알고리즘] Assignment 1 2022. 1. 28.
[GLSL] Float-float 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 The left side is a noise graph, and the right side is a random graph. A noise and a random are different. Let's make a noise function. float i = floor(x); // integer float f = fract(x); // fraction y = rand(i); float i = floor(x); // i.. 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] Circle Shapes https://thebookofshaders.com/07/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com Let's make mirrored circle wave. New default codes: #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 *= .. 2022. 1. 6.
[GLSL] Circle https://thebookofshaders.com/07/ To make circle, the functions ‘length’ and ‘distance’ are often used. // Author @patriciogv - 2015 // http://patriciogonzalezvivo.com #ifdef GL_ES precision mediump float; #endif uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; void main(){ vec2 st = gl_FragCoord.xy/u_resolution; float pct = 0.0; vec2 toCenter = vec2(0.5)-st; pct = length(to.. 2022. 1. 6.
[GLSL] Gain http://www.iquilezles.org/www/articles/functions/functions.htm Inigo Quilez Articles on computer graphics, math and art iquilezles.org Remapping the unit interval into the unit interval by expanding the sides and compressing the center, and keeping 1/2 mapped to 1/2, that can be done with the gain() function. This was a common function in RSL tutorials (the Renderman Shading Language). k=1 is th.. 2022. 1. 5.
[GLSL] Shaping Functions https://thebookofshaders.com/05/ The Book of Shaders Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders. thebookofshaders.com Here is the code I met previously. #ifdef GL_ES precision mediump float; #endif uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; // Plot a line on Y using a value between 0.0-1.0 float plot(vec2 st, float pct){ re.. 2022. 1. 5.
[GLSL] Smoothstep https://thebookofshaders.com/05/ 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; void main() { vec2 st = gl_FragCoord.xy/u_resolution; float y = st.x; vec3 color = vec3(y); gl_FragColor = vec4(color,1.. 2022. 1. 5.