Home Technical Talk

UV mapping for terrain techniques?

Ark
polycounter lvl 11
Offline / Send Message
Ark polycounter lvl 11
Just wondering what the common practice is for uv mapping irregular meshes such as terrain for use with tiling textures.

Just looking at this image here from John Germanns portfolio is a shot from one of Uncharted 2 levels:

image-JG-icecave-mp-4-1.jpg
image-JG-icecave-mp-4-2.jpg

Can't get my head around how you'd split the mesh up uniformly to take advantage of tiling textures.

Seems there'd be a lot of texture stretching if you where to take pieces of the mesh and just relax them to conform to a square and them fit them to 0-1 uv space so that they'd tile.

I see they use a lot of texture blending so maybe texture seams aren't that important if they can just blend another texture over the seams.

One way i though of doing it was to create a plane with the required subdivisions, then uv map each quad so that it covers the full 0-1 uv space, then you'd get perfect tiling and just model the plane into the shape required.


Any further insight would be grateful.

Replies

  • Rurouni Strife
    Options
    Offline / Send Message
    Rurouni Strife polycounter lvl 10
    I would be very very interested in knowing this as well. I like your theory, and since they do use a crazy amount of blending in their environments which makes stretching less noticeable.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
  • Ark
    Options
    Offline / Send Message
    Ark polycounter lvl 11
    That looks useful r_fletch_r, but i doubt that could be transfered easily to a game engine without some special shader that supports it.
  • Autocon
    Options
    Offline / Send Message
    Autocon polycounter lvl 15
    Ark wrote: »
    Seems there'd be a lot of texture stretching if you where to take pieces of the mesh and just relax them to conform to a square and them fit them to 0-1 uv space so that they'd tile.

    Well the problem is thats not really how you tile textures at all. Sure you "can" do that but for things tiling textures in the 0 to 1 is not something you do at all. Then again it depends on what type of texture blending you use be it vertex or blend maps.

    The reason for this is each asset requires a different tiling rate to keep a uniform pixel density. Say for example you have a massive terrain chunk and small rock both using the same texture. If you crushed the UV's down in the 0 to 1 box you would require 2 different variations of the shader to get the same pixel density as the terrain would require a lot more tiling in the shader itself.

    What you want to do is tile things in your UV's by making them larger or smaller outside of the 0 to 1 box. Using this method you can ensure that each asset using the same tiling texture has a closer pixel density ratio then if you crushed everything into the 0 to 1. Not to mention the 0 to 1 crush would give you crazy amounts of texture stretching.

    You want your unwraps to have as little distortion as possible.



    How to get around seams is generally smart planning/placement of them not only in unwrapping but in modeling. For terrain the best places to break up UV's is on the inset of cracks and crevasses. Another place is right under the lip over hang of a cliff face. When modeling cliff faces like this its good to keep this concept in the back of your mind so you can add some well placed inset cracks in areas that will help break up your UV's to avoid to much stretching.


    Another way to alleviate this problem is most modern day games (if not all modern next gen games) use vertex blending or blend maps for terrain. At Bungie we used blend maps for Reach. Basically its an extra texture map, that is only 3 colors. Red Green and Blue. Each color represent a tiling texture shader so Red could be your snow, Green your cliffs and Blue your cliffs with snow on them. Or what have you. You use this to blend the textures together nicely and it helps with texture seams but dosnt remove them compelty.

    The blend map dosnt have to be super huge as you dont need it to be super detailed but again it is another texture map in memory. Also for blend maps the blend map will take all the terrain UV's and scale them to fit into the 0 to 1 box as it will be a unqiue texture and tiling is then controlled via the shader, not UV's. Again it all comes down to what your engine supports and how you want to go about it. Vertex blending would have UV's outside the 0 to 1 as you dont require a unique blend map texture to control where things blend. So tiling is not controled by the shader, more by the UV's


    Here is an example UV layout of what I mean when your textures should tile outside of the 0 to 1. This is obviously not terrain, it is actually wood boards but I think you can get the idea.

    uvtiles.jpg
  • fade1
    Options
    Offline / Send Message
    fade1 polycounter lvl 14
    i'm coming from the old scholl, but i think this looks more difficult then it actually is.
    for me this looks like a blend map between two materials. snow and rock. probably one uv layout, which was painted and projected on one texture.
    then there are two base materials rock and snow both tiling textures. you can pu your seams or break up the uv's wherever you're texture is 100% blended with the other material. that's it.
    at least i could reproduce the result with this technique.
    add some vertex lightning or a lightmap on top and you get nice result. for sure the blend map needs quite some size, but you save that one the tiling texture.
    if needed you can reuse part of the blend map for parts of the mesh to keep the texture size smaller.
  • Ark
    Options
    Offline / Send Message
    Ark polycounter lvl 11
    Thanks for the breakdown Autocon.

    What i meant with the statement you quoted, was breaking the mesh up into relatively sized square chucks that tile, then each part would get the same pixel density. This would probably cause some stretching, but there'd be no seams.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Ark: Im taking a shot at it now. I have the XYZ projection and Axis based falloffs worked out i just need to glue it all together. No promises yet but it doesnt seem all that complex.
  • Autocon
    Options
    Offline / Send Message
    Autocon polycounter lvl 15
    Have you ever actually seen a real life terrain or cliff way that tiles nicely? No never, thats now how nature is. What makes a terrain/rock walls look real is making them look unqiue and removing that generic tiling look.

    If you were to make rock wall chunks out of a ton of square pieces you would notice the tiling. Again why would you ever want stretched textures when simple planning can more or less eliminate them. Putting seams in the inset cracks and crevasses, having lighting/ao and using blend maps/vertex blending will remove the noticeably of seams while still giving your terrain/cliffs that unique realistic look instead of silly tiling chunks.

    For cliff walls another technique you can use is to create 4 or 5 different large cliff wall faces. This wont tile front end to end at all, but will still use the same techniques as a large piece of terrain on where to put cuts and seams. You then zbuffer these chunks into each other to create large unique cliff faces. Naughty dog also did this with there cliff faces. Large terrain meshes like shown above are uniquely made.

    Again you dont want your terrain/cliffs to look like they tile so creating square sized tiling chunks to make up your terrain is only going to show the tiling even more. You will also never get the unqiue look of real life from this method. It will have that very CG look to it. In reality I cant think of a single game that uses tiling cliff chunks to make up there walls. They might use large cliff chunks they zbuffer together but the chunks themselfs dont tile from end to end.
  • Ark
    Options
    Offline / Send Message
    Ark polycounter lvl 11
    Heres what i was trying to explain. If you imagine this as the top of the cliff and the blue lines is where the mesh is split to be tiled.

    asasash.jpg

    r_fletch_r: Look forward to seeing the results.

    Autocon: I would be using vertex colour for the blending, im just looking for the best way about unwrapping something similar to that mesh in my first post to take advantage of tiling textures.
  • Autocon
    Options
    Offline / Send Message
    Autocon polycounter lvl 15
    I guess you did not fully understand my last picture so here is one that is more clear. As long as your texture tiles from top to bottom and side to side it will tile endlessly like the picture bellow. I still have no idea why you are cutting it up into those odd squares, that is compelty wrong. There is no point to do so. It is actually worse especially if using Unreal as Unreal creates new smoothing groups on UV seams. So not only are you getting ugly stretching but you are also going to get a harsh seam from smoothing groups. Right now your way is counter productive to removing seams as the smoothing group seam will create lighting issues.

    uvtiles2.jpg
  • Justin Meisse
    Options
    Offline / Send Message
    Justin Meisse polycounter lvl 18
    for caves and other crazy stuff on WAR, texture 1 used UV1 while texture used UV2, basically just put the seams where you won't see them because of texture blending.

    Oh yeah, get outside the 0-1 box dude! Let me guess, you're a character artist branching out to environments?
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Pah who needs UV's :D. The Shader works them out on the fly, blending over seams automatically. By no means perfect but it'd save one hell of a lot of work.
    blended_Shader.jpg
  • Justin Meisse
    Options
    Offline / Send Message
    Justin Meisse polycounter lvl 18
    All I saw is voodoo in your post, how expensive is that? Cool technique. UVing terrain stuff isn't hard, just lay out some UV borders and do a pelt map, easy-peazy.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Genuinely I have no idea how expensive it is. I've never done shader writing before, I got Shader FX earlier today to practice my math for a course im doing. Ill clean it up tomorrow and post the sfx & .fx file.

    To put it really really simply the shader does blended box mapping of up to 3 textures and modulates between them with the R G and B Vertex colours.
  • cholden
    Options
    Offline / Send Message
    cholden polycounter lvl 18
    I do this type of stuff all the time. I usually flatten map or box map, then stitch. Like Justin said, we used to use multiple UV channels for different materials blending. Pretty easy to make things seamless as you can plan the seams where blending will occur. If you have good decals and propping, makes it a lot easier.
  • malcolm
    Options
    Offline / Send Message
    malcolm polycount sponsor
    We uv our large terrain meshes by planar mapping them from the top down and then smooth uv's in maya, takes 2 seconds to get no stretching uv's. Then we spend the rest of the our lives painting the rgb vertex blend and smoothing the results so you can't see triangles.
  • Joshua Stubbles
    Options
    Offline / Send Message
    Joshua Stubbles polycounter lvl 19
    Essentially, fletch's shader is a realtime version of Neil Blevin's "blended box map" technique, which is available in the Soulburn scripts.

    It's a cool premise for some things, but a lot of the time I'd like exact control over how it looks. I suppose for open areas of grass and such, it's a great technique. I'm sure the shader is a bit expensive though. Blending multiple channels and textures is always spendy.
  • Ark
    Options
    Offline / Send Message
    Ark polycounter lvl 11
    Autocon: Thanks for clearing that up, i fully understand what your saying now :D, must have had my dumb head on yesterday. I never thought about doing it like that. Thanks again for taking the time to explain.

    r_fletch_r: Looks awesome.

    Justin_Meisse: No, i've always enjoyed environment stuff more than the character stuff. Just wasn't aware that anything outside of 0-1 uv space would transfer over to a game engine.

    Tnx everyone for your inputs.
  • renderhjs
    Options
    Offline / Send Message
    renderhjs sublime tool
    the same technique is used as I believe in Polyboost aka graphite tools in max2010+ when you render a wrap map. It blends a input texture around the object as well and bakes it to the target UV channel.
    Although using a shader gives this thing a whole new dimension if its fast enough for real time situations.

    Maybe even a mix of things like a script that colors vertex colors depending on angle or world orientation and then a traditional texture blending script based on vertex colors to blend them would be another way of doing things.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    A script combined with this could be awesome indeed. It wouldn't be a stretch to write a script that automatically layed down vertex colours based on altitude / Worldspace Angle/ local curviture. That'd give you a nice quick way of laying down Grass on flat areas, Rock on steep faces. Sand Below sea level.(thats another day though)

    I'm re building the shader at the moment to use as few instructions as possible. Even if this is too expensive for realtime I'm going to make a MetaSL version so I can use it in Max. I think MetaSL may even do this natively.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    Here it is. Its has some problems blending hard angles but its quite fun to play with. Its especially fun modeling with it enabled.

    Its just for max at the moment. You will need to use a directX material to apply it.

    Workflow:
    Assign Black Vertex Colours to the mesh.
    Assign the Shader to the mesh.
    *Load a texture into atleast the base, and texture2 map slots.

    Paint Vextex Colours to expose the individual textures
    Red to expose Texture2
    Green to expose Texture3
    Blue to expose Texture4
Sign In or Register to comment.