0
\$\begingroup\$

What is the best way to minimise stretch when bending a plane? I'm making a road kitbash to use in Unity and would like the road markings to remain a consistent size when the road bends (I'm using more complex markings than just lines). Here I've added a texture to a straight and curved section to illustrate the problem:

straight road vs road with a bend

I've tried adding and sliding edge loops lengthwise but they have no effect. I've tried skewing the UVs (scaling the longer edge smaller and vice versa) which does correct the scale problem, but then the shapes rotate and don't line up with a straight section if placed next to it.

Here's an example of what I'm trying to achieve - the markings are correctly oriented perpendicular to the road and are all of the same size:

road with a J bend

I achieved this using a bunch of planes in an array, but as there will be thousands of markers in the scene, I'd prefer to use larger meshes for long sections of road to keep the draw count down. Also, the road has an asphalt texture and any stretching would be noticeable close up; again, this could be solved with separate meshes for the roads, but I'd then need transparent textures for the markings, which would add tons of overdraw. I could use UV islands, but again, extra draw calls.

\$\endgroup\$
7
  • \$\begingroup\$ What's your desired outcome here? Can you sketch it? If you want exact alignment at the ends, ie. the same number of texture repeats over the length, then there has to be stretching because the same amount of texture has to cover a longer distance at the outside edge. If you want no stretching, then the same amount of texture cannot cover both the shorter and longer edges, leading to a mismatch at one end or both. If you show us the road markings you're using, we may be able to suggest a more bending-friendly way to draw them than relying on conventional texture mapping over the road itself. \$\endgroup\$
    – DMGregory
    Aug 4, 2022 at 14:34
  • \$\begingroup\$ @DMGregory Thanks, updated the post with desired result. \$\endgroup\$
    – user87997
    Aug 4, 2022 at 18:48
  • \$\begingroup\$ Looks to me like you want three separate strips, each with a different number of texture repeats according to their length. \$\endgroup\$
    – DMGregory
    Aug 4, 2022 at 18:52
  • \$\begingroup\$ @DMGregory Sure, I was thinking that too and will probably go with it. The bulk of the texure is asphault though and the stretching is apparent on that too when the camera is close enough and there would be a visible seam by each marking. I updated the post again (last paragraph) to explain. \$\endgroup\$
    – user87997
    Aug 4, 2022 at 18:54
  • \$\begingroup\$ Sounds like what you really want to ask is "how to texture a bending road in Unity" and the bend modifier/blender tags are a red herring. You may be able to apply the asphalt texture in worldspace and then layer on the markings as decals, for just two draw calls once static batching combines the meshes. \$\endgroup\$
    – DMGregory
    Aug 4, 2022 at 19:19

1 Answer 1

0
\$\begingroup\$

After much torturing of UV maps I conclude it's usually not going to be possible to get a neat result - mapping a 2D image on a non-linear plane (or 3D shape) will always yield stretching somewhere.

One solution is to hide the stretching in your scene, either rotated away from the camera or obscured by other objects.

In this case I solved the issue by using separate meshes for the markings that sit on top of the asphalt mesh with a transparent shader. That way I could planar map the asphalt, and as the markings are in thin strips, stretching could be minimised even around corners, as manipulating the UV map is much easier when you have less UVs to work with.

\$\endgroup\$

You must log in to answer this question.