Hint brush: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (typo correction)
(badly moved multipage)
 
(60 intermediate revisions by 30 users not shown)
Line 1: Line 1:
[[Category:Level Design]]
{{LanguageBar}}
{{back|Tool textures#hint|Tool Textures}}
 
[[File:Toolshint.gif|left|link=]]
Hint planes are used to split [[visleaves]] during compile time and, as such, are a way of optimizing the results of the [[Vvis|Vis]] map compile stage.
 
They are commonly referred to as hint [[brush]]es 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 <code>tools/[[tool textures#hint|toolshint]]</code> 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 <code>tools/[[tool textures#skip|toolsskip]]</code> texture; these faces will be ignored by the compiler.
 
Hints are automatically tied to their own [[VisGroup#VisGroups|auto visgroup]], so you can easily hide them.
 
== Why and when to split visleaves ==
{{note|Learning how [[visleaves]] work may aid the understanding of this article.}}
 
Sometimes, certain leaf shapes are preferred over others simply because that shape makes those leaves see fewer other leaves. Whenever a leaf is not seen, the contents of the leaf is not drawn, speeding up rendering.


HINTs are planes used to split [[visleafs]]. Here's how hinting works. First, you create a brush, with on all sides the "tools/toolsskip"-texture. (this texture makes those faces to be ignored by the compilers). Now, wherever you want a leaf to be split, create the "tools/toolshint"-texture. The leafs are split EXACTLY where the face with the hint texture is. You don't have to tie the brush to an entity. Be sure to fit hint brushes to walls exactly, or else their effect *may* be lost. It will also make your level tidier.
The following illustrates the importance of visleaf cutting, and, at the same time, provides examples on where hints are useful.
Hints are automatically tied to their own <code>visgroup</code>, so you can easily hide them.


You may take a look at the example map made by valve in: "sourcesdk_content\hl2\mapsrc\sdk_hints.vmf" for more information on how to make these hint-brushes, or look at the akilling.org HINT brush tutorial  [[http://www.akilling.org/akg/tutorials/wiseHINT.asp]].
The first example is almost the same as the [[#Examples|SDK example map]]. This is a side view of a single room with players and pipes separated by a wall:


=Why and when split visleafs?=
[[File:Hint example1.jpg|frame|left|caption|Side view of the sdk_hints.vmf sample map, showing the player starts on the left, and models on the right, separated by a wall.]]{{clr}}
First, before trying to understand this, learn how [[visleafs]] work. (see that link)
Sometimes, certain leaf-shapes are preferred over others simply because that shape makes those leafs see less other leafs. (which means less stuff to be rendered, thus a faster map)


I will try to illustrate the importance of visleaf-cutting, and in the same time give you some examples on where one could use hints.
When a player is at either of the two player_starts the engine must consider whether the brushes (pipes) to the right of the wall should be drawn. That occurs because <code>vbsp.exe</code> did not do what would be the most efficient way of dividing our level into leaves:


Our first example is allmost the same as the example level:
[[File:Hint example2.jpg|frame|left|caption|With no hints, vbsp makes leaves that extend all the way to the ceiling.]]{{clr}}


[[Image:Hint example1.jpg]]
Because the leafs are very tall and go all the way to the ceiling, the leaf on the left (with the players) can directly "see" the leaf on the right with the pipes. So the leaf and the contents (the pipes) will be drawn. Quite a shame, because those pipes cannot be seen from the player's perspective (they are behind the wall in the center). We can use hints to steer the process of leaf-making.


When a player is at either of the two player_starts, he can see the brushes (pipes) to the right of the wall.
[[File:Hint example3.jpg|frame|left|caption|Creating a single horizontal hint creates multiple leaves, and the two leaves on either side of the wall cannot see each other.]]{{clr}}
Why is that? well, it's because <code>vbsp.exe</code> did not do what would be the most efficient way of dividing our level into leafs:


[[Image:Hint example2.jpg]]
The white line is a side of a brush with the <code>tools/toolshint</code> texture. It forces <code>vbsp</code> to divide our map into three leaves. In this case, there can be no longer be a straight line drawn from the leaf the players are in to the leaf the pipes are in. That is the essence of hinting.


See? The leaf the player is in, can see the leaf the pipes are in, and so 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:
[[Skybox]]es are sometimes a bit high, causing a player to see a lot of stuff in the city because the leaf they are 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.


[[Image:Hint example3.jpg]]
== Corner hints ==
[[File:Hint example5.JPG|thumb|200px|right|caption|Without hints, either corner of this hallway will be rendered when standing in the opposite corner.]]


The white line is a side of a brush with the "tools/toolshint"-texture. Notice how it forces <code>vbsp.exe</code> to divide our map into three leafs? And that, in this case, there can be no straight line drawn from the leaf the player is in to the leaf the pipes are in? If you understand that, you understand the essence of hinting.
Here is a 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.


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.
One may think <code>vbsp</code> will make sure each player won't see the objects belonging to the other player. This is wrong. It will divide this space into two leaves, either cutting the leaves along the brown or pink line (depending on which brush face <code>vbsp</code> cuts first).


Let's add some more examples:
Either way, the two corner leaves have a direct line-of-sight to each other, so the contents of each corner will always render when standing in the opposite corner.{{clr}}


[[Image:Hint example5.JPG]]
[[File:Hint example4.jpg|thumb|200px|right|caption|Adding an angled hint brush creates corner leaves that can't see each other.]]


Above we see 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. We do not want this stuff to be rendered when not neccesairy, e.g. when we are "around" the corner.
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.
You may think <code>vbsp.exe</code> will make sure each player wont see the stuff belonging to the other player. This is wrong. The program has no AI, so it isn't smart enough to see what we see. It will divide this "level" into two leafs, either cutting the leafs along the brown or pink line (remember how <code>vbsp.exe</code> is not very predictable?). Either way, the leafs will be able to see each other and the stuff from the other player will be drawn. However, we '''can''' do something about it, simply by placing a '''hint''' at the corner, dividing our level into three leafs, (one more) but making sure the players don't render the stuff from the other players:


[[Image: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, they will see both their own 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]].{{clr}}


See? The red and brown leafs can't see each other, so the players wont have to render each others' stuff. However, if one of the players moves into the green leaf, he will see both his and the other players' 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]]
== More examples ==
[[File:Hint example6.PNG|frame|caption|right|Various ways to use hints.]]


A last few examples I have whipped up in paint.
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.


[[Image:Hint example6.jpg]]
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 <code>vbsp</code> is forced to cut up the top visleaf because visleaves can't be [[concave]]. No matter how <code>vbsp</code> cuts up this corner, the hints will always work less effectively and create extra leaves (more work for <code>vvis</code>). 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.).


We see here a few examples of when, and how to use '''Hints'''. In all cases we try 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 degrees the two players will not render each other, because no straight line can be drawn between their leafs. (think about this one) The bottom-left example shows you that can happen when the angle is less than 180 degrees. One can easily draw a straight line from leaf to leaf, resulting in non-functional hints.
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, <code>vbsp</code> 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|detail brush]]. Details geometry do not create visleaves and are not taken into consideration by <code>vvis</code>. It will think both players will see each other and that's not what we want. <code>vbsp</code> may even make it so both players here are in the same leaf.
When the corner in the hallway is 180 degrees, as in the middle top picture, you can suffice placing two hints like there. In fact, you can even make them closer to the players, but that would increase their effectivity (more stuff will be drawn "around the corner". ) see the example below the middle. Because you lowered the hints, <code>vbsp.exe</code> is forces to cut up the top visleaf because visleafs can't be [[concave]]. No matter how <code>vbsp.exe</code> cuts up this corner, the '''hints''' will always work less effective AND create extra leafs (more work for <code>vvis.exe</code>). In our example, the left player can see leafs 1 and 2 (same surfaces as above), but the right player will see all three numbered leafs (which is more than the top example.).
The two right pictures show you you should keep things as simple as possible. If you can suffice using one '''hint''', like in the top example, do so. And, don't use '''hints''' if you don't need to, like in the bottom picture. there is absolutely no way <code>vbsp.exe</code> can create leafs that enable both players to see each other, so there's no need to use hints here to hide the players from each other (you can offcourse use '''hints''' to hide parts of the hallways). In the same example you can also see a nice wall (the middle one) that should NEVER be a func_detail: because func_details don't exist according to <code>vvis.exe</code>, it will think both players will see each other and thats not what we want. <code>vbsp.exe</code> may even make it so both players here are in the same leaf.


A last example on when to use hints, is for simplifying your map. Sometimes, <code>vbsp.exe</code> cuts up your level into more leafs than neccesairy. This will only add to the compile time, so you don't want this. You can use '''hints''' to counteract this. For instance, place hints in doorways to stop the doorways to cut up the rooms they connect. Or, if you get an error that a certain visleaf is cornering too many other visleafs, you can use hints to cut that leaf into multiple leafs that corner a smaller amount of leafs.
In summary, since hints have no direct rendering cost during the playing of a map, when used wisely they are a '''primary way to speed up your map and control your visibility.'''


In summary, since hints cost no extra power during the playing of your map, the are the '''primary way to speed up your map and controll your visibility.'''
== Hints used to simplify ==
----
Lastly, hints can be used to simplify a map. Sometimes, <code>vbsp</code> 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.
''See also''


[[Controlling Geometry Visibility and Compile Times]]
{{note|Visleaves will always be divided every 1024 units (at each red or blue line in the 2D views)}}


[[Skips]]
== See also ==
* [[Visibility optimization]]
* [[Skip]]
* [[Material_Flags#.25CompileHint.28toolshint.29|%compilehint]], for creating custom hint textures.
* [[Optimization (level design)]]


[[Category:Level_Design]]
== Examples ==
[[Category:Glossary]]
* <code>sourcesdk_content\hl2\mapsrc\sdk_hints.vmf</code> - sample map included in the Source SDK.
[[Category:Level Design]]

Latest revision as of 06:18, 14 July 2024

English (en)Русский (ru)中文 (zh)Translate (Translate)
Tool Textures
Toolshint.gif

Hint planes are used to split visleaves during compile time and, as such, are a way of optimizing 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 auto visgroup, so you can easily hide them.

Why and when to split visleaves

Note.pngNote:Learning how visleaves work may aid the understanding of this article.

Sometimes, certain leaf shapes are preferred over others simply because that shape makes those leaves see fewer other leaves. Whenever a leaf is not seen, the contents of the leaf is not drawn, speeding up rendering.

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:

Side view of the sdk_hints.vmf sample map, showing the player starts on the left, and models on the right, separated by a wall.

When a player is at either of the two player_starts the engine 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:

With no hints, vbsp makes leaves that extend all the way to the ceiling.

Because the leafs are very tall and go all the way to the ceiling, the leaf on the left (with the players) can directly "see" the leaf on the right with the pipes. So the leaf and the contents (the pipes) will be drawn. Quite a shame, because those pipes cannot be seen from the player's perspective (they are behind the wall in the center). We can use hints to steer the process of leaf-making.

Creating a single horizontal hint creates multiple leaves, and the two leaves on either side of the wall cannot see each other.

The white line is a side of a brush with the tools/toolshint texture. It forces vbsp to divide our map into three leaves. In this case, there can be no longer be a 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 they are 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.

Corner hints

Without hints, either corner of this hallway will be rendered when standing in the opposite corner.

Here is a 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 will make sure each player won't see the objects belonging to the other player. This is wrong. It will divide this space into two leaves, either cutting the leaves along the brown or pink line (depending on which brush face vbsp cuts first).

Either way, the two corner leaves have a direct line-of-sight to each other, so the contents of each corner will always render when standing in the opposite corner.

Adding an angled hint brush creates corner leaves that can't see each other.

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.

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, they will see both their own 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.

More examples

Various ways to use hints.

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 is forced to cut up the top visleaf because visleaves can't be concave. No matter how vbsp cuts up this corner, the hints will always work less effectively and create extra leaves (more work for vvis). 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 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 detail brush. Details geometry do not create visleaves and are not taken into consideration by vvis. It will think both players will see each other and that's not what we want. vbsp may even make it so both players here are in the same leaf.

In summary, since hints have no direct rendering cost during the playing of a map, when used wisely they are a primary way to speed up your map and control your visibility.

Hints used to simplify

Lastly, hints can be used to simplify a map. Sometimes, vbsp 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.

Note.pngNote:Visleaves will always be divided every 1024 units (at each red or blue line in the 2D views)

See also

Examples

  • sourcesdk_content\hl2\mapsrc\sdk_hints.vmf - sample map included in the Source SDK.