LED dot matrix spatial

very simple dot matrix shader for 3d objects. this can simulate LED screens

Shader code
shader_type spatial;

uniform sampler2D tex;
uniform vec3 emission_color : source_color = vec3(1.0);
uniform float emission_strength=2.0;
uniform float grid_size = 0.025; // Size of the grid cells
uniform float dot_radius = 0.01; // Radius of each dot

void fragment() {
    vec4 base_color = texture(tex, UV);
    
    // Calculate grid coordinates (center of the cell)
    vec2 cell_pos = floor(UV / grid_size);
    vec2 cell_center = (cell_pos + 0.5) * grid_size;
    
    // Calculate distance from the center of the cell
    float dist = distance(UV, cell_center);
    
    // Create a circular alpha based on distance
    float circle_alpha = smoothstep(dot_radius - 0.01, dot_radius + 0.01, dist);
    
    // If we're inside the circle, show the texture with full opacity
    if (dist < dot_radius) {
        ALBEDO = base_color.rgb * emission_color*emission_strength; // Make it emissive
        ALPHA = 1.0;
    } else {
        ALPHA = 0.0; // Make non-dot areas fully transparent
    }
}
Tags
dot, LED, Spatial
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.

More from FrankTheApe

Impact VFX

Variable Dot Pattern

Kuwahara Shader

Related shaders

LED BULB EFFECT SPATIAL SHADER

pixelated horror vignette dot-matrix downres

LED Grid Overlay Shader (Adjustable Aspect Ratio) v.2.0

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments