drawTriangle = regl({
vert: `
precision mediump float;
uniform float scale;
attribute vec2 position;
attribute vec3 color;
varying vec3 fcolor;
void main () {
fcolor = color;
gl_Position = vec4(scale * position, 0, 1); // scale (0 - 1) * position 정점
}`,
frag: `
precision mediump float;
varying vec3 fcolor;
void main () {
gl_FragColor = vec4(sqrt(fcolor), 1); // sqrt 각 성분의 제곱근을 계산 (sqrt(0.25) = 0.5) -> 색상이 원래 값보다 더 밝게 나타나게 됨
// gl_FragColor = vec4(fcolor, 1);
}`,
attributes: {
position: [
[1, 0],
[0, 1],
[-1, -1]
],
color: [
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]
]
},
uniforms: {
scale: regl.prop("scale")
},
count: 3
})