pen(x)

pen(x) = sin(x) * |sin(3x)|

Shader code
shader_type canvas_item;

float Ellipse(vec2 st, bool transparent) {
	vec2 center = vec2(0.5) - st * vec2(1.0, 2.0);
	float value = (0.5 - length(center));
	
	return transparent ? value : (value > 0.0 ? 1.0 : 0.0);
}

float pen(float x) {
	return sin(x) * abs(sin(3.0*x));
}

void fragment()
{
	vec2 st = UV * 2.0;
	//st.y -= 0.5;
	
	float sum = 0.0;
	
	const int ELEMENTS_COUNT = 20;
	const float MARGIN = 0.25;
	
	for(int i=0; i<ELEMENTS_COUNT; i++) {
		float pos = float(i) / float(ELEMENTS_COUNT); // [0.0; 1.0)
		
		float y = ((pos * 2.0) - 1.0) * (1.0 - MARGIN);
		float x = (pen(TIME*5.0 + (float(i) / 30.0)) / 2.0) * (1.0 - pos);
		
		sum += Ellipse(st - vec2(0.5, 0.75) - vec2(x, y), false);
	}
	
	COLOR = vec4(1.0, 0.0, 0.0, sum);
}
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

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
AndreaTerenz
5 months ago

is pen(x) supposed to be something well known or….?

seeeeees
seeeeees
5 months ago

I love pen x (pronounces as penis)