Sign in to follow this  
bjarnia

Rotating texcoords for roads

Recommended Posts

I'm trying to embed roads into my terrain, and it works fine for tiling (all edges) road textures, but what I'm more interested in is getting it to work with road textures that actually look like roads such as this: http://www.steik.org/dump/road.png This is what I have right now: http://steik.org/dump/Cosmopolis2010-03-1711-24-46-57.png The white line is a curve (CatmullRom, but can be whatever) that "imprints" itself into the terrain on terrain creation time, adding vertex data to the terrain. The vertex data is the distance from the center of the curve (for fading out edges) and the direction (atan2 of the normalized direction vector). I know how to do basic rotation of texture coordinates, but well.. the results are nothing usable: http://www.steik.org/dump/Cosmopolis2010-03-1711-37-39-81.png I have tried adding a 90 or 270° rotation to it, but it did not do much. This is how I do the rotation at the moment (Pixel Shader): float2 texCoord = input.WorldPos.xz / 6; texCoord.x -= (int)texCoord.x; texCoord.y -= (int)texCoord.y; float theta = input.Road.y; // atan2 of segment direction float s = sin(theta); float c = cos(theta); texCoord = mul(texCoord, float2x2(c, -s, s, c)); So... I guess the main question is.. Does this approach even make sense? Right now I think not :) Should I try to compute the texture coordinates as I create the road somehow instead of doing it in PS based on the direction? Any other ideas?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this