0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

概要

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);
}

写真

image.png

成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?