Technical solutions for dealing with in-game roads

polycounter lvl 5
Offline / Send Message
Deadly Nightshade polycounter lvl 5
I wrote about this topic on (see below) but I didn't quite get the feedback I had hoped for:

Any thoughts?
We develop games for mobile platforms (iPad, android, windows phone, etc) so obviously we have higher restrictions on what we can implement in our games.

My biggest issue is on how to best use splattmapping together with roads (which have UV's that tile in only one direction) and how to best deal with junctions (X-, T-, Y- intersections, road splits and so on). Using a gazillion of different road textures is a really bad idea due to the fact that we have worse hardware to work with. And at the same time, alpha textures are expensive. Right now we aren't even sure that splatmapping is worth it (although I have said we should look into it).

The first thing can be sorted out with multiple UV-sets. One normal UV-set, where UV-shells for the road are straight - and another UV-set for the splatmap where everything is uniform. But how do you display this in maya when you can only have one primary uv set visible at a time?

EDIT: And I've already considered the most common solutions, such as splitting UV-shells like this: (which is decent for 90-deg turns and when there isn't much noise in the texture) I'm looking for some outside-the-box-thought-up -ideas.


  • abmurray
    Are you handcrafting the road geometry? Are you using prefabbed chunks of road geo that you can recombine over and over?
  • Deadly Nightshade
    Offline / Send Message
    Deadly Nightshade polycounter lvl 5
    First question: Yes, because we haven't found any good way to do it with splines inside Maya (splines acting as guides for the engine - which then draws the roads along them)
    Second: Yes, but the less the better. I understand that just having one texture/module is probably unrealistic.

    I'm considering using two textures: One straight with road stripes. One straight without road stripes (neutral).
    Then in intersections, you switch over to the ones without road stripes, and place one of the roads above the other, and applying vertex alpha to it (50%). I dunno if this actually looks good or not but at least it would allow a vertical road to blend with a horizontal one.

    (also im considering per-vertex texturing as an option instead of using splatmapping för texture blending)
  • Bruno Afonseca
    Offline / Send Message
    Bruno Afonseca Polycount Sponsor
    Why don't you just cut or float the painted lines? That's how I've done it before...
    That allows you to be a bit more creative with it, having line variations, etc!

    So my workflow is:

    - Laying down the road splines (on corner mode)
    - Filleting corners
    - Creating a spline shape and lofting it using the first one as a path, with 'generate mapping coords.' on
    - Creating width variations, cambers etc and adding them to the loft
    - Adjust uvs
    - Using the road's center edgeloop to create the lines (if you don't run an edge loop on the middle of the road, you might get harsh collisions on ascending or descending or leaning turns)

    So this is pretty much it!
  • Deadly Nightshade
    Offline / Send Message
    Deadly Nightshade polycounter lvl 5
    Yea I feel I have those bases covered fonfa.
    What I'm interested in learning more about are the different ways of making the road blend with the rest of the environment, especially when it comes to road blending against another road.

    And if I understood our coders correctly, using vertex alpha is more expensive than vertex on a texture.

    We've talked a little bit about per-vertex texturing and my funky idea was that maybe we can use different vertex colors for representing different materials? One for each primary color (RGB). But I dunno... I haven't exactly heard about anyone else using such a method before.
  • McGreed
    Offline / Send Message
    McGreed Polycount Sponsor
    There is a tutorial about using UDK and vertex painting, which is pretty nice and shows how to use vertex paint to bland different materials.

    Maybe that might be an idea, create a mask image (which doesn't have to be high resolution, since its just a black and white "alpha"), an asphalt material and a stripe material, and use the mask to show where the stripe material should be use, and use vertex paint to bland the mask with a black color, so you can vertex the strips on and off. If you understand what I mean?

    Instead of using your strips texture with alpha map, you use the mask texture instead, and since its only black/white, and the shapes is simple, you don't need the texture to be large. But the question is if vertex paint is cheap enough to use, and if you can make the shader for it.
  • Eric Chadwick
    Vertex alpha is more expensive than splat mapping, because it's alpha blending. Anything with transparency is generally more expensive, especially for mobile hardware.

    For the transitions between road and terrain, you could use the eat3d method in McGreed's link, except not using the blend texture for details... just straight vertex blending. It's soft and not detailed, but for mobile you often have to go cheap & fast.

    Since vertex color is three color channels of data, you could have up to four textures that you're blending together. You have the 1st texture, rock for example, that you can think of as your "bottom" texture. It's always under everything else. Then where you paint blue vertex color, you're showing the 2nd texture, dirt for example. Green vertex color would show texture #3, maybe grass. Then red vertex color shows the 4th texture, asphalt for example.

    If the vertex color is yellow, then you would see the 3rd and 4th textures together. If white, you see 2 and 3 and 4. If black, you see only #1 (i.e. rock).

    You could use UV channel 1 for the road, so it follows the curves. And UV channel 2 for the terrain, tiled.

    Make the road mesh slightly larger than the width of your asphalt surface, and use vertex color along the edges to blend in the terrain textures. The middle of the road would be red vertex color (asphalt texture), and the edges would be mostly dirt (blue vertex color), and maybe some grass (green vertex color) or rock (black vertex color) mixed in here and there.
Sign In or Register to comment.