Using tiling textures on models to replace displacements

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
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.
rockwip_12.JPG


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:
rockwip_11.JPG

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:
rockwip_08.JPG

rockwip_09.JPG

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!
proplightmaps.JPG

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
rockwip_03.JPG

rockwip_04.JPG

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:
rockwip_13.JPG

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:
rockwip_10.JPG
 
Last edited:

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
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.
 

iiboharz

eternally tired
aa
Nov 5, 2014
857
1,291
Using this method would basically mean outsourcing my final displacement shape to someone who can competently deal with models. Save me the work :^)
 

RataDeOrdenador

L5: Dapper Member
Oct 12, 2015
230
105
EqlTZj3.png


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
 

iiboharz

eternally tired
aa
Nov 5, 2014
857
1,291
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

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.
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
1hr 20 on mesh+texture to illustrate you can do things you really couldn't do with displacements:
rockwip_14.JPG

rockwip_15.JPG
 

zahndah

professional letter
aa
Jul 4, 2015
721
642
is that for an underwater base themed map where the mercs have been taken captive by an octopus?
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
Actually it could be done with disps but learning 3ds max is faster.
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
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
 

Empyre

L6: Sharp Member
Feb 8, 2011
309
187
It is probably also possible with brushwork, but it wouldn't be a good idea.
 

EArkham

Necromancer
aa
Aug 14, 2009
1,625
2,773
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.
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
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
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
Light/dark blend :B1:
idk why i feel so crazy tonight ima try it tomorrow on my pc
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
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.
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
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
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.
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
Are you talking about $seamless_scale? I thought that didn't work in TF2, or on models in general.
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
it works for model detail textures, but not for regular displacements