Home Technical Talk

UV tiling tricks within 0 to 1 space.

Hello,

Some of your views of tiling is probably the auto tiling of a single map, that goes outside of the 0-1 space, such as the UVs generated by Loft, or the auto tiling that most 3D engines provide.

However, what with the awareness of combining materials, lowering draw calls etc, I'm sure most of you have experience of working completely in 0 to 1 space, and tiling manually.

Here's an example of what I want to do, this is just an initial mock up of a track I'm building for the first time with line/sweep.

track_uvs.jpg


Getting basic tiling working in this way couldn't be easier, you just select UVW face mapping, then unwrap UVW, and position the UVs wherever you want them on the map.

However, in this case I actually want a square portion of the texture to span across 3 polygons, not one, obviously, as you can see the textures are all squashed.

Obviously what needs to be done is to scale and stack UVs in bunches of 3.

This can be achieved manually with the dot loop function in graphite modelling tools, but do any of you know of a better/more automated way?

Basically, do you know of a tool that specialises in custom tiling within the UV map? Or do I just need to make a tool myself?

Cheers,
RumbleSushi

Replies

  • AlecMoody
    Offline / Send Message
    AlecMoody ngon master
    couldnt you just overlap all your chunks of faces and then type in the U cords (0 .333 .666 and 1)
  • rumblesushi
    Hi Alec, you're right, position the UVs is the easy bit. I was more thinking about an automated selection process. To play around with spanning a texture across different numbers of faces quickly, to save dot looping 4 times for example if you want to span a texture across 4 faces for example.

    I wondered if there was a common method/tool that people use, or if people simply do what I'm doing.
  • Eric Chadwick
    There really isn't a good way of doing this in Max.

    One way could be to try a Loft for the track, and add a UVW Xform modifier on top.

    In the Loft, turn on Apply Mapping but turn off Normalize... that way each face is given equal distance in UV space. Then use the UVW Xform modifier to tweak the tiling amounts. You'll still have to get in there and edit the UVs some, but it should help.

    If you're using texture filtering, don't forget about leaving room for bleeding!
  • rumblesushi
    Thanks for the info Eric., I'll give that a go with loft.

    Gotta admit, that kind of surprises me. Given that texture atlases etc are popular, this surely has to be a VERY common way of UVing for environments?

    When you say there isn't a good way of doing this in Max, how does any other software handle it?

    PS - Eric, could you post the link you showed me ages ago, describing the game you made using modular pieces etc?

    Cheers.
  • Eric Chadwick
    Well there are a couple utilities that certainly help. Check out TexTools, MorphMap, Texture Atlas Generator.

    Not much info in that link I shared awhile back, but here it is.
    http://ericchadwick.com/img/world_of_zoo.html
  • Eric Chadwick
  • rumblesushi
    Eric, actually I have some experience with texture atlasing and sharing materials, I was talking about the other game you worked on (I meant modular geometry rather than textures).

    You mentioned it was for a studio that is now closed down, with a clever guy that developed a nice 3D engine etc. I seem to recall it's a shooting game, and you detailed your workflow for it, using modular assets on a somewhat driving game esque course etc.

    Workflow wise it's different to what I am doing now, but something I'm interested in.

    PS - That atlas generator looks very impressive. I actually downloaded it months ago but haven't bothered to use it. I didn't realise it even made the necessary cuts in the model to adapt it from traditional tiling etc. Looks good indeed.
  • Eric Chadwick
    Ah, I culled that page to narrow down my portfolio a bit. Here are the relevant bits I think...

    nte_screenshot_lava.jpg

    Terrain was made of canyons underwater, so I created a set of U-cross-sectioned canyon pieces that all tiled with one another. I tiled the textures on each piece in whole numbers along the length of each piece, so the canyons would tile seamlessly together. I also had to make sure things mirror-tiled at the edges... when a texture is mapped onto a U shape, as it goes across the U to the other side it changes to upside down. This means when another piece is rotated 180° and snapped to the first piece, the two pieces will meet with their maps upside down to each other.

    nte_landscape_tiles.jpg

    The Whatif engine uses a morph-like technology for blending multiple meshes, so I created four variations for each canyon tile (basically four morph targets). In the game the walls were then randomized in a blend between the four shapes, to add variation so no walls were ever exactly the same. I used the same morphing technique to create lava fissures that open up as the player gets near, with flowing lava in the cracks. I used the transition to fade in baked lightmaps that splash orange lighting across the mesh.

    nte_layout_in_max.jpg

    We laid out the entire game level and all the entities using 3ds Max. Max's Xref system wasn't production-ready yet, so we made our own lean-n-mean exporter-compatible Xref system. Scene scale becomes really important if laying out a scene that stretches for miles, because the precision gets really bad at small vs. large scales, seams stop snapping together if the unit scale isn't correctly accounted for at the start.
  • Arcanox
    I don't mean to HiJack this thread, but it's somewhat relevant. I've cut up a couple meshes similar to the manner that RumbleSushi is describing and I've aligned clusters manually but they fall outside 0 to 1.

    Is there a simple script that'll take the clusters that I've already aligned and simply pack them into normal UV space without losing the alignment? I know several other people have talked about using a script like that to finalize some of their assets but I haven't been able to find it. Does anybody know where I can pickup a script like that?
  • Eric Chadwick
    TexTools has some stuff for this... Sort, and Pack
    http://www.renderhjs.net/textools/

    ... but not exactly what you want I think. You might also try Copy & Paste, Paste works on multiple clusters at a time, as long as the faces are identical.
  • Arcanox
    uvspaceexample.jpg

    This is mainly what I meant. I know there are a lot of pieces of geometry that aren't cut up so they fit into normal UV space, but ignore those. I'd just like to move clusters that I've aligned outside of normal uv space into 0-1. I like to do all my alignment to the left or the right so I don't end up having issues selecting specific clusters. Or even if I'm using multiple sheets on one model, I'd like to have the clusters that use different sheets separated so they don't get overlapped.

    I already use TexTools, but I haven't seen that specific packing feature.
  • Eric Chadwick
    Arcanox wrote: »
    I'd just like to move clusters that I've aligned outside of normal uv space into 0-1.

    Do you just want to move it 1 unit up on the V axis? There's a type-in area for this in the lower left corner of the Edit UVWs window. I'm probably not understanding you though.
    Arcanox wrote: »
    Or even if I'm using multiple sheets on one model, I'd like to have the clusters that use different sheets separated so they don't get overlapped.

    Why not just pack each into its own 1-unit-square area... u=0-1, u=1-2, u=2-3, etc. As long as your shader isn't set top Clamp its UVs, they'll still be mapped the same as if they were all inside 0-1.
  • rumblesushi
    That's what I was going to say Eric, that yep, you can shift the entire group by 1, which is what I do with stacked UVs for baking etc. Very easy.

    But like Eric, I'm not sure exactly what you mean Arcanox.

    Oh and by the way, thanks for the info about the level ;)
  • Arcanox
    Do you just want to move it 1 unit up on the V axis? There's a type-in area for this in the lower left corner of the Edit UVWs window. I'm probably not understanding you though.



    Why not just pack each into its own 1-unit-square area... u=0-1, u=1-2, u=2-3, etc. As long as your shader isn't set top Clamp its UVs, they'll still be mapped the same as if they were all inside 0-1.

    That's exactly what I mean. I was hoping there was a script that would do this automatically though. I've been working with UDK for the most part and it doesn't have issues with clamping.

    The thing I was looking at in particular is an older engine I was dealing with and it did clamp UV's and mapping outside normal UV space isn't possible. I know that some other Polycount folks have talked about some scripts that actually look at each shell and determine how much it needs to be offset so it's packed in normal UV space. That way, you could go through a whole bunch of assets at once and have them packed and ready for export.
  • rumblesushi
    Writing a script for that should be ridiculously easy, if you know your UV's are always offset by 1.

    If (UV.u < 0) {
    UV.u += 1;
    } else If (UV.u > 1) {
    UV.u -= 1;
    }

    Except in MaxScript of course.
  • Eric Chadwick
    Arcanox wrote: »
    That's exactly what I mean. I was hoping there was a script that would do this automatically though.
    Here's one I made for this awhile back. You could easily adapt this for V offsetting too.
    macroScript OffsetU
        category:"Eric Chadwick"
        tooltip:"UVW Offset U+1 (Shift = -1)"
        buttonText:"OffsetU"
        (
            if classof (modPanel.getCurrentObject()) == Unwrap_UVW then (
                if keyboard.shiftpressed do (
                    $.modifiers[#unwrap_uvw].unwrap2.MoveSelected [-1,0,0]
                    )
                if not keyboard.shiftpressed do (
                    $.modifiers[#unwrap_uvw].unwrap2.MoveSelected [1,0,0]
                    )
                )
                    else (
                    messageBox "Select an object that has an UVW Unwrap modifier!" title:"UVW Offset U" 
            )
        )
    
    Arcanox wrote: »
    I've been working with UDK for the most part and it doesn't have issues with clamping.

    I don't use UDK, but clamping is very helpful as a shader option in general. It simply prevents tiling, so your UVs can be right up against the edge of the uv box, and you'll never get filtering artifacts from the other side of the map. A good example is a cubemap on a cube... you don't want each face to filter along the edges, since that would create seams.
    Arcanox wrote: »
    I know that some other Polycount folks have talked about some scripts that actually look at each shell and determine how much it needs to be offset so it's packed in normal UV space. That way, you could go through a whole bunch of assets at once and have them packed and ready for export.
    TexTools does this nicely!
Sign In or Register to comment.