Bordered Torus

My first shader ! It turns a Sprite2D into a torus, with a red border. A “little” buggy. No parameters. 

(just attach the shader code to the material of a Sprite2D)

Shader code
shader_type canvas_item;
render_mode blend_mix;

void fragment() {
// Input:23
	vec4 n_out23p0 = COLOR;


// Input:2
	vec2 n_out2p0 = UV;


// Vector2Constant:6
	vec2 n_out6p0 = vec2(0.500000, 0.500000);


// Distance:7
	float n_out7p0 = distance(n_out2p0, n_out6p0);


// SmoothStep:16
	float n_in16p0 = 0.51000;
	float n_in16p1 = 0.27500;
	float n_out16p0 = smoothstep(n_in16p0, n_in16p1, n_out7p0);


// FloatOp:9
	float n_in9p1 = 0.20500;
	float n_out9p0 = n_out7p0 + n_in9p1;


// SmoothStep:18
	float n_in18p2 = 0.50000;
	float n_out18p0 = smoothstep(n_out7p0, n_out9p0, n_in18p2);


// Step:17
	float n_out17p0 = step(n_out16p0, n_out18p0);


// FloatFunc:19
	float n_out19p0 = 1.0 - n_out17p0;


	vec3 n_out21p0;
// ColorFunc:21
	{
		vec3 c = vec3(n_out19p0);
		vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
		vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
		n_out21p0 = c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
	}


// Mix:22
	vec3 n_in22p1 = vec3(1.16000, 0.07000, 12.24000);
	vec3 n_out22p0 = mix(vec3(n_out23p0.xyz), n_in22p1, n_out21p0);


// SmoothStep:10
	float n_in10p0 = 0.46000;
	float n_in10p1 = 0.37500;
	float n_out10p0 = smoothstep(n_in10p0, n_in10p1, n_out7p0);


// SmoothStep:8
	float n_in8p2 = 0.42000;
	float n_out8p0 = smoothstep(n_out7p0, n_out9p0, n_in8p2);


// Step:11
	float n_out11p0 = step(n_out10p0, n_out8p0);


// Step:12
	float n_in12p1 = 0.64000;
	float n_out12p0 = step(n_out11p0, n_in12p1);


// Mix:20
	float n_in20p1 = 1.00000;
	float n_in20p2 = -0.02000;
	float n_out20p0 = mix(n_out12p0, n_in20p1, n_in20p2);


// Output:0
	COLOR.rgb = n_out22p0;
	COLOR.a = n_out20p0;


}
Live Preview
Tags
donut, red, torus
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.
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments