
a moving platform), the texture will appear to crawl along it. If the object moves through worldspace (eg. (Here I've used an unlit opaque shader without fog as a base, but other effects can be incorporated in a straightforward way if you need.) You can use the regular texture tiling & offset fields to fine-tune how many repeats you want per world unit and the alignment of the tiling.

Use the worldspace coords instead of the mesh's UVs. Gets the xy position of the vertex in worldspace.įloat2 worldXY = mul(_Object2World, v.vertex).xy O.vertex = mul(UNITY_MATRIX_MVP, v.vertex) To do this, create a new shader something like the following: Shader "Unlit/WorldspaceTiling" ( The brick texture is a free asset from ) On the right are the same four quads textured in worldspace using a single material. In this example you can see conventional texture mapping on the left, using four standard quads at different scales with one material.


They'll also automatically tile seamlessly where two similarly-textured objects meet, even if they're using different scales (provided you've used a seamless tiling texture) That way you'll always have a consistent repeat rate, no matter where or how stretched your objects are. One simple way to do this without a script modifying the tiling per object is to apply the texture in worldspace.
