Is there a way to get textures to line up between repeating segments?
To elaborate, I have a series of road segments with various types (straight, turn, intersection, etc) that we’ve made to be able to add and replace segments with ease as we design or make changes to the map.
I made a repeating texture to put on the sidewalk, and I thought it looked pretty good. But (and I admit, I was afraid this would happen), when I link two segments, the textures don’t line up.
Example:
Similar issues occur if there’s a turn in the road. The texture will be going one way, but then the next straight segment must be rotated 90 degrees, and will then be facing another way from the other straight segments.
Is there a way to fix this within Unity? Right now, I’m using UV mapping generated by 3DS Max, but if I change the mapping to get the segment to line up, it moves the texture for all segments of the same type, and so it won’t line up if I try it that way at all.
Or is this one of those things were you’d say “If it’s good enough for them, it’s good enough for me”? (In reference to the fact that a lot of professional games have similar issues to this if you pay close enough attention)
As Twiik alluded to, the first step is probably to make sure the texture itself tiles seamlessly under normal circumstances. If the texture is mapped exactly to the surfaces, the edges should match up correctly, more or less, if the texture is tileable.
Another issue will be whether the texture only tiles in one orientation, or in any orientation. If it only tiles in one orientation and your objects are at different orientations, you’ll most likely get visible irregularities as in your image. One solution to this problem would be to orient all of the objects the same way (if that’s feasible).
Another option would be to assign texture coordinate to the surfaces procedurally using planar texture mapping. This would ensure that the textures would line up correctly at object boundaries, regardless of whether the texture is tileable or not.
Even then though, I’d think that with a continuous surface being represented using multiple separate objects like that, you could end up with rendering artifacts (e.g. z-fighting or ‘sparklies’) where edges meet. Whether you’ll run into this problem or not would probably depend largely on what’s going on numerically with your transforms.
I’m not sure what the overall context is here, but if I were doing something like this I’d probably generate composite meshes procedurally to ensure that the edges matched up exactly (both geometrically and in terms of UV coordinates). I realize that may not be feasible for what you’re doing though.
Back when I modded warcraft3 I modeled some roads. I made a series of models that handled all I needed streets to do.
The solution was to have individual (yet seamless transitions) textures for each type of road.
Straight
Blank
90* turn
3-way intersection
4-way intersection
All streets need a common angle when in a specific direction (vertical streets are always 0*, never 180 in an example). This will prevent mirrored textures.
No, the texture itself is perfectly seamless. The only issue comes with lining up two models with the same texture.
Jesse Anders;
I suppose I could try to map the UV so that the edges ended on the edge of a texture. Right now, it’s just mapped so that ‘this area uses this texture.’ I’ll also take a look at how to do the composite meshes, and see how that works.
Windexglow;
I’ll also look into making textures for each type of turn, but since I have to scale the texture down quite a bit in Unity, I’m not sure how well that’d work.
Thanks for your replies.
Update: Lining the UV up a little better really helped. However, I’m still interested in the composite meshes you mentioned. I can’t find any mentions on the forums for that term exactly, though.
A better term to search for might be ‘procedural meshes’. There are some example projects in the ‘resources’ section of the Unity site demonstrating some of these techniques. (I can’t say for sure that this would be the most appropriate solution here, but it might be worth looking into.)