# 坐标操作
- out , in
- vec2, vec3, vec4
- fragColor, fragCoord
- iResolution
# 简单的颜色变化
void mainImage (out vec4 fragColor, in vec2 fragCoord){
vec2 uv = fragCoord / iResolution.xy;
fragColor = vec4(uv, 0, 1.); // rgba
}
# 画个圆
void mainImage (out vec4 fragColor, in vec2 fragCoord){
vec2 uv = fragCoord / iResolution.xy - vec2(.5);
float c = 0.0;
float r = 0.3;
if(length(uv) < r){
c = 1.0;
}
fragColor = vec4(vec3(c),1.0); // rgba
}
# 画个正圆
void mainImage (out vec4 fragColor, in vec2 fragCoord){
vec2 uv = (fragCoord - 0.5 * iResolution.xy)/min(iResolution.x,iResolution.y);
float c = 0.0;
float r = 0.3;
if(length(uv) < r){
c = 1.0;
}
fragColor = vec4(vec3(c),1.0); // rgba
}