본문 바로가기
College Study/GLSL

[GLSL] Hello World

by 2den 2022. 1. 5.
728x90

 


#ifdef GL_ES
precision mediump float;
#endif

void main() {
    gl_FragColor = vec4(1.0,0.0,1.0,1.0);
}

 

1. Shader Language is C-flavored language.

2. The final pixel color is assigned to the reserved global variable gl_FragColor.

3. Shader Language has the types like 'vec3' and 'vec2'.

4. Float types are vital in shaders, so the level of precision is crucial. Lower precision means faster rendering, but at the cost of quality. You can be picky and specify the precision of each variable that uses floating point. In the first line (precision mediump float;) we are setting all floats to medium precision. But we can choose to set them to low (precision lowp float;) or high (precision highp float;).

5. The last, and maybe most important, detail is that GLSL specs don’t guarantee that variables will be automatically casted. So don't forget the floating points.

 

vec4 color = vec4(vec3(1.0,0.0,1.0),1.0); //it means 'vec4(1.0,0.0,1.0,1.0);
 

 

728x90

'College Study > GLSL' 카테고리의 다른 글

[GLSL] Smoothstep  (0) 2022.01.05
[GLSL] Fragment Coordinate (gl_FragCoord)  (0) 2022.01.05
[GLSL] Uniform  (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

댓글