vec3 red= vec3(1.0,0.0,0.0);
vec3 green= vec3(0.0,1.0,0.0);
vec3 blue= vec3(0.0,0.0,1.0);
vec2 p1= vec2(-1.0, -1.0);
vec2 p2= vec2( 1.0, -1.0);
vec2 p3= vec2(-1.0, 1.0);
varying vec4 p;
void main() {
//float r1= ((p.x-p1.x)*(p.x-p1.x))+((p.y-p1.y)*(p.y-p1.y));
//float r2= ((p.x-p2.x)*(p.x-p2.x))+((p.y-p2.y)*(p.y-p2.y));
//float r3= ((p.x-p3.x)*(p.x-p3.x))+((p.y-p3.y)*(p.y-p3.y));
float r1= distance(p.xy, p1);
float r2= distance(p.xy, p2);
float r3= distance(p.xy, p3);
vec3 color;
if (r1<r2 && r1<r3)
color= red;
else if (r2<r1 && r2<r3)
color= green;
else
color= blue;
gl_FragColor = vec4(color, 1.0);
}
0 件のコメント:
コメントを投稿