Okay, so I’m AWARE (since someone will invariably point it out anyway) that I can use the TexCoord node to control the tiling of a material, and I’m AWARE that it’s possible to use the world position of a material to tile a texture along it in such a way that it doesn’t care about world size or position.
But what I’d like to do is find a way to tile a material, on a specified axis ONLY, such that no matter the size of the object on this axis, the material will loop itself to fill it.
Note that what this means is if the object moves, the material (well, the texture anyway) will move WITH it, it won’t remain fixed in place. If the object is rotated, the texture will rotate with it. All I want is to tile rather than stretch when an object is scaled along a specific local axis, in such a way that the scaling along that axis can be arbitrary without manually modifying the material (i.e. without tweaking a parameter that controls TexCoord scaling to make sure it visually looks right).
Here’s the specific scenario: I’ve got an Actor which is, at its base, a spline. This actor, in its construction script, spawns various copies of a SplineMesh, such that their Start and End points are aligned with the points on the spline. Thus, manipulating the spline enables manipulation of the meshes. I use this to create “track”, as pictured below.
What I’d like to do is texture this in a fashion similar to a road; imagine having a dashed white line down the center (it won’t be exactly this, but for the purposes of argument let’s say it is, since the principle is the same). That means the texture must tile evenly along the mesh, regardless of the “size” of the particular Spline Mesh it’s attached to, since it would be impractical to design these splines with exactly equidistant points to guarantee an identical length for all segments of road. However, it ALSO means the texture must stretch/deform along the NON tiling axis in an ordinary manner.
In other words, I need to know how to allow a material to determine the world scale, in pixels, of ONE of its UV axes, and tile a texture along that axis without stretching, while simultaneously allowing it to stretch as needed along its other axis.
I can get the world bounds of an object but this doesn’t really help me much when dealing with a mesh which is deformed via a curve in an arbitrary way and at a non-right angle to the world axes.