概要
plunkerでshadertoyのglsl動かしてみた。
TUTORIAL、やってみる。
TUTORIAL 11
MAKING THE ASPECT RATIO OF THE COORDINATE SYSTEM 1.0
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 r = vec2(fragCoord.xy - 0.5*iResolution.xy);
r = 2.0 * r.xy / iResolution.y;
vec3 backgroundColor = vec3(1.0);
vec3 axesColor = vec3(0.0, 0.0, 1.0);
vec3 gridColor = vec3(0.5);
vec3 pixel = backgroundColor;
const float tickWidth = 0.1;
for (float i = -2.0; i < 2.0; i += tickWidth)
{
if (abs(r.x - i) < 0.004)
pixel = gridColor;
if (abs(r.y - i) < 0.004)
pixel = gridColor;
}
if (abs(r.x) < 0.006)
pixel = axesColor;
if (abs(r.y) < 0.007)
pixel = axesColor;
fragColor = vec4(pixel, 1.0);
}
写真
成果物
以上。
