Circular Pattern Shader

This shader generates a dynamic circular pattern effect that alternates between two customizable colors. The pattern is created using concentric rings emanating from the center of the canvas. Users can control the density of the rings to adjust the spacing and customize the two colors to suit their needs.

 

Key Features:

  • Density Control: Adjust the number of rings with the density parameter for a tighter or more spaced-out pattern.
  • Custom Colors: Select two colors (color1 and color2) to create a unique alternating color scheme for the rings.
  • Versatile Usage: Ideal for creating dynamic backgrounds, decorative effects, or visual highlights in your projects.
Shader code
shader_type canvas_item;

uniform float density: hint_range(4.0, 25.0) = 10.0;
uniform vec4 color1: source_color;
uniform vec4 color2: source_color;


void fragment() {
	float x = (UV.x-.5);
	float y = (UV.y-.5);
	float v = (sqrt((x*x)+(y*y)) * density);
	float can_color = mod(v, 2.0);
	vec4 color;
	if (can_color > 1.0) {
		color.rgb = color1.rgb;
	}else{
		color.rgb = color2.rgb;
	}
	color.a = 1.0;
	COLOR = vec4(color.rgba);
}
Tags
circle, circular pattern, circular ring, pattern
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.

More from gamifiedsoul

Noise-Based Moving Smoke Effect

Related shaders

circular pattern

Circular Life Bar

Circular Plane

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments