Home Technical Talk

Mapping for modular textures

I've recently been reading this article on the wiki, and though it discusses the advantages of the technique, the buildings all seem to be one mesh (excluding the roofs) how can you set up a mesh so that I can change the texture of individual sections like that? Do I use multiple UV maps for different sections, and if so, wouldn't that be a detriment to performance?

Replies

  • m4dcow
    Options
    Offline / Send Message
    m4dcow interpolator
    Well just about all of the textures used for this are tiling textures, so it seems to be just different shaders applied to different faces. If you bring this into UDK, you can apply whatever you want to a particular slot different style of roof, wooden walls instead of thatch etc...

    If you mean the wall sections between the beams when you say individual sections, then I'm pretty sure those faces are split according to the pattern of the beams (or at least some of them) and you can move the face around in UV space to get it where you want, seams don't matter all that much since they are covered up by the beams. You could also add a bit more geometry and get better vertex shading.

    There is nothing saying you can't split these sections up to make them modular, but I think it should only be done to a small extent as it could end up being a nightmare trying to fit these things together. The style is also simple enough that you could create some unique designs fairly quickly.

    I suppose there maybe some performance implications with using so many material ids, but if you're doing a whole village its probably worth it. Also if you break it up modularly into many objects along with many material ids, that will likely be more draw calls than the mesh merged together (depending on how the engine handles this).
  • dregoloth
    Options
    Offline / Send Message
    Alright, thanks for the help.
  • Eric Chadwick
    Options
    Offline / Send Message
    m4dcow wrote: »
    I suppose there maybe some performance implications with using so many material ids, but if you're doing a whole village its probably worth it. Also if you break it up modularly into many objects along with many material ids, that will likely be more draw calls than the mesh merged together (depending on how the engine handles this).

    This is indeed very bad for performance. Usually you should not use multiple materials for each model.

    But it depends on how the game engine is set up. If it handles instancing really well, then you can make the buildings out of multiple separate objects. But if this kind of approach slows down the framerate, which it usually does, then it is better to use a single material for the whole house (or large chunks) and use a texture atlas.
  • Mark Dygert
    Options
    Offline / Send Message
    I agree with Eric, its also better to use separate meshes because most engines can cull a few pieces that aren't seen (roof, windows, walls ect) and help performance rather than keeping the whole building visible because you can see a tiny corner of it.

    Or worse, it bases it's visibility culling calculation on the objects local pivot and it culls the whole building while its still visible, which is more likely to happen with big meshes.
  • leechdemon
    Options
    Offline / Send Message
    leechdemon polycounter lvl 11
    This is kind of funny... I'm actually in the process of taking a set of buildings I created using tiling, modular portions, and baking them down into single object, single texture sets.

    My original thinking was that, say for a city scene, all brick could be one draw, all generic windows could be another, etc. Based on that, you'd end up with way less draws than if each building was it's own texture, on top of which you'd benefit from the high resolution potential of a tiling texture. We've been doing some performance checks on another project, and our draws are our big downfall, so I'm proactively squishing these down.

    The brick portions still tile, but they tile on the same map as the windows and other bits. However since they're tiling, I'm not able to put AO into this set. Alternatively, if I unwrapped the entire building in order to get unique UV's, I'm worried my resolution would plummet. Is there a way to get around this, or is the solution putting AO into a different UV channel, Vertex Color, or someplace else?
  • Mark Dygert
    Options
    Offline / Send Message
    If you haven't checked it out yet there is a very handy script for carving up tiling meshes and converting them to texture atlases.
    http://www.scriptspot.com/3ds-max/scripts/texture-atlas-generator

    As for the problem with AO, the 2nd UV channel seems to be a logical way forward if you have a lot of unique shadow details. Keep in mind you can stack/offset UV shells that are similar(like the windows) saving you some space and allowing you to up res your AO without having to up your map size. If you have some unique shadow details (like a drain pipe, AC unit or planter box) you can give the affected pieces their own space, or it might be fine just to leave alone and forget about the shadow.

    Stacking the lightmap gets you into trouble with UDK sometimes, because it bakes in 100% unique lighting info into the light map. You can still do it if you know UDK will calculate the lighting on each tile exactly the same. but if you're engine doesn't render/bake lighting into a lightmap, then you are free to stack AO shells.

    If you lay it out properly you probably won't need a 2nd UV channel, you can add it to the diffuse atlas.

    I don't think vertex color will net you very good results unless the mesh is fairly dense and I'm not sure if its any more efficient that an second UV channel? Also the workflow for baking lighting into the vertex color channel can be a long drawn out ordeal.
  • leechdemon
    Options
    Offline / Send Message
    leechdemon polycounter lvl 11
    I saw the script in the past, but I'm still not quite sure what the advantage is. In the example I attached in my last post, you can see that I took the brick textures and ran them off the top and side edges. That way I can still tile those portions. Is the benefit of the script that you don't have to do that? That it takes everything that runs off the edge, and puts the tile breaks into the geometry instead of having your map do that?

    I ran it a few times on that model; if I do it per-part (the original mesh is about 150 boxes), then each face quickly turns into 50 faces, and my mesh gets spendy FAST. If I do it to the entire building, flattened to one mesh, it crashes on me. I have a lot of tiling of the bricks, so I'm wondering if that's causing me problems?

    I guess the advantage of vColor AO is that you don't need to supply a map. You're not "resolution bound" by your image, but you're still bound by the number of vertices. Also, Radiosity sometimes does stupid things with intersections; one side is white, the other is black. I'm playing around with the idea of baking Radiosity and Light Tracer with a few bounces, then blending the results into vColor... not sure if that's a solution or not yet, though.
  • Mark Dygert
    Options
    Offline / Send Message
    I doubt it would do running textures like that. It seems to carve the geometry where ever there is a tile edge then stack the geometry on the texture atlas. When all is said and done the script will have everything inside the 0-1 space, nothing will hang outside.

    For example, if you run it on a single poly that has a brick material set to tile 2 times in both directions and you run the script it will carve the mesh in 4 pieces and stack the UV's. If your mesh is already carved up, then it could run into some problems.
Sign In or Register to comment.