Snap Grid Display with Material Scale?

So in my app I have a snap to grid system. The snap values are per UnityUnit (1m) and can be adjusted with a stepper UI element (min 0.1, max 2).
I am trying to create a way to display the grid in the 3D world. Rather than some GL.Lines or Gizmo system, I figured it would be easiest to have a giant plane with a grid transparent material on it that stretches across the whole ground plane and adjust the scale as needed. This works fine – Material Scale is at 100,100 when a “box” equals 1 Unit.

The problem is, I am trying to have this scale match the grid snap value, but no matter what I try, the grid won’t match up. Is there some math I’m missing?

The snap value always starts at 1 (meaning the material scale is 100,100), and it can be adjusted up or down from there.
My goal is to have the “boxes” on the grid always align so the objects snap to the center of the box.
What calculations should I be doing to make this happen? - To be clear, I don’t need the snapping logic, just the right math to get the material scale to match the snap value.
I hope this makes sense!

Thanks for any and all help!

Canonically the UV space on a texture is 0 to 1 in both axes.

The UVs on the Unity Plane and Quad are also 0 to 1, which is handy.

Plane is 10x10, quad is 1x1.

If you made your own geometry, then I don’t know what your UVs are. Fix that to be 0 to 1 if so!

Obviously if you scale your geometry, you must account for that.

I’m not sure what you mean by this:

Remember there is also phase / offset, eg, which part of the repeating UV cycle you’re on when you’re at zero. At zero is there a grid line, or are you perfectly between two grid lines? Or something else? That can be controlled by the offset of the material.

And of course the position of your geometry affects phase / offset.

It’s a default unity plane, but stretched to 100,100,100 so it covers the entire “ground plane” which is also at the same scale.

For this purpose, it’s probably simpler if the goal is for objects to be at a perfect intersection, I apologize for the correction.

When the snap value is at 1, the material scale is 100,100, presumably to match the scale of it’s plane mesh. By default, the snapped object is at a perfect intersection. This works perfectly until I change the grid snap value.
My goal is for the material scale to adjust accordingly so the objects are always on an intersection.
I have tried messing with the offset, but I’m not sure what calculation would need to be made to have it adjust accordingly.
Thanks so much!

One other thing to check: if your texture dimensions are NOT a power of two, Unity’s default importer may slew it up or down to a power of two. Check the import settings of the texture, and ideally make it a power of two in size.

The texture is 1024x1024, so not an issue.