Transparency Dither

This effect is identical to the distance fade used in StandardMaterial3D under Distance Fade. Unlike distance-based fading, this dithering effect is controlled by the alpha component of the source color.

Source:
https://github.com/godotengine/godot/blob/master/scene/resources/material.cpp

Shader code
shader_type spatial;

const vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
uniform vec4 color: source_color = vec4(1.0, 1.0, 1.0, 0.5);

void fragment() {
	ALBEDO.rgb = color.rgb;
	if (color.a < 0.001 || color.a < fract(magic.z * fract(dot(FRAGCOORD.xy, magic.xy)))) {
		discard;
	}
}
Tags
Alpha Dither, alpha hash, dither, Dithered Transparency, dithering, screen door
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.

Related shaders

Dithering / Screen Door Transparency

Simple World Triplanar Grid (Allows Transparency)

simple fresnel transparency

guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Riley
Riley
2 months ago

Bro, this is just like in Baldi’s Basics Plus! This is amazing!!