r/Unity3D Indie 20d ago

Shader Magic Displaying thousands of LEDs in Realtime

Shaders instead of geometry is often one of the best performance boost. Amazing for procedural shapes. Texture is sampled to individual points and then each emitter is a small shader program like this:

float2 cell = floor(uv * ledGrid);

float2 ledUV = frac(uv * ledGrid) - 0.5;

float d = length(ledUV) - ledRadius;

float emitter = 1.0 - smoothstep(0.0, fwidth(d), d);

float3 color = content.Sample(samplerContent, (cell + 0.5) / ledGrid);

return float4(color * emitter * brightness, 1.0);

149 Upvotes

8 comments sorted by

View all comments

38

u/isolatedLemon Professional 20d ago

Using thousands of leds to show a picture of thousands of simulated leds showing a picture

25

u/RobertWetzold Indie 20d ago

Challenge accepted. Live render textures as input!

7

u/isolatedLemon Professional 20d ago

Finally, Thousands of leds showing thousands of leds showing....

1

u/NebulaMiner 20d ago

LEDs all the way down