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

Func reflective glass: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Unified with func_brush)
(made it easier to understand)
 
(29 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{CD|CFuncReflectiveGlass|file1=func_reflective_glass.cpp}}
[[File:Reflectiveglass0000.jpg|thumb|250px|func_reflective_glass (Note how NPC's and env effects are reflected)]]
[[File:Reflectiveglass0000.jpg|thumb|250px|func_reflective_glass (Note how NPC's and env effects are reflected)]]
 
{{this is a|brush entity|name=func_reflective_glass|since=Source 2007}}
{{base brush|func_reflective_glass}}  


==Entity description==
==Entity description==
It is used to produce perfectly reflective glass that renders world + entities. You must use a [[LightmappedReflective]] texture (glass/reflectiveglass001.vmt is a good start) on one side of the brush, and the rest of the sides either [[Tool textures|nodraw]] or some other opaque texture for this to work properly.
It is used to produce perfectly reflective glass that renders world + entities. You must use a '''[[LightmappedReflective]]''' texture ({{file|glass/reflectiveglass001|vmt}} is a good start) on one side of the brush, and the rest of the sides either [[Tool textures|nodraw]] or some other opaque texture for this to work properly.
 
It is functionally identical to [[Water (shader)|expensive water shaders]], but typically used with opaque, flat materials.
{{note|This entity will not show a player their own reflection, however it will render other players.}}
{{Bug|This entity will cease to render or cause visual artifacts if water and or portals are in a visible visleaf.}}
{{Bug|If more than one face of this brush entity contains a reflective or translucent texture, then the mirror's behavior will suddenly switch depending on one's perspective. To prevent this, make sure ''exactly one'' surface has the reflective texture. All others must be opaque.}}
 
==Keyvalues==
{{KV|Solidity (Solidity)|choices|Used to control the solidity/collision of these brushes.
:*0: Toggle - The solidity can be toggled together with its visibility.
:*1: Never Solid
:*2: Always Solid}}
{{KV|Solid BSP (solidbsp)|bool|Set this to BSP if the player seems to rotate oddly relative to the surface.
:*0: [[VPhysics]]
:*1: BSP ([[QPhysics]])}}
{{KV|NPC class excluded from collisions (excludednpc)|classname|If an NPC classname (i.e. {{ent|npc_zombie}}) is specified here, NPCs of that type won't collide with these brushes.}}
{{KV|Invert NPC class exclusion (invert_exclusion)|bool|If set, then the excluded NPC class will consider this brush solid, and all ''other'' NPC classes will consider it non-solid.}}
{{KV EnableDisable}}
:{{tip|If '''Solidity''' is ''Toggle'', disabling will also make the entity non-solid.}}
{{KV visiblebrush|l4d=1}}
{{KV BaseEntity|brush=1}}
 
==Flags==
*2: Ignore player +USE - Entity will ignore all {{ent|Use}} inputs, including ones from the player.


==Inputs==
{{IO|SetExcluded|Change the NPC class that does not collide with the brush.}}
{{IO|SetInvert|Whether to reverse the NPC class exclusion rule.}}
{{I EnableDisable}}
{{I visiblebrush|portal2=1}}
{{I BaseEntity}}


==Outputs==
{{note|This entity will not show a player their own reflection in first person (except in {{gmod|4}}). It will only show if the client is rendering their own player model (e.g. In third person)}}
{{O BaseEntity|l4d=1}}
{{note|This entity may be constructed from more than one brush, but all [[LightmappedReflective]] faces must be on the same {{w|Plane (geometry)|plane}} to work as intended.}}
{{Bug|1=[[CSM]] shadows do not render on the brush.|since=csgo}}
{{Bug|This entity will always be drawn in front of translucent textures, including particles and sprites.}}
{{Bug|This entity will cease to render or cause visual artifacts if expensive water and/or [[func_areaportal]]s are in a visible visleaf (meaning they can see each other).}}
{{Bug|If more than one face of this brush entity contain a reflective or translucent texture, then the mirror's behavior will suddenly switch depending on one's perspective. To prevent this, make sure ''exactly one'' surface has the reflective texture. All others must be opaque.}}
{{Bug|hidetested=1|In {{portal|4}}, unless <code>r_portal_stencil_depth</code> is set to 0 (which disables portal rendering):
* Having linked portals present near the mirror, or if they are present anywhere within the players' view range (even if they are not being reflected) will cause heavy visual artifacts. The effects are more intense if more portals are reflected and/or more portals are within the players' view range.
* The view through portals renders incorrectly or not at all when viewed through a mirror.
* If a mirror is viewed through a portal, the mirror will still reflect based on the players' absolute position rather than the relative position from the other portal, which causes the mirror to display inaccurately.
* If <code>r_portal_stencil_depth</code> is greater than 2, the game may crash when attempting to look through portals that can see each other and the mirror.
}}
{{Bug|hidetested=1|In {{bms|2}}, [[LightmappedReflective]] doesn't work (shows [[wireframe]] instead of surface with reflection). Despite this, the entity still creates the reflection camera. This means that it still can heavily reduce performance. The [[True reflections under CSS|old (pre-2007) method]] can be used as a workaround, but only for floors.}}
{{Tip|To keep the framerate high, use [[trigger]]s to disable the entity while not needed.}}
{{OtherKIO|func_brush|All}}


== See also ==
== See also ==
*[[LightmappedReflective]], the material shader used for this entity.
*[[LightmappedReflective]], the material shader used for this entity.
* [http://www.youtube.com/watch?v=5NJMh5O-lIQ YouTube tutorial: How to make a mirror]
* {{youtube|5NJMh5O-lIQ|page=watch|YouTube tutorial: How to make a mirror}}
* {{ent|prop_mirror}} {{portal2|only|addtext={{p2ce}}}}: an alternate method of creating an albeit simple real-time reflection

Latest revision as of 13:34, 29 August 2025

C++ Class hierarchy
CFuncReflectiveGlass
CFuncBrush
CBaseEntity
C++ func_reflective_glass.cpp
func_reflective_glass (Note how NPC's and env effects are reflected)

func_reflective_glass is a brush entity available in all Source Source games since Source 2007 Source 2007.

Entity description

It is used to produce perfectly reflective glass that renders world + entities. You must use a LightmappedReflective texture (🖿glass/reflectiveglass001.vmt is a good start) on one side of the brush, and the rest of the sides either nodraw or some other opaque texture for this to work properly. It is functionally identical to expensive water shaders, but typically used with opaque, flat materials.


Note.pngNote:This entity will not show a player their own reflection in first person (except in Garry's Mod Garry's Mod). It will only show if the client is rendering their own player model (e.g. In third person)
Note.pngNote:This entity may be constructed from more than one brush, but all LightmappedReflective faces must be on the same Wikipedia icon plane to work as intended.
Icon-Bug.pngBug:CSM shadows do not render on the brush.  [todo tested in ?]
Icon-Bug.pngBug:This entity will always be drawn in front of translucent textures, including particles and sprites.  [todo tested in ?]
Icon-Bug.pngBug:This entity will cease to render or cause visual artifacts if expensive water and/or func_areaportals are in a visible visleaf (meaning they can see each other).  [todo tested in ?]
Icon-Bug.pngBug:If more than one face of this brush entity contain a reflective or translucent texture, then the mirror's behavior will suddenly switch depending on one's perspective. To prevent this, make sure exactly one surface has the reflective texture. All others must be opaque.  [todo tested in ?]
Icon-Bug.pngBug:In Portal Portal, unless r_portal_stencil_depth is set to 0 (which disables portal rendering):
  • Having linked portals present near the mirror, or if they are present anywhere within the players' view range (even if they are not being reflected) will cause heavy visual artifacts. The effects are more intense if more portals are reflected and/or more portals are within the players' view range.
  • The view through portals renders incorrectly or not at all when viewed through a mirror.
  • If a mirror is viewed through a portal, the mirror will still reflect based on the players' absolute position rather than the relative position from the other portal, which causes the mirror to display inaccurately.
  • If r_portal_stencil_depth is greater than 2, the game may crash when attempting to look through portals that can see each other and the mirror.
Icon-Bug.pngBug:In Black Mesa Black Mesa, LightmappedReflective doesn't work (shows wireframe instead of surface with reflection). Despite this, the entity still creates the reflection camera. This means that it still can heavily reduce performance. The old (pre-2007) method can be used as a workaround, but only for floors.
Tip.pngTip:To keep the framerate high, use triggers to disable the entity while not needed.
Note.pngNote:All Keyvalues / Inputs / Outputs are same as func_brush.

See also