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 14

BUILT-IN FUNCTIONS: STEP

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
	vec2 r = 2.0 * vec2(fragCoord.xy - 0.5 * iResolution.xy) / iResolution.y;
	float xMax = iResolution.x / iResolution.y;
	vec3 bgCol = vec3(0.0);
	vec3 col1 = vec3(0.216, 0.471, 0.698);
	vec3 col2 = vec3(1.00, 0.329, 0.298);
	vec3 col3 = vec3(0.867, 0.910, 0.247);
	vec3 pixel = bgCol;
	float edge, variable, ret;
	if (r.x < -0.6 * xMax)
	{
		variable = r.y;
		edge = 0.2;
		if (variable > edge)
		{
			ret = 1.0;
		}
		else
		{
			ret = 0.0;
		}
	}
	else if (r.x < -0.2 * xMax)
	{
		variable = r.y;
		edge = -0.2;
		ret = step(edge, variable);
	}
	else if (r.x < 0.2 * xMax)
	{
		ret = 1.0 - step(0.5, r.y);
	}
	else if (r.x < 0.6 * xMax)
	{
		ret = 0.3 + 0.5 * step(-0.4, r.y);
	}
	else
	{
		ret = step(-0.3, r.y) * (1.0 - step(0.2, r.y));
	}
	pixel = vec3(ret);
	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?