I need a shader that will be used to draw the "floor" of my game. At it's most basic behaviour, it would work as a simple world-space grid that tiles a texture each X pixels.
This shader will be applied to a texture filling the screen and following the camera, but its texture must "remain in place" with origin at the world's origin instead of following the camera.
However, I'm stuck trying to get the basics going. I managed to tile a texture using frac()
but I can't figure out how to:
(A) make it retain it's aspect -- the texture is stretched horizontally to fit the screen aspect. I need to scale the UV, but mantaining square pixels.
(B) scroll it somehow to keep its origin at the world origin, instead of following the camera.
I'm using VisualShader but any help is welcome, even if it's pseudocode. I've tried a lot of the built-in nodes trying to make this work, but nothing really worked and the visualshader docs were not very helpful.
Here's a visual explanation in case that helps:

Thanks!