Making Shadows Snap to Pixels in Godot.
by Vicente C.
Published |
12
Share
GreatOdds recreated a Minecraft-style effect that keeps shadow edges locked to the texture as the model moves and rotates.
After seeing pixel-locked shadows in Minecraft's Vibrant Visuals, GreatOdds wanted to try the same effect in Godot. It is still an experiment, and the original technique comes from Minecraft shaders.
In Minecraft, every point inside one texel, or texture pixel, samples the shadow map from the same position. The shadow edge then moves one texel at a time instead of sliding across the surface.

GreatOdds could not find a way to access Godot's shadow maps, but LIGHT_VERTEX can change where Godot calculates lighting and shadows without moving the surface itself.
To keep the shadow aligned with the texture, the shader finds the center of the current texel and measures the gap from the original UV. That gap becomes an offset across the surface. The shader applies it to LIGHT_VERTEX along the tangent and binormal, so every fragment in the texel uses the same point for lighting.

At first, this only worked on a one-unit plane. Stretching the plane changed how its UVs matched its size, and the shadows broke. GreatOdds later added a METERS_PER_PIXEL value so the UV offset could be measured in meters on the model.

The updated shader also works on a Minecraft player model. Snapping model space to a grid works for blocks aligned to an axis, but the effect can look wrong after a surface rotates. GreatOdds' version stays tied to the surface, so the shadow turns with it.
You can find more about GreatOdds and the original references below:

Want to learn Godot VFX? ✨
We just released our new Godot All About VFX Bundle, it covers shaders, particles, and VFX for 2D, UI, and 3D games with step-by-step examples. Over 600 pages of content!
Jettelly wishes you success in your professional career! Did you find an error? No worries! Write to us at [email protected], and we'll fix it!

Subscribe to our newsletter to stay up to date with our latest offers

© 2026 Jettelly Inc. All rights reserved. Made with ❤️ in Toronto, Canada