Jump to content
  • Advertisement
Sign in to follow this  
bjarnia

Rotating texcoords for roads

This topic is 3021 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

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!