Tutorial: How to create nice displacements.


Dash
04-17-2006, 01:47 AM
Alrighty, I'm writing this tutorial for the many many mappers out there that have trouble with making nice smooth displacements and keep their maps optimized at the same time.

My technique is very simple and it is based on powers of 2 to work. This is a VERY important concept to achieve smooth and leak-free displacements.

Rule #1: Powers of 2
Almost all the models you will use and all the entities are based on powers of 2, this is a very important concept for displacements, as their precision factor ("power" in the displacements window) is also based on the power of 2 (2^2, 2^3 and 2^4).

The best way to make displacements is to choose a magic trio number that consist of 3 numbers from the power of 2 such as 16, 32, 64, 128, 256, 512, 1024 (you get the idea).

Each displacement will be a square of the size of one of these numbers, so you will need to plan in advance. You ABSOLUTELY HAVE to choose 3 numbers in a row (16,32,64 is good, but 16 64 128 isn't).

Most maps usually use the 1024,512,256 trio or the 512,256,128 for more precision. More on that later.

For this tutorial I will be using the 256x256, 128x128 and 64x64 trio.

Rule #2: Subdivisions

This is directly linked to Rule #1. Subdivisions are what are making your displacement. A displacement is built with triangles, or rather divided squares. The more subdivisions, the higher the amount of detail you'll be going into.

Rule #3: Splitting

Splitting your terrain is extremily important. try to make the smaller squares near buildings, and large squares in empty fields. This way you'll be able to optimize easier in the end (more on that later).

Rule #4: Sewing!!!!

Sewing is your god here. Always Click "Sew" whenever you are modifying the geometry of your displacements to verify for correct connectivity between displacements. This will avoid you from having displacement leaks and spot bad optimization faster.


ONTO THE TUTORIAL!!!!

http://www.daretogame.com/maps/tutorial_displacements/01.jpg
Displacements are faces of polygons that have been extracted and subdivided. Before doing any displacements, place square brushes (also known as polygons) around your buildings. Each brush will need to be a square of the size of your chosen trio (in this case it's large 256 by 256, medium 128 by 128 and small 64 by 64).
Be sure to apply the NODRAW texture to the brushes you'll be making and do NOT make them overlap. Always be sure that ALL THE EDGES ARE ALIGNED TOGETHER.

http://www.daretogame.com/maps/tutorial_displacements/02.jpg
Apply a "Blend" texture or any other texture you wish to use on your displacement on the top face of all the brushes. It's wise to check the "Treat as One" option here, especially when dealing with grass. Be sure to set the rotation and scale to your preferences here.

http://www.daretogame.com/maps/tutorial_displacements/03.jpg
It's not time to create the displacement. On the displacement tab, click "CREATE" and select Power: 2.
You will see your terrain split up in different sized subdivisions.

http://www.daretogame.com/maps/tutorial_displacements/04.jpg
In fact, this subdivision is problematic. Using AUTO-SEW (check it), start making mountains around the house.

http://www.daretogame.com/maps/tutorial_displacements/05.jpg
You'll notice that the edges aren't lining up together nicely because the subdivisions are different. This is where the Rule of Power of 2 and Subdivisions kick in. If you followed the rules, this is an easy issue to fix.

Right now, all the displacement pieces have the power of 2. This means that no matter what size your displacement is, it will be split up in 4 pieces (which will then be subdivided to form 32 triangles).

This little equation will be useful:
16x16 fits 4 times in 32x32, 32x32 fits 4 times in 64x64.
Basically, everytime you go up one number of the magic trio, the number of squares formed by the displacement power (which is 2 for all) is upped to the square.

We will be working on the smalled scale here which is 64x64. If you want to have uniform displacements, all displacements will need to have 32 triangles per 64x64 region. This is where the play on powers comes handy.

64x64 will keep the power of 2, since this displacement is the root size of others.
128x128 will need to have its triangle count squared, as I explained above. This means its power will be bumped up one more square, so 128x128 becomes power of 3.
256x256 will need to double square its triangle count, so we add 2 to its power, which is 4, and also the maximum power a displacement can have! Pretty neat huh?


http://www.daretogame.com/maps/tutorial_displacements/06.jpg
After changing the power of each displacement, this is how our terrain now looks like subdivided. Pretty smooth and uniform isn't it?

http://www.daretogame.com/maps/tutorial_displacements/07.jpg
Here you can see a 64x64 displacement selected on the left and the 256x256 displacement on the right. They look the same.

Dash
04-17-2006, 01:50 AM
http://www.daretogame.com/maps/tutorial_displacements/09.jpg
I flattened the displacements and selected ALL of them. Now it's time to retry painting geometry on our new uniform displacement.
Be sure to use Auto-Sew and click "Sew" often. Mistakes are now virtually impossible to make.

http://www.daretogame.com/maps/tutorial_displacements/10.jpg
Displacements now work perfectly together without any leaks. There is also no need for layering, as no displacement is leaking and bleeding is useless because the displacements arrive exactly on the edges on the building.

http://www.daretogame.com/maps/tutorial_displacements/11.jpg
And this is our final result with a few different shaped displacements chosen.



I will create another tutorial on how to deal with diagonal buildings with the same technique.
Feel free to ask any questions.
Stay Tuned!

Furyo
04-17-2006, 05:14 AM
Not to diss your own work cause the end result looks like you can handle yourself with displacements very well, but the use of level 4 displacement should be very limited.

Displacements will increase your bsp size ten folds, much like the "power of 2" rule, a level 3 displacement takes a lot more space than a level 2, and the level 4 is the absolute space filler.

So when in the end you're gonna end up with very similar results, you could limit yourself to level 2 and 3.

Dash
04-17-2006, 12:17 PM
I know what you mean, but you have to take the sizes into consideration.

The example I took for the tutorial is extreme, nobody's going to make 256x256 displacements with power of 4, but if you use a 1024 displacement with a power of 4, it covers so much space that you will use these sparingly.

Logically, it means the larger the displacement, the less likely you'll be using it, and the less likely you'll be using displacements with power of 4.

Ace_McGirk
04-17-2006, 01:33 PM
Originally posted by Furyo
Not to diss your own work cause the end result looks like you can handle yourself with displacements very well, but the use of level 4 displacement should be very limited.

Displacements will increase your bsp size ten folds, much like the "power of 2" rule, a level 3 displacement takes a lot more space than a level 2, and the level 4 is the absolute space filler.

So when in the end you're gonna end up with very similar results, you could limit yourself to level 2 and 3.

in the end its not bsp size that matters.It the fps the finished map has.

Remember that the number of polys per given area is not just based on the powers,if you make a 4096 unit square brush and give it a power of 4 you will have LESS polys than 4 1024units brushes with a power of 4 that cover the same area.So to say a power of 4 is expensive is misleading.My experience tells me to "use the smallest brush/highest power that gives you the ""smoothness"" you need",keeping in mind the other details you need to add, the more prop_xxxx's you need to add, the better off you are with the lower powers.

Also, brushes need to be 1/2 the size of the brush next to it to sew properly and the two vertices on the edges that meet of each brush MUST lie in the same horizontal plane.(vertical if you used the 'vertical' faces of the brushes to make walls.etc)

Creative use of brush size, fog and farz clipping will overcome the "limits" of a power of 4.Decompile dod_alps and see,I used power of 4 almost everywhere,the main terrain and for the displacements that make the road.

I ALWAYS start with big brushes first,power of 4, then cut the brushes in quarters as many times as needed to get the detail I need.

In the end,there are not many hard rules to follow, just make sure the fps in the finished map is what you wanted.

Furyo
04-17-2006, 04:07 PM
Displacements are FPS' best friend, no matter what level you use for them. They're so cheap to render they're a joke.

CoolHand
04-17-2006, 05:38 PM
The power really depend on what you are doing with it. For example I making a 10240 X 10240 unit map size. So I made 512 X 512 square at the power of 4. Anything lower on such a big brush end up being not enough to creat realistic terrain. At the moment doing a normal compile I sitck with 100 FPS and 12 Mg o file with usage of fog.

PS: I will add this tutorial to dod-federation tutorial search engine :)

Sly Assassin
04-17-2006, 07:45 PM
nice tut.

I've been creating a map for the mod I'm on since September last year, I've been using 2048 unit squares set to the power of 4 and have found I can get great looking terrain off such a limited amount of subdivisions. Like someone else commented there isn't any hard set rules for displacements, basically take your time and always use the 16, 32, 64, 128, etc rule other wise things can get tricky, though in saying that it can work aswell ;)

McJewels
04-18-2006, 09:56 PM
and dont forget you can use rectangles to fit in areas, as long as the ratios of the sides are exactly 2:1, 3:1, and so on, so they can sew to the other dispacement youre using.

Dash
04-18-2006, 10:49 PM
Originally posted by McJewels
and dont forget you can use rectangles to fit in areas, as long as the ratios of the sides are exactly 2:1, 3:1, and so on, so they can sew to the other dispacement youre using.

True, but rectangles aren't the best option as they will create a stretched out terrain, unless that's what you're aiming for.

Ace_McGirk
04-19-2006, 01:02 AM
Originally posted by McJewels
and dont forget you can use rectangles to fit in areas, as long as the ratios of the sides are exactly 2:1, 3:1, and so on, so they can sew to the other dispacement youre using.

Actually you can use ANY four sided brush(topview) look at flash for examples.....

Day of Defeat Forum Archive created by Neil Jedrzejewski.

This in an partial archive of the old Day of Defeat forums orignally hosted by Valve Software LLC.
Material has been archived for the purpose of creating a knowledge base from messages posted between 2003 and 2008.