Hint brush

From Valve Developer Community
Revision as of 23:24, 23 May 2006 by BJ (talk | contribs) (leafs -> leaves)
Jump to navigation Jump to search

Hint planes are used to split visleaves during compile time and, as such, are a way of optimising the results of the Vis map compile stage.

They are commonly referred to as hint "brushes" since they are placed in a map in the same way as a normal world brush. The hint plane is defined by the side of the brush that is covered with the tools/toolshint texture. Multiple hint planes can be defined by texturing multiple sides of the brush, or by using multiple brushes. The other sides of the brush that are not acting as hint planes must be covered with the tools/toolsskip texture; these faces will be ignored by the compiler.

Hints are automatically tied to their own visgroup, so you can easily hide them.

A number of example maps and a tutorial discussing their use can be found below.

Todo: Determine whether tieing a hint brush to an entity causes it to stop acting as a hint brush.

Why and when to split visleaves

Note.pngNote:Learning how visleaves work may aid the understanding of this article. (See that link.)

Sometimes, certain leaf shapes are preferred over others simply because that shape makes those leaves see less other leaves. (which means less stuff to be rendered, thus a faster map).

The following illustrates the importance of visleaf cutting, and, at the same time, provides examples on where hints are useful.

The first example is almost the same as the SDK example map. This is a side view of a single room with players and pipes separated by a wall:

Hint example1.jpg

When a player is at either of the two player_starts, the Source engine, while rendering each frame, must consider whether the brushes (pipes) to the right of the wall should be drawn. That occurs because vbsp.exe did not do what would be the most efficient way of dividing our level into leaves:

Hint example2.jpg

From the leaf the players are in, the leaf the pipes are in can be seen and the pipes are drawn. Quite a shame, because those pipes cannot be seen from the players perspective (they are behind the wall in the center). We can use hints to steer the process of leaf-making, like so:

Hint example3.jpg

The white line is a side of a brush with the tools/toolshint texture. It forces vbsp.exe to divide our map into three leaves. In this case, there can be no straight line drawn from the leaf the players are in to the leaf the pipes are in. That is the essence of hinting.

Skyboxes are sometimes a bit high, causing a player to see a lot of stuff in the city because the leaf he is in can see over the houses. (like in the above example). That also is a good situation where one can use hints to stop the visibility.

Here are more examples:

Hint example5.JPG

Above is top view of a typical corner. There are two players (the green boxes) and the cylinders at each end represent a lot of stuff to be drawn for the engine. The goal with hinting in this case is avoid rendering objects when unnecessary, e.g. when a player is "around" the corner from the objects. One may think vbsp.exe will make sure each player won't see the objects belonging to the other player. This is wrong. It will divide this "level" into two leaves, either cutting the leaves along the brown or pink line (vbsp.exe is not very predictable). Either way, one can see from one leaf to the other and the other player's stuff will be drawn. However, this situation can be greatly improved by simply by placing a hint at the corner, dividing our level into three leaves, (making a total of three instead of two) but making sure one player's stuff doesn't get rendered from the other player's point of view:

Hint example4.jpg

There is no direct line-of-sight between the red and brown leaves so unnecessary rendering is avoided. However, if one of the players moves into the green leaf, he will see both his and the other player's stuff rendered. You cannot stop that using hints. The only way to stop this would be by changing the level layout or by using other methods, like the ones described in Controlling Geometry Visibility and Compile Times

A last few examples:

Hint example6.jpg

Here a few examples of when and how to use Hints. In all cases the goal is to hide the green players from each other. The upper three work as they should. The left one illustrates that it doesn't even matter if its one hint-brush spanning the corner, as long as its angle is > 180° the two players will not "see" each other's leaves because no straight line can be drawn between their leaves. The bottom-left example shows you that can happen when the angle is less than 180°. One can easily draw a straight line from leaf to leaf, resulting in non-functional hints.

When the corner in the hallway is 180°, as in the middle top picture, two hints will suffice. In fact, they can even be closer to the players, but that would decrease their effectiveness (more stuff will be drawn "around the corner". ) In the example in the middle bottom, the hints have been lowered and vbsp.exe is forced to cut up the top visleaf because visleaves can't be concave. No matter how vbsp.exe cuts up this corner, the hints will always work less effectively and create extra leaves (more work for vvis.exe). In the example, the left player can see leaves 1 and 2 (same surfaces as above), but the right player will see all three numbered leaves (which is more than the top example.).

The two right pictures show you you should keep things as simple as possible. If one hint will suffice, like in the top example, that is preferred. And, obviously, hints should not be used if not needed, as in the bottom picture. As shown, vbsp.exe cannot create leaves that enable both players to see each other, so there's no need to use hints here to hide the players from each other (hints can be used, of course, to hide parts of the hallways). In the same example, the middle wall should never be a func_detail. func_details are not taken into consideration by vvis.exe. It will think both players will see each other and that's not what we want. vbsp.exe may even make it so both players here are in the same leaf.

Lastly, hints can be used to simplify a map. Sometimes, vbsp.exe cuts up a level into more leaves than necessary. This increases compile time. hints can be used to counteract this. For instance, hints can be placed in doorways to prevent the doorways from cutting up the rooms they connect. Or, if you get an error that a certain visleaf is cornering too many other visleaves, hints can used to cut that leaf into multiple leaves that corner a smaller amount of leaves.

In summary, since hints cost no extra power during the playing of a map, they are the primary way to speed up your map and control your visibility.

See also

Examples