Using tiling textures on models to replace displacements

Discussion in 'Tutorials & Resources' started by YM, Jun 1, 2016.

  1. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,742
    This has been something I've thought about doing for a long time. I've always wondered if it'd be possible use models instead of displacements for cliffs. They'd have a few advantages, namely the way displacement cliffs always seem kinda soft (or jagged) and have problems with texture stretching if you try and do any more interesting shapes. Now that props can have lightmaps, the main drawback of having to use vertex lighting is a thing of the past!

    So without further ado, what am I really talking about?

    If you've ever delved into TF2's materials, you may notice that many use a detail texure. There's a handful of grayscale textures that Valve use to add a bit of extra detail to their textures. The main benefit is that the detail texture is blended into the main texture at a different scale so that when you're really close up to the main texture, the detail texture still shows the some detail. Virtually every game uses this technique now to enhance perceived texture resolution.

    I took a modeled section of cave wall (thanks @Woozlez for the push to do this and the vmf), here this part is about 768x1024 units and just shy of 1000 tris. It's simple and not in any way something I'd ship but just something to use as a proof of concept.
    [​IMG]

    I then laid out the UV map, baked ambient occlusion and painted some very simple colours onto it, this texture is what serves as our large scale variation to the model. Without this, the detail texture would be not much more than a regular displacement's tiling texture, but with it, we can alter the colour of each area however we want.
    I also pinched an existing displacement cliff texture, desaturated it and used that as my detail texture. If I were to do this for real I'd probably be spending a lot of time on making the detail texture unique and interesting.

    These are 512 and 1024 pixels:
    [​IMG]
    You can see in the smaller material I've got the long light and dark bands running across the texture, the advantage of this method is it allows for nice strata like this.

    Then these two textures are blended together in the material like this.
    Code:
    "VertexLitGeneric"
    {
        "$basetexture" "models\props_rocks\rock_base_01"
     
        "$detail" "models\props_rocks\rock_detail_01"
        "$detailscale" 5
        "$detailblendfactor" 1.5
        "$detailblendmode" 0
    }
    And here's the result:
    [​IMG]
    [​IMG]
    All in all this uses a 512 base texture, a 1024 tiling detail map and a 512 lightmap.

    I've only spent about 4 hours on this in total, so it's easy to imagine I could get an entire map's cliffs done in a few days, a similar length of time to using displacements, but the shapes and forms achievable are far better.

    It'd be fantastic if someone actually used this method in a TF2 map, it could really take your cliffs to the next level, not to mention it'd be great practice at doing things in a way the rest of the games industry might.

    Appendices:
    Oh why aren't you using a normal map and baking details down from a higher res sculpt??

    Well, as it turns out... any prop that uses a normal map can't have a lightmap. See this image, the left hand fireplace and table are using default lighting settings, the right hand pair are set to use a 128 lightmap. As you can see only the right hand table actually has any luxels!
    [​IMG]
    Until I did this test I wasn't sure if a normal map would stop a lightmap from working, I already knew it stops vertex lighting. Oh well, Source is an ancient engine after all
    Why bother with a lightmap?
    Well... these images were from the first and second compile test, the top image uses vertex lighting
    [​IMG]
    [​IMG]
    There's not a huge difference, but the lightmap definitely performs a lot better where there are corners.
    Here's an excellent polycount thread about a similar technique used in UDK for a huge sea cliff. He makes a high poly sculpt, bakes a normal down to a lowpoly then blends in different tiling textures over that base normal map with fantastic results. If only Source weren't an ancient engine!
    http://polycount.com/discussion/117621/udk-sea-defenses
    You can simulate what the texture will look like by using an overlay layer in photoshop. The line in the vmt that defines $detailscale tells you how many times to tile the detail texture, for me it was 5. It looks like this:
    [​IMG]
    Lovely and pixelated! But because Source isn't downscaling the detail texture when it renders the model, it still has all the detail up close:
    [​IMG]
     
    • Thanks Thanks x 4
    • Useful Useful x 4
    • Creative Creative x 4
    • Like Like x 2
    Last edited: Jun 1, 2016
  2. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,440
    Positive Ratings:
    1,191
    Will probably do only with final/rc maps where the mapper is certain they will never change the shape.
    I have some another feeling against this method but I can't even word it, so negligible.
     
  3. iiboharz

    aa iiboharz Meme Queen

    Messages:
    715
    Positive Ratings:
    1,037
    Using this method would basically mean outsourcing my final displacement shape to someone who can competently deal with models. Save me the work :^)
     
  4. RataDeOrdenador

    RataDeOrdenador L5: Dapper Member

    Messages:
    235
    Positive Ratings:
    102
    [​IMG]

    Anyways,is it better to use models instead of displacements in terms of optimization? If maps can run much faster with models and yadiyada,it might be a nice idea. Either way,this "replace displacements with models" sonds interesting.

    I really need to start modeling something... But I need a proper computer first. :D
     
  5. iiboharz

    aa iiboharz Meme Queen

    Messages:
    715
    Positive Ratings:
    1,037
    Pretty sure models actually use up more memory? But in this day-and-age it's negligible as I can't imagine any of these models having a high poly density.
     
  6. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,742
    1hr 20 on mesh+texture to illustrate you can do things you really couldn't do with displacements:
    [​IMG]
    [​IMG]
     
  7. zahndah

    aa zahndah professional letter

    Messages:
    718
    Positive Ratings:
    627
    is that for an underwater base themed map where the mercs have been taken captive by an octopus?
     
    • Agree Agree x 1
    • Funny Funny x 1
  8. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,440
    Positive Ratings:
    1,191
    Actually it could be done with disps but learning 3ds max is faster.
     
  9. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,742
    Please, be my guest
     
  10. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,440
    Positive Ratings:
    1,191
    Wait. Do you want me to try?
    If yes, I did never mean it's practical/disp method is better.
    i was actually making a joke about how long could it take
     
  11. Empyre

    Empyre L6: Sharp Member

    Messages:
    294
    Positive Ratings:
    141
    It is probably also possible with brushwork, but it wouldn't be a good idea.
     
  12. EArkham

    aa EArkham Necromancer

    Messages:
    1,576
    Positive Ratings:
    2,199
    It's a complete shame that you can't also get normal maps working with this. A good normal map would make this technique look awesome.
     
  13. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,742
    If you want normal maps you need to sacrifice the lightmap, Bang says he did this for 2fort invasion. He imported the VMF using wallworm and baked the lighting in max straight into the diffuse texture. It's more work, especially if you need to edit anything, but it's possible.
    The biggest downside is that it makes each piece 10000% tied to that area, and impossible to use modularly
     
    • Agree Agree x 1
  14. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,440
    Positive Ratings:
    1,191
    Light/dark blend :B1:
    idk why i feel so crazy tonight ima try it tomorrow on my pc
     
  15. Tumbolisu

    aa Tumbolisu  I ⌄ I 

    Messages:
    947
    Positive Ratings:
    930
    Wouldn't it be possible to get the same effect by using VertexLitTwoTexture?
     
  16. fubarFX

    aa fubarFX The "raw" in "nodraw"

    Messages:
    1,624
    Positive Ratings:
    1,712
    vertexlittwotexture doesn't really do the same thing. iirc, it would transform your $detail into a blend texture sortof
     
  17. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,219
    The drawback to this is that your UV unwrap has to be almost perfectly level and plumb and evenly scaled all over so the overlay will look right. I imagine in CS:GO (assuming it supports lightmaps on models yet... does it?) you don't have to worry about this because you can have multiple UVs — hell, you can probably just set the first UV to some tiny, blank texture just to serve as the guide for the lightmaps and use the second one for your real texture.
     
  18. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,742
    Only if you have a detail texture that has a strong grain in it! The first example I did has that strong grain so it'd need to all be level but that second one has no clear directionality in it, you could easily rotate UV islands without it being a problem.

    Also, since when is keeping UV island scales consistent a drawback of modelling? It's just how it goes if you want consistently scaled textures.

    I'd also like to point out that if you don't have any strong directionality going, you can use the seamless tiling for your detail texture. Using that you can have variable UV island scales since the detail texture is projected in worldspace.
     
  19. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,219
    Are you talking about $seamless_scale? I thought that didn't work in TF2, or on models in general.
     
  20. YM

    aa YM LVL100 YM

    Messages:
    7,099
    Positive Ratings:
    5,742
    it works for model detail textures, but not for regular displacements