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 17

BUILT-IN FUNCTIONS: MIX

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
	vec2 p = vec2(fragCoord.xy / iResolution.xy);
	vec3 bgCol = vec3(0.3);
	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 ret;
	if (p.x < 1. / 5.)
	{
		float x0 = 0.2;
		float x1 = 0.7;
		float m = 0.1;
		float val = x0 * (1.0 - m) + x1 * m;
		ret = vec3(val);
	}
	else if (p.x < 2. / 5.)
	{
		float x0 = 0.2;
		float x1 = 0.7;
		float m = p.y;
		float val = x0 * (1.0 - m) + x1 * m;
		ret = vec3(val);
	}
	else if (p.x < 3. / 5.)
	{
		float x0 = 0.2;
		float x1 = 0.7;
		float m = p.y;
		float val = mix(x0, x1, m);
		ret = vec3(val);
	}
	else if (p.x < 4. / 5.)
	{
		float m = p.y;
		ret = mix(col1, col2, m);
	}
	else if (p.x < 5. / 5.)
	{
		float m = smoothstep(0.5, 0.6, p.y);
		ret = mix(col1, col2, m);
	}
	vec3 pixel = 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?