|Topic was automatically imported from the old Question2Answer platform.
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:
I ll get to it tomorrow. Until then, is it a problem in your project if You applied shader to square texture ? It is going to follow camera anyway, so part of it can stretch from viewport ? This would get rid of problem of scaling UV.
About scrolling You need to constantly feed camera movement to shader_param and add this vector to UV (or subtract )
Inces | 2021-12-17 21:26