圆形循环(cycle_circle)

在纯色背景中不断向左或向右移动的排列成矩阵的纯色圆形(

通过在纯色背景中不断向左或向右移动来排列成矩阵的纯色圆圈)

Shader code
shader_type canvas_item;

uniform int ranks = 2;
uniform float circle_radius = .1;
uniform vec3 background_color = vec3(1,1,1);
uniform vec3 color = vec3(0,0,0);


float sdcircle( vec2 p, float r ) {
    return length(p) - r;
}

float cycle_circle(vec2 uv, float c_r) {
	vec2 start_position = vec2((c_r * 2.) - 1.,.5);
	vec2 end_position = vec2((c_r * 2.),.5);
	start_position.x += fract(TIME);
	end_position.x += fract(TIME);
	float start_circle = smoothstep(sdcircle(uv - start_position, c_r), sdcircle(uv - start_position, c_r) + .001, .01);
	float end_circle = smoothstep(sdcircle(uv - end_position, c_r), sdcircle(uv - end_position, c_r) + .001, .01);
	return start_circle + end_circle;
}

void fragment() {
	vec2 ranks_uv = fract(UV * float(ranks));

	float cycle_circle = cycle_circle(ranks_uv, circle_radius);
	vec3 colors = background_color + cycle_circle * (color - background_color);

	COLOR.rgb = colors;
}
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments