Jump to content
  • Advertisement
Sign in to follow this  
jamesford42

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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:
Spline-based roads

Share this post


Link to post
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)

Wow, can't figure out how to add hyperlinks.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!