From Valve Developer Community
Revision as of 18:43, 10 May 2014 by Kizzycocoa (talk | contribs) (spent a whole day to find this out on a different page, in a vague side-note. fixing that!)
Jump to: navigation, search
Specular reflections.

The $envmap VMT parameter creates specular reflections, which are seen on smooth surfaces. It does this by defining an "environment map" (specifically a cubemap) to draw as a reflection; normally that of the nearest env_cubemap entity. The reflection is not dynamic.

The other form of reflection supported by Source is the diffuse phong type.


$envmap env_cubemap

"env_cubemap" is normally used, as it tells VBSP to swap in the name of the nearest env_cubemap when the map compiles. However it is also possible to use a static cubemap image that has been manually created.

Note.png Note: Cubemap textures will have no reflectivity when used as overlays or decals

Creating a custom static cubemap texture

Creating a custom cubemap texture might be required for some circumstances and is used occasionally in some Valve models.


For this to work you will need to have the 6 sides of the cubemap saved as individual textures in the correct orientation for it to appear correctly in the Source Engine. So some faces might need to be rotated either clockwise or counter clockwise. Each face will need to be mirrored horizontally before orientation.

Here is a map of the orientation required


  • FT=Front
  • BK=Back
  • RT=Right
  • LF-Left
  • UP=UP
  • DN=Down

  • CW = Clockwise
  • CCW = Counter Clockwise

  • 00_00_00 eg. (customcubemap_00_00_00.tga)
  • 00_01_00 eg. (customcubemap_00_01_00.tga)
  • 00_02_00 eg. (customcubemap_00_02_00.tga)


Once you have all the image sides ready you can just import them all into VTFEdit and select "Environmetal Map"


Also making sure the "Generate Sphere Map" is ticked in the Advance tab.

Then just save it all as a .vtf file and use it in your VMT like so

"$Envmap"             "models/cra0kalo/ct_swat/eyeglint_cubemap"    // Reflection environment map static


VTEX will automatically mirror and orient your faces, you need only to provide correctly named textures. Name each file something like envmap001a*.tga, where * is put BK, FT, LF, RT, UP, or DN. If you took a cubemap screenshot in-game, this step will already by done.

To do: What axis does each direction relate to?

Create a text file the same name as your textures (e.g. envmap001a.txt). If building for HDR write in the following, otherwise leave it blank:

pfm 1
pfmscale [normal]
nocompress 1

Run the text file through VTEX, and you should end up with a working cubemap! HDR envmaps will be named like envmap001a.hdr.vtf, and only need to exist to work.

Additional Parameters

$envmapmask <texture>
See $envmapmask. A VTF file that determines per-texel reflection intensity.
$envmaptint "[<red float> <green float> <blue float>]"
Controls the intensity of the reflection's red, green and blue color channels. Any positive number can be used. Default is "[1 1 1]", which means 100% intensity.
Note.png Note: You must use quotemarks, as there are space characters within the value.
Tip.png Tip: This command is often used to dim the brightness of a specular reflection without the overhead of an $envmapmask.
$envmapcontrast <normal>
Controls the contrast of the reflection. 0 is natural contrast, while 1 is the full squaring of the color (i.e. color*color).
Tip.png Tip: Use higher contrasts to diminish relatively darker areas and increase "hot spots".
Note.png Note: Will not work when Phong is enabled.
$envmapsaturation <normal>
Controls the colour saturation of the reflection. 0 is greyscale, while 1 is natural saturation.
Note.png Note: Will not work when Phong is enabled.
$envmapframe <int>
The frame to start an animated cubemap on.
$envmapmode <int?>
Depreciated MATERIAL_VAR_ENVMAPMODE = (1 << 25), // OBSOLETE
$basetexturenoenvmap <bool>
$basetexture2noenvmap <bool>
Probably used for materials with two albedos, to make one or the other matte. Require DirectX 9; see also $basetexture and $basetexture2.
$envmapoptional <choices>
Sets the oldest DirectX version that should draw the reflection. Choose from:
  • 80 (DirectX 8)
  • 81 (DirectX 8.1)
  • 90 (DirectX 9)
  • 95 (DirectX 9 with Shader Model 3)
$envmapsphere <bool>
Determines whether the material's envmap should be a spheremap (deprecated) instead of a cubemap. Set this to 1 to use a spheremap.

Console commands

Generates cubemaps for use in materials. If this isn't run, objects will reflect the skybox (OB) or have an invalid reflection, white in Ep1 and pink checkerboards in MP.
r_showenvcubemap <bool>
Debug command to display cubemaps on all dynamic objects at full intensity. It was used to create the image at the start of this article.

See Also