# UV calculation for a procedural Road

This topic is 3825 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

To cut to the heart of the question. I "think" the terminology for what I am trying to do is ... calculate UV(s) to seamlessly map a road texture to a procedurally generated road (decal) that can curve and vary in width. Perhaps this is possible using a non-aligned matrix? Or maybe we need one matrix for each corner point of a road-segment and blend between them? Basically how do you transform a plane (the texture), into a quad that could be distorted in any way, like... | | \ | | \ / | | ==> \ |, | \, / \, etc... Currently it looks like this, with a debugging texture, notice the blocky edges where the road is changing width. Actually the inner stripped lines are blocky while the blue edge is not because it is using clamp. http://farm4.static.flickr.com/3124/2588137523_37b03c732f.jpg

##### Share on other sites
I think the idea is to create UV points as if it were perfectly straight and of the same width (i.e. 0.0 -> 1.0 from one side to the other along the width) and then calculate the position of the vertices like a set of sweeping arcs.

If you calculate from the center of the road, you'll probably get some stretching as the inner corner stretches inward (imagine trying to bend one of those old plastic HotWheels tracks to fit a corner - the outside would stretch, but the inside would be getting squished).

Here's the example I'm thinking of from the Ogre forums:

##### Share on other sites
Thanks, that looks like an interesting thread. I think the solution may line with "Barycentric" coordinates. I'll be checking out these google results...

http://www.cescg.org/CESCG97/olearnik/txmap.htm
http://en.wikipedia.org/wiki/Barycentric_coordinates_(mathematics)

##### Share on other sites
By the way, this page has a good function for calculating barycentric coords for a n arbitrary point in a 3d triangle.

http://www.gamedev.net/community/forums/topic.asp?topic_id=351974

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633655
• Total Posts
3013187
×