Seba's Basic Hint Guides

Seba

DR. BIG FUCKER, PHD
aa
Jun 9, 2009
2,364
2,728
I posted these on facepunch a while ago, I figured I might as well post them here too. Both guides are super basic, basically an explanation of how hints work and when/where to use them, and are aimed at someone rather new to optimization in Source. If you have any comments let me know.


What Hints Are and How They Work
-------------------------------------------------


Consider a situation like this:

iFa4KUd.png


In the above image we have two world brushes to cut leaves, two func_details to simulate players and renderable objects, and a light entity so the map'll compile (okay fine it'll compile without the light but it'll leak). If we click Map -> Load Portal File -> Yes, this shows up:

SXNG804.png


The blue lines show the leaves VBSP cut in your map. If VVIS can go from one leaf's volume to another's without crossing any visibility-solid geometry (world brushes) then a player standing in the first leaf will render everything contained in the second leaf. Sometimes this is undesirable, as the blue cube (the player) will render the red cube (a prop) despite not being able to see it. Even though the leaves are cut in front of the wall, they extend above the wall as well, which means that VVIS can connect them. To fix this we'll put a world brush above the wall, like so:

ck5A678.png


The brush is 5 faces toolsskip, 1 face toolshint. The hint face is coplanar with the top of the wall. In this example I've made the hint face the top face, but it could very well be the bottom face of a brush above the wall. All that matters is that the hint face is on the same plane as the top of the wall. If we recompile and reload the portal file, we'll see this:

lgLw8dy.png


You can see that VBSP has now cut the leaves along the top of the wall. As a result, the blue cube won't render the red cube because VVIS can't draw a straight line from the blue cube's leaf to the red cube's leaf.

That's the basics of using hint and skip. Hint is the real workhorse here, as it tells VBSP where to cut leaves. Skip is used on the other faces so VBSP will ignore them (won't cut leaves along those faces). Now, of course, the above example is very primitive and involves five brushes, but in real maps you'll have more props, overlays, whatever, that can hugely impact the player's performance. Hint brushes are used to manually fine-tune leaves to render as little out-of-sight detail as possible.

Here's some more information about visleaves, toolshint, and toolsskip.

VBSP automatically cuts vertical leaves every 1024 units, like so:

rlsCfHD.png


The above example map is centered on the origin, hence the way the leaves are split in the center. If we recompile the map within the default 1024^2 cuts, we'll get leaves like this:

jGJ2TGB.png


In which case we'd put the hint faces on top of the wall and on the front face of the wall:

olqG0uS.png


Isn't that so much cleaner?


Horizontal cuts will only go to the nearest edge of a 1024 vertical cut:

r5pPmT0.png



Toolshint causes func_detail brushes to cut leaves:

Z1WX9Lt.png


unless the other faces are toolsskip:

R2ZWDpv.png



Toolshint and toolsskip get their unique properties from the %compilehint and %compileskip (respectively) VMT parameters. %compilehint makes VBSP always cut leaves along those faces, %compileskip makes VBSP always ignore them.




How to Use Hints, a More Practical Approach
---------------------------------------------------------------


Let's say this is what you're starting out with:
gru1D7A.png


and a quick compile gives this (the roof additions are func_detail, since they definitely won't block visibility):
Hlw3dKL.png


You can optimise the corners using diagonal brushes.
TuqoyI9.png


However, as you can see, there are no horizontal cuts except the ones done by buildings, and those stop at the default 1024 leaves. Because of this a lot of leaves can 'see' other leaves just because they're very tall. This can be remedied by putting a large, map-covering (in my example) hint at the height of the lowest roof (ignoring the func_details of course, because they don't affect leaf cuts).
vViajkz.png


Now the diagonal hints really get their money's worth, since every ground-level leaf only reaches the top of the lowest leaf-cutting object and the leaves the players will be in most of the time can't 'see' into each other.
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
You know what I just realized Hammer could really stand to have? A "hide skip faces" button like the one that hides nodraw faces. That, and for toolshint to have $nocull enabled, but that can be fixed by creating a custom material file for it.