This article's documentation is for anything that uses the Source engine. Click here for more information.

Func occluder: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(No point in having a patch for this.. don't even know what game this was for)
(Simplify/Reformat this page to be similar to other pages.)
Line 1: Line 1:
{{LanguageBar}}[[File:Occlusion example.jpg|350px|thumb|Green boxes represent occluded props, red boxes unoccluded ones.]]
{{LanguageBar}}
{{this is a|semi-internal=1|brush entity|name=func_occluder|sprite=Toolsoccluder.gif}}
{{this is a|semi-internal=1|brush entity|name=func_occluder|sprite=Toolsoccluder.gif}} It hides [[model]]s that are entirely covered by it in the player's view, according to how it has been textured.
{{clr-left}}
{{CD|CFuncOccluder|file1=func_occluder.cpp}}
{{CD|CFuncOccluder|file1=func_occluder.cpp}}
==Entity Description==
[[File:Occlusion example.jpg|thumb|Green boxes represent occluded props, red boxes unoccluded ones.]]
It hides [[model]]s that are entirely covered by it in the player's view, according to how it has been textured. They are used to control visibility in places where {{ent|func_areaportal}}s or [[world brush]]es are unsuitable or not working correctly. Calculations of model visibility in-game is done in real time and is not in the final compile process. Use <code>func_occluder</code>s wisely, because they do calculations in real time and can cost a lot of CPU if there are too many in a map.


Occluders are very useful in cases where you have reasonably large {{ent|func_detail}}, [[Prop Types Overview|prop]], {{ent|func_brush}}, or [[displacement]] walls. These walls do not cut [[visleaves]] and therefore will not stop props from rendering behind these walls. Adding an occluder inside the same wall will at the very least hide all props behind the brush entity walls.
Unlike {{ent|func_areaportal}} or other optimization tools, occluders perform visibility calculations at run-time.  They do not cut [[visleaves]], and they do not hide world geometry (world brushes, displacements, etc).  Because of this, they are much less effective when directly compared to areaportals or good [[Hint brush]] placement for optimization, and should be used primarily when the former strategies are not possible or ineffective on their own.


Usually, all faces of a <code>func_occluder</code> are Nodraw or Skip (as seen in {{csgo|2}} maps), with the occluding faces using the Occluder or Trigger texture.<br>
{{Note|[[VBSP]] may display a warning saying <code>Occluder "" straddles multiple areas. This is invalid!</code>.  This warning is obsolete and will not affect functionality. Removed in {{mapbase}} VBSP.}}
The occlusion will only work if the player is looking at the side that has the occluding texture "visible." If the back side is Nodraw, the occlusion will not take place if looked at from the other side.


{{bug|tested={{tf2}}|Occluders placed inside an [[instance]] will not function once the map is compiled.}}
== Usage ==


== Usage ==
Occluders are very useful in cases where you have reasonably large {{ent|func_detail}}, [[Prop Types Overview|prop]], {{ent|func_brush}}, or [[displacement]] walls. These walls also do not cut [[visleaves]] and therefore will not stop props from rendering behind these walls. Adding an occluder inside the same wall will at the very least hide all props behind the brush entity walls.
{{clr}}
 
{| class=wikitable style="float:right; text-align:center"
They can also be very helpful if your map layout does not allow for efficient visleaf cuts in an area with a lot of visible detail props.  In this situation, you can embed func_occluders in the surrounding geometry to at least reduce the amount of props rendered.  An example of this would be {{l4d|2}}'s <code>c8m1_apartment</code>, where large occluders are used in the survivor starting area and the alley after leaving apartments to hide large amounts of props.
! Texture on a func_occluder !! Effect of that face
[[File:Nomercy.png|thumb|{{l4d}}'s c8m1_apartment using occluders to hide props below the starting area.]]
|-
| [[File:Toolsoccluder.gif|link=tool textures#occluder]] || Occlude
|-
| [[File:Toolsnodraw.gif|link=nodraw]] || Don't Occlude
|}
===Texturing===
This entity works according to how materials has been applied to it:
* All sides covered with the '''[[tool textures#occluder|Occluder]]''' materials will occlude.
* All sides covered with the '''[[Tool textures#nodraw|Nodraw]]''' material will not occlude.


===Occluders and Areaportals===
=== Texturing ===
There are several important differences between occluders and areaportals:


* An occluder only hides props, not world geometery or static brushes.
The occlusion will only work if the player is looking at the side that has the [[tool textures#occluder|Occluder]] [[File:Toolsoccluder.gif|20px|link=tool textures#occluder]] texture applied, any [[Tool textures#nodraw|Nodraw]] [[File:Toolsnodraw.gif|20px|link=nodraw]] faces will not occlude.  This means you could make, for example, a large func_occluder cube, apply nodraw to the entire thing, then apply the occluder texture to only two faces.  Only those two sides will hide models when the player is facing them.
* An occluder does not split [[visleafs|visleaves]].
* An occluder can be free standing and does not need to separate two areas.
{{Note|[[VBSP]] will display a warning saying <code>Occluder "" straddles multiple areas. This is invalid!</code> if the func_occluder is not fully enclosed in world geometry.  This warning can be ignored if you intend to occlude models that may still be visible otherwise, and will not affect functionality. This warning is removed in {{mapbase}} VBSP. }}


===Debugging Commands===
=== Debugging Commands ===
;<code>r_occlusion</code>:Activate/deactivate the occlusion system.
;<code>r_occlusion</code>:Activate/deactivate the occlusion system.
;<code>r_visocclusion</code>:Activate/deactivate wireframe rendering of what the occlusion system is doing.
;<code>r_visocclusion</code>:Activate/deactivate wireframe rendering of what the occlusion system is doing.
Line 43: Line 27:
;<code>r_occludermincount</code>:At least this many occluders will be used, no matter how big they are.
;<code>r_occludermincount</code>:At least this many occluders will be used, no matter how big they are.


==Keyvalues==
== Keyvalues ==
{{KV Targetname}}
{{KV Targetname}}
{{KV|Initial State|intn=StartActive|boolean|If the entity starts inactive, use the <code>Activate</code> or <code>Toggle</code> inputs to turn it on. Default value is 1.
{{KV|Initial State|intn=StartActive|boolean|If the entity starts inactive, use the <code>Activate</code> or <code>Toggle</code> inputs to turn it on. Default value is 1.
Line 50: Line 34:
{{KV|Occluder Number|intn=occludernumber|int|nofgd=1|Automatically inserted by VBSP to distinguish occluders; should not be handled manually.}}
{{KV|Occluder Number|intn=occludernumber|int|nofgd=1|Automatically inserted by VBSP to distinguish occluders; should not be handled manually.}}


==Inputs==
== Inputs ==
{{I|Activate}}
{{I|Activate}}
{{I|Deactivate}}
{{I|Deactivate}}

Revision as of 18:31, 16 September 2025

English (en)Translate (Translate)
Toolsoccluder.gif

func_occluder is a semi-internal brush entity available in all Source Source games. It hides models that are entirely covered by it in the player's view, according to how it has been textured.

C++ Class hierarchy
CFuncOccluder
CBaseEntity
C++ func_occluder.cpp
Green boxes represent occluded props, red boxes unoccluded ones.

Unlike func_areaportal or other optimization tools, occluders perform visibility calculations at run-time. They do not cut visleaves, and they do not hide world geometry (world brushes, displacements, etc). Because of this, they are much less effective when directly compared to areaportals or good Hint brush placement for optimization, and should be used primarily when the former strategies are not possible or ineffective on their own.

Note.pngNote:VBSP may display a warning saying Occluder "" straddles multiple areas. This is invalid!. This warning is obsolete and will not affect functionality. Removed in Mapbase VBSP.

Usage

Occluders are very useful in cases where you have reasonably large func_detail, prop, func_brush, or displacement walls. These walls also do not cut visleaves and therefore will not stop props from rendering behind these walls. Adding an occluder inside the same wall will at the very least hide all props behind the brush entity walls.

They can also be very helpful if your map layout does not allow for efficient visleaf cuts in an area with a lot of visible detail props. In this situation, you can embed func_occluders in the surrounding geometry to at least reduce the amount of props rendered. An example of this would be Left 4 Dead Left 4 Dead's c8m1_apartment, where large occluders are used in the survivor starting area and the alley after leaving apartments to hide large amounts of props.

Left 4 Dead's c8m1_apartment using occluders to hide props below the starting area.

Texturing

The occlusion will only work if the player is looking at the side that has the Occluder Toolsoccluder.gif texture applied, any Nodraw Toolsnodraw.gif faces will not occlude. This means you could make, for example, a large func_occluder cube, apply nodraw to the entire thing, then apply the occluder texture to only two faces. Only those two sides will hide models when the player is facing them.

Debugging Commands

r_occlusion
Activate/deactivate the occlusion system.
r_visocclusion
Activate/deactivate wireframe rendering of what the occlusion system is doing.
r_occludeemaxarea
Prevents occlusion testing for entities that take up more than X% of the screen. 0 means use whatever the level said to use.
r_occluderminarea
Prevents occlusion testing for entities that take up less than X% of the screen. 0 means use whatever the level said to use.
r_occlusionspew
Activate/deactivates spew about what the occlusion system is doing.
r_occludermincount
At least this many occluders will be used, no matter how big they are.

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Initial State (StartActive) <boolean>
If the entity starts inactive, use the Activate or Toggle inputs to turn it on. Default value is 1.
  • 0: Inactive
  • 1: Active
Occluder Number (occludernumber) <integer> !FGD
Automatically inserted by VBSP to distinguish occluders; should not be handled manually.

Inputs

Activate
Deactivate
Toggle
Control the state of the occluder.

External links