#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution; // Canvas size (width,height)
uniform vec2 u_mouse; // mouse position in screen pixels
uniform float u_time; // Time in seconds since load
void main() {
gl_FragColor = vec4(abs(sin(u_time)),0.0,0.0,1.0);
}
So far we have seen how the GPU manages large numbers of parallel threads, each one responsible for assigning the color to a fraction of the total image. Although each parallel thread is blind to the others, we need to be able to send some inputs from the CPU to all the threads. Because of the architecture of the graphics card those inputs are going to be equal (uniform) to all the threads and necessarily set as read only. In other words, each thread receives the same data which it can read but cannot change.
The names will vary from implementation to implementation.
Uniform is the variable that CPU passe to GPU. When you run the above code, you can see red-black changing colored pixels. 'abs(sin(u_time))' will represent an absolute sine value that moves between 0 and 1 as the runtime progresses.
If the information about references including built-in functions is needed, look this link: https://thebookofshaders.com/glossary/
The Book of Shaders
Gentle step-by-step guide through the abstract and complex universe of Fragment Shaders.
thebookofshaders.com
'College Study > GLSL' 카테고리의 다른 글
[GLSL] Smoothstep (0) | 2022.01.05 |
---|---|
[GLSL] Fragment Coordinate (gl_FragCoord) (0) | 2022.01.05 |
[GLSL] Hello World (0) | 2022.01.05 |
[GLSL] What is a shader? (0) | 2022.01.05 |
[GLSL] Let's Dive in to the Shader! (0) | 2022.01.05 |
댓글