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

LightmappedReflective

From Valve Developer Community
Jump to navigation Jump to search

LightmappedReflective (DX9 SM2) is a pixel shader available in all Source Source games since Source 2007 Source 2007. This shader renders real-time reflection and refractions similar to Water (shader).

func_reflective_glass (using materials with LightmappedReflective shader)
Warning.pngWarning:All parameters listed in the example (except $bumpframe, %tooltexture and $surfaceprop) must be included when used, or func_reflective_glass may not work properly. Counter-Strike: Global Offensive Counter-Strike: Global Offensive additionally requires $translucent.
Icon-Important.pngImportant:This shader must be used on a brush tied to a func_reflective_glass, or the real time reflections will fail to work and it will be rendered as a plain brush.
Icon-Bug.pngBug:In Black Mesa Black Mesa this shader was missed in the deferred renderer update. To achieve the same effect, use 3D Skybox with logic_measure_movement to simulate reflection[Elaborate?] or use the Shader-ball.png Water shader (see True reflections under CSS).
Note.pngNote:Not available in DirectX 8 and earlier, and lacks shader fallbacks.

Example

The example shown here is materials/glass/reflectiveglass001.vmt

"lightmappedreflective"
{
	"%tooltexture" "dev/flat_normal"
	"$refracttexture" "_rt_WaterRefraction"
	"$refractamount" "0"
	"$refracttint" "[.5 .5 .6]"

	"$reflecttexture" "_rt_WaterReflection"
	"$reflectamount" "0"
	"$reflecttint" "[1 1 1]"

	"$fresnelpower" "0"
	"$minreflectivity" "0.8"
	"$maxreflectivity" "1.0"
	
	"$normalmap" "dev/flat_normal"

	"$surfaceprop" "glass"
	"$bumpframe" "0"
}
Icon-Bug.pngBug:Doesn't support 3D skyboxes, instead of your 3D Skybox, the reflection will show a black void.  [todo tested in?]
Icon-Bug.pngBug:Stops correction and reflection itself if you look at reflective water.  [todo tested in?]
Icon-Bug.pngBug:Adding proxies to a lightmappedreflective causes the texture to not be drawn. (Could this be because it includes some default proxy in order for it to work, and once there is a user-defined proxy, those "behind the scenes" proxies are no longer there?)  [todo tested in?]
Icon-Bug.pngBug:If there is a portal in the reflection in Portal 2 Portal 2 and Portal 2 branch games, it will cause the game to crash. Almost works in The Beginner Guide under the same conditions. This is fixed in Portal 2: Community Edition Portal 2: Community Edition  [todo tested in?]
Warning.pngWarning:Although this is functional in Portal Portal, the reflection does not update when viewed through portals and portals will only update in the reflection if both of them are visible to you and to the func_reflective glass. Also, if the portals are rotated differently and viewed through the func_reflective_glass, the portals will display incorrectly. This second bug has carried over into Portal 2 and Portal 2: Community Edition

Shader parameters

Textures

Warning.pngWarning:$bumpmap is NOT supported! $normalmap must be used!
Diffuse texture, optional.
bump map, per-pixel warping of the reflection
Frame to start the animated du/dv map and bump map on, respectively. Somewhat confusingly, $bumpframe affects $normalmap, which should be pointing to a bump map.
Transforms the bump map texture.
The default position is center .5 .5 scale 1 1 rotate 0 translate 0 0.
  1. center defines the point of rotation. Only useful if rotate is being used.
  2. scale fits the texture into the material the given number of times. 2 1 is a 50% scale in the horizontal X axis while the vertical Y axis is still at original scale.
  3. rotate rotates the texture counter-clockwise in degrees. Accepts any number, including negatives.
  4. translate shifts the texture by the given numbers. .5 will shift it half-way. 1 will shift it once completely over, which is the same as not moving it at all.
Note.pngNote:All values must be included!
Icon-Bug.pngBug:Scaling the texture may cause odd issues where the Texture Lock tool in Hammer will not actually lock the texture in place.  [todo tested in?]
Icon-Bug.pngBug:Rotating textures applied on brushes will rotate around the map origin (confirm: Orangebox engine only?). A fix for this is to change the center position in the VMT to the brush's origin.  [todo tested in?]

Reflection

Texture to use for reflection. For real-time reflections, use _rt_WaterReflection.
Amount of warp for the reflection. Higher values produce more warping. Also controls the strenght of the bump map
Color tint for the real-time reflection.
Controls opacity of reflection. Similar to $alpha
Per-pixel opacity of reflection
Todo: What is this?
Todo: What is this? It seems to do as the name suggests, controls the max reflection strength similar to $reflectance

Refraction

Texture to use for refraction. For real-time refractions, use _rt_WaterRefraction.
Amount of warp for the refraction. Higher values produce more warping.
Color of the refraction.
Warning.pngWarning:It is recommended that you set this to white or something close to white so that edge transitions work properly on DX9.

Other

Defines the texture Hammer will display in the material browser.
Controls fresnel effect of reflections.
Will make the surface both reflective and transparent dependent on the angle and distance of view.
Icon-Bug.pngBug: Must be set to "1" in Counter-Strike: Global Offensive, or the entity shifts its origin to [0 0 0].
Note.pngNote:Fixed in Strata Source Strata Source
  [todo tested in?]