break-utopia/project/shaders/dither_effect.gdshader
2025-12-10 21:34:07 +01:00

28 lines
967 B
Text

shader_type spatial;
render_mode unshaded, blend_mix, cull_disabled;
uniform sampler2D albedo : source_color, hint_default_white;
uniform vec4 albedo_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform float dither_count : hint_range(500., 10000.) = 500.;
uniform vec4 dither_color : source_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform float dither_size : hint_range(0.0, 1.0) = 0.5;
//void vertex() {
// // Called for every vertex the material is visible on.
//}
void fragment() {
vec4 color = texture(albedo, UV);
float pattern = sin(SCREEN_UV.x * dither_count) * sin(SCREEN_UV.y * (VIEWPORT_SIZE.y / VIEWPORT_SIZE.x * dither_count));
if (pattern > (1. - dither_size)) {
ALBEDO = dither_color.xyz;
} else {
ALBEDO = COLOR.xyz * color.xyz * albedo_color.xyz;
}
ALPHA = color.w;
}
//void light() {
// // Called for every pixel for every light affecting the material.
// // Uncomment to replace the default light processing function with this one.
//}