Transparency Dither

This is the same distance fade effect used in the StandardMaterial3D under “Distance Fade”
However, this dithering effect is not based on distance. Instead, it uses the alpha value 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 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.

Related shaders

Dithering / Screen Door Transparency

Simple World Triplanar Grid (Allows Transparency)

3D Pulsing transparency

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments