Capsule Toy

Simple capsule toy shader with color uniform.

Shader code
shader_type spatial;
render_mode blend_mix, cull_disabled, depth_prepass_alpha;

uniform vec4 solid_color : source_color = vec4(1.0, 0.3, 0.3, 1.0);
uniform vec4 transparent_color : source_color = vec4(0.15, 0.55, 1.0, 1.0);
uniform float transparent_alpha : hint_range(0.0, 1.0) = 0.3;

varying float local_y;

void vertex() {
	local_y = VERTEX.y;
}

void fragment() {
	float split = step(0.0, local_y);

	ALBEDO = mix(transparent_color.rgb, solid_color.rgb, split);
	ALPHA = mix(0.3, 1.0, split);
}
Live Preview
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from RobbieBobbie

guest

0 Comments
Oldest
Newest Most Voted