Optimization for newbies

From rANdOm Wiki
Jump to: navigation, search

Original post by:Mehis

Piece of advice before starting to read this.

If something doesn't work, don't give up. Optimization is part of mapping, what you want to learn. Without, people will complain about the lag. Which usually comes to removing your map or fixing it by decompiling, which makes it even worse.


Func_detail

Func_detail, is a brush entity, which doesn't counter with vis leafs. You could imagine it as it was not there. You can see through it, but not go through it. Like invisible wall, without being a wall.

Here is an example of func_detail and a world geometry.

World geometry (left), Func_detail (Right) Those boxes, corners highlighted with blue lines are leafs. They show what you can see and what you can't. Lets say there is a prop on the other side of the room, but you cannot see there. But, it doesn't mean the leaf you are IN can see it. If the leaf cannot see it you are in, neither do you. This is already calculated when you compile your map, that's why it's important to keep your map clean.

Obviously the left one is bad. This is because it tries to calculate what player can see on those little leafs. This will result in compile log error WARNING: Cluster portals saw into cluster (usually). It basicly says, that there are too many leafs clustered together. In-game this usually causes huge fps drops, invisible walls, etc. Even problems, which doesn't have to do anything with the leafs. If you don't get this error, it doesn't mean your map can have these mistakes. VVIS (The leaf calculating program.) would take longer to compile your map. (No, VVIS does not compile your map. There are two other programs, which does own sections of your map.)

(90 degree arch) Here, you have made an 90 degree arch. If you would now compile it without turning it into func_detail, it would take longer time to compile. You could turn it as it is to func_detail. But, i'd rather do this: Taking the whole arch apart and make each section of it func_detail. Press Ctrl+U. It ungroups the arch to their own smaller sections. Like this Now, simply click each section and press Ctrl+T. This creates brush entity. Select from the dropdown list func_detail. Repeat. (No, you don't have to press Ok or anything to apply this.) If you want to move it around like arch again, select all the section and press Ctrl+G. It will group them back together. The main point is to func_detail every single brush on it's own.

This next picture, is a demonstration what you should func_detail and what not. Everything small or complicated should be func_detailed. Small slopes like this is usually func_detailed. However, if the slopes are big enough to block player's view, you can leave it as world geometry.

Func_detail these.
· Stairs
· Slopes
· Small geometry
· Complicated geometry
· Pillars, supporters, etc.
· Thin brushes

These you MUST func_detail. (func_detail is like every other brush entity. Other entities like func_brush, func_illusionary, too doesn't counter with leafs. If you want to make them func_brush for an example, it will act like func_detail. Func_detail is just the cheapest version of all of them.)

More examples:
http://img853.imageshack.us/img853/6517/brush05.png This ceiling is problematic. Ceilings are usually world geometry, but in this case it isn't. If the ceiling is func_detail, then you'll just have to cover it with brushes.
http://img3.imageshack.us/img3/6301/brush06.png
http://img507.imageshack.us/img507/2586/brush07.png
http://img844.imageshack.us/img844/6200/brush08.png

Read more about func_detail


Fade distance

Fade distance is the most easiest part of optimization. With fade distance, all props (Some entities. This includes, weapons, healthstations, etc.) fades away. This means that the prop isn't rendered anymore in certain distance.

Simply go into prop's properties and choose your fade distance.

600-1000 indoors
1000-3000 outdoors
You'll just have to experiment and find the right one.


Helping VVIS

In this section, you'll have to use your brain and know something about HINT and SKIP textures. Skip, like the name, is nothing, skipped. It doesn't do anything. It's not rendered. When map compiles, all faces with SKIP gets removed completely (You cannot use SKIP texture like nodraw. E.g, for optimization purposes). They aren't there anymore. Hint however, 'blocks' leafs from going through it. It cuts them into own seperate pieces.

http://img16.imageshack.us/img16/4331/brush10.png Lets say you compile your map, you use mat_wireframe 3, but you can still see the barrel from the other side of the wall. This means, that the leaf you are in, can see the leaf where the barrel is. You don't want it to do that.

You fix the problem, by adding a SKIP textured brush like in the picture and making one of the sides HINT texture. Imagine it as a wall, you can't see it and you can go through it.

If player can go over the wall, you just put another one like this. Imagine it as a ceiling, you can't see it and you can go through it. Now the 'player-leaf' can't see the 'barrel-leaf'.

This doesn't mean, that the leafs must be blocks. This is perfect example. The players cannot see each other, until one of them steps inside the hint brush.


Areaportals

Areaportals are used to block player's view to the other side of the areaportal. They are usually placed on doors, windows, small cracks, etc. The engine in-game calculates what player can see and what not. Just make a brush size of the door and texture it with areaportal texture. Ctrl+T and from dropdown list select func_areaportal. Make sure that initial state is closed. (If the door is closed.)

Here is an example. We could simply put an func_areaportal on the door, but OH NO! There is a gap in the wall! If we would compile the map without fixing the gap, it would crash the game. That's why there is func_areaportalwindow for the gap. (Imagine the void as skybox.) Now when it's fixed, you can happily play your map.

Example what areaportals do. When the door is closed, both barrels aren't rendered for the player. When the door is opened, player can only see the white barrel. If the player moves more to the left, the brown barrel would be rendered eventually. Cool isn't it?


Occluder

Occluder is mostly used when you cannot use areaportals. It calculates, if the player can see all the content what's inside it. Pretty much works like areaportal. Make a brush bigger than the model, use occluder texture on it. Ctrl+T, func_occluder.


Others

Connecting walls like this, optimizes your map too. It saves one face from rendering. It might not sound much, but it makes the map more clean.
Nodraw. Simple as that. Apply nodraw texture on every face where player can't see. This includes unreachable places such as roofs and skyboxes.


--Shawn 10:31, 25 January 2012 (CST)