A World Space Grid Snapped Shader @WorldOfZeroDevelopment
A World Space Grid Snapped Shader  @WorldOfZeroDevelopment
Uploaded February 2021 | Updated November 2026, 3 hours ago
Expanding upon our exploration of a shader that snaps vertices to a grid. This time we're moving things into world space!

By moving the grid snapping into world space positions we actually gain a few fun things! For example it means that multiple different objects with the shader applied will actually merge together cleanly in world space (in essence, all objects will share a global grid space in our scene). This makes the results a lot more consistent and prevents things like rotating or scaling an object from skewing the results. This also means that we get pretty interesting results when we apply the effect to more complex objects like a particle system, in this case we can create a series of flowing snapped cubes with particles.

Compared to the previous grid snapped shader we need to add two lines. One to move our vertices into World Space and another to move back into Object Space after our operations have been applied.

```diff
void vert(inout appdata_full v) {
+ v.vertex = mul(unity_ObjectToWorld, v.vertex);
v.vertex /= _GridSize;
v.vertex = round(v.vertex);
v.vertex *= _GridSize;
+ v.vertex = mul(unity_WorldToObject, v.vertex);
}
```

You can view the entire playlist of implementing this effect here: youtube.com/playlist?list=PLEwYhelKHmiixWR3Tn5dYt1iUlSCL6OFq

***

The variables I use (`unity_ObjectToWorld` and `unity_WorldToObject`) are documented here along with a number of other useful built-in shader variables: docs.unity3d.com/Manual/SL-UnityShaderVariables.html
You can find a collection of other Visual Effects we've explored on the channel here: youtube.com/playlist?list=PLEwYhelKHmig6ttzH0nRL3OOQsGLtVrtX
The animated model is from the "Mecanim Warrior Anim Free" package on the asset store - this effect should work on any object that you can apply the material to though. assetstore.unity.com/packages/p/mecanim-warrior-anim-free-6127
Join the World of Zero Discord Server: discord.gg/hU5Kq2u
A World Space Grid Snapped ShaderBuilding a Cloud Game w/ @MicrosoftReactor  - Day 2Solving FizzBuzz with C#s Pattern Matching Switch StatementsUsing Git HooksLearning to Compile a Java Class From ScratchHow I Use NDepend to Manage my Technical DebtSending Real-Time Messages to Unity from a Blazor Website - SignalR in Unity - Part 3Dynamic Game Speed - Unity Quick TipFiring Projectiles - Lets Make a Side Scrolling Shooter - Part 5I Learn How To Build Flowcharts and Signal Diagrams in Mermaid.JSCollaborative Coding with Visual Studio Live ShareRigidbody Top-Down Spaceship Controller
World of Zero |

A World Space Grid Snapped Shader

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER