Ru/$envmap: Difference between revisions
m (Nesciuse moved page $envmap/ru to Ru/$envmap over redirect: Language prefixes) |
m (-Using L template for links) |
||
Line 1: | Line 1: | ||
{{langsp}}{{Update translation}} | {{langsp}}{{Update translation}} | ||
[[File:Specular.jpg|thumb|Specular reflections at full intensity.]] | [[File:Specular.jpg|thumb|Specular reflections at full intensity.]] | ||
It most commonly used to approximate the [[wikipedia:specular reflection|specular reflections]] seen on smooth surfaces, such as metals and plastics. This is achieved by mapping the | It most commonly used to approximate the [[wikipedia:specular reflection|specular reflections]] seen on smooth surfaces, such as metals and plastics. This is achieved by mapping the {{L|Normal|vertex normals}} of a {{L|3D Model|model}} to positions on a cubemap - specified by <code>$envmap</code> - and adding the sampled color from the cubemap to the model's surface. Typically, the cubemap is a simple, static "environment map" which has been pre-rendered (although a custom cubemap can be animated). | ||
When <code>$envmap</code> is set to <code>{{ent|env_cubemap}}</code> and {{ent|buildcubemaps}} has been run on the map, the engine will automatically select the environment map contained in the | When <code>$envmap</code> is set to <code>{{ent|env_cubemap}}</code> and {{ent|buildcubemaps}} has been run on the map, the engine will automatically select the environment map contained in the {{L|BSP}} which is nearest to the model as it moves through the world, providing a ''very'' rough approximation of dynamic reflections. | ||
The other form of specularity supported by Source is the | The other form of specularity supported by Source is the {{L|$phong|Phong}} type, which provides simpler reflections on both static '''and''' dynamic models. | ||
== Availability == | == Availability == | ||
Line 17: | Line 17: | ||
</pre> | </pre> | ||
"env_cubemap" is typically used, which tells | "env_cubemap" is typically used, which tells {{L|VBSP}} to swap in the name of the nearest <code>env_cubemap</code> when the map compiles. However, it is also possible to use a static cubemap image that has been manually created. | ||
{{note|If <code>$envmap</code> is used without specifying {{ent|$basetexture}}, the specular reflections will be force drawn regardless of anything.}} | {{note|If <code>$envmap</code> is used without specifying {{ent|$basetexture}}, the specular reflections will be force drawn regardless of anything.}} | ||
Line 27: | Line 27: | ||
Creating a custom cubemap texture might be required for some circumstances and is used occasionally in some Valve models. | Creating a custom cubemap texture might be required for some circumstances and is used occasionally in some Valve models. | ||
{{bug| Cubemaps flagged as sRGB will only properly load as sRGB when | {{bug| Cubemaps flagged as sRGB will only properly load as sRGB when {{L|HDR}} is disabled. Either include an HDR {{code|.hdr.vtf}} equivalent for an sRGB-encoded SDR {{code|.vtf}} cubemap, or encode the SDR cubemap in regular RGB. | ||
{{modernConfirm|What games can actually load SDR cubemaps in HDR mode? {{css}} handles such fine (printing warnings about missing a proper HDR cubemap in the console), but {{dods}} seems not be able to load SDR cubemaps in HDR mode (regardless of sRGB-ness), resulting in the surface glowing white.}}}} | {{modernConfirm|What games can actually load SDR cubemaps in HDR mode? {{css}} handles such fine (printing warnings about missing a proper HDR cubemap in the console), but {{dods}} seems not be able to load SDR cubemaps in HDR mode (regardless of sRGB-ness), resulting in the surface glowing white.}}}} | ||
=== In | === In {{L|VTFEdit}}=== | ||
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. | 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. | ||
Line 37: | Line 37: | ||
To the right hand side of this page you will find two guide images to aid in properly rotating each side of your environment render.<br> | To the right hand side of this page you will find two guide images to aid in properly rotating each side of your environment render.<br> | ||
Save one or both of those guides on your computer and then import your environment render onto it or recreate it in a smaller scale, then rotate your sides as instructed by the images.<br> | Save one or both of those guides on your computer and then import your environment render onto it or recreate it in a smaller scale, then rotate your sides as instructed by the images.<br> | ||
Save every side as a separate image file, their names should be the number found on that specific square. This will ensure that the environment texture will be built correctly, as the numbers also represent the import order in | Save every side as a separate image file, their names should be the number found on that specific square. This will ensure that the environment texture will be built correctly, as the numbers also represent the import order in {{L|VTFEdit}}. | ||
[[File:Cubemap T assembly guide.png|thumb|Orientation guide for T-assembled environments. Click to enlarge]] | [[File:Cubemap T assembly guide.png|thumb|Orientation guide for T-assembled environments. Click to enlarge]] | ||
Line 76: | Line 76: | ||
<span id="$envmapmask"></span> | <span id="$envmapmask"></span> | ||
{{MatParam|$envmapmask|texture|See {{ent|$envmapmask}}. A texture file that determines per- | {{MatParam|$envmapmask|texture|See {{ent|$envmapmask}}. A texture file that determines per-{{L|texel}} reflection intensity.}} | ||
<span id="$envmaptint"></span> | <span id="$envmaptint"></span> | ||
{{MatParam|$envmaptint|RGB matrix|Controls the intensity of the reflection's | {{MatParam|$envmaptint|RGB matrix|Controls the intensity of the reflection's {{L|RGB|red, green and blue}} color channels. Any positive number can be used. Default is <code>"[1 1 1]"</code>, which means 100% intensity. | ||
{{important| '''On {{ent|VertexLitGeneric}} this parameter is being converted from gamma to linear'''. The input will turn into {{code|X^2.2f}}. For Example, 0.25 is not 25% reflectivity, it's actually ~5%! }} | {{important| '''On {{ent|VertexLitGeneric}} this parameter is being converted from gamma to linear'''. The input will turn into {{code|X^2.2f}}. For Example, 0.25 is not 25% reflectivity, it's actually ~5%! }} | ||
{{note|You ''must'' use quotemarks, as there are space characters within the value.}} | {{note|You ''must'' use quotemarks, as there are space characters within the value.}} | ||
Line 90: | Line 90: | ||
{{MatParam|$envmapsaturation|RGB matrix|Controls the color saturation of the reflection. 0 is greyscale, while 1 is natural saturation. R, G and B can be de/oversaturated respectively using <code>"[r g b]"</code> | {{MatParam|$envmapsaturation|RGB matrix|Controls the color saturation of the reflection. 0 is greyscale, while 1 is natural saturation. R, G and B can be de/oversaturated respectively using <code>"[r g b]"</code> | ||
: {{note|In the Shadercode for {{src13|2}} and {{as|2}} the parameter is defined as a float parameter. However it will be used as a vec3 and the Shader expects and uses it as such.}} | : {{note|In the Shadercode for {{src13|2}} and {{as|2}} the parameter is defined as a float parameter. However it will be used as a vec3 and the Shader expects and uses it as such.}} | ||
: {{note|Will not work when | : {{note|Will not work when {{L|Phong}} is enabled on models.}} | ||
: {{bug|{{css}} Works only on models.{{modernConfirm|Does this bug exist in other {{src13mp}} games using stock shaders? (ex: {{hl2dm}} {{hldms}} {{dods}} {{tf2}}) }} }} }} | : {{bug|{{css}} Works only on models.{{modernConfirm|Does this bug exist in other {{src13mp}} games using stock shaders? (ex: {{hl2dm}} {{hldms}} {{dods}} {{tf2}}) }} }} }} | ||
<span id="$envmapframe"></span> | <span id="$envmapframe"></span> | ||
Line 97: | Line 97: | ||
{{MatParam|$envmapmode|int|Depreciated MATERIAL_VAR_ENVMAPMODE {{=}} (1 << 25), // OBSOLETE|deprecated=1}} | {{MatParam|$envmapmode|int|Depreciated MATERIAL_VAR_ENVMAPMODE {{=}} (1 << 25), // OBSOLETE|deprecated=1}} | ||
<span id="$basetexturenoenvmap"></span> | <span id="$basetexturenoenvmap"></span> | ||
{{MatParam|$basetexturenoenvmap|and=$basetexture2noenvmap|bool|Used for materials with two | {{MatParam|$basetexturenoenvmap|and=$basetexture2noenvmap|bool|Used for materials with two {{L|albedo}}s, to make one or the other matte. See also {{ent|$basetexture}} and {{ent|$basetexture2}}. | ||
:{{note|Superseded in {{csgo}} by <code>[[$envmapmask#CS:GO_WorldVertexTransition_Parameters|$envmapmask2]].</code>}}|dx9=1|shaders=WorldVertexTransition|removed={{csgo}}}} | :{{note|Superseded in {{csgo}} by <code>[[$envmapmask#CS:GO_WorldVertexTransition_Parameters|$envmapmask2]].</code>}}|dx9=1|shaders=WorldVertexTransition|removed={{csgo}}}} | ||
<span id="$envmapoptional"></span> | <span id="$envmapoptional"></span> | ||
{{MatParam|$envmapoptional|choices|Sets the oldest | {{MatParam|$envmapoptional|choices|Sets the oldest {{L|DirectX Versions|DirectX version}} that should draw the reflection. Choose from: | ||
:*<code>80</code> (DirectX 8) | :*<code>80</code> (DirectX 8) | ||
:*<code>81</code> (DirectX 8.1) | :*<code>81</code> (DirectX 8.1) | ||
Line 106: | Line 106: | ||
:*<code>95</code> (DirectX 9 with Shader Model 3)|removed={{l4d}}}} | :*<code>95</code> (DirectX 9 with Shader Model 3)|removed={{l4d}}}} | ||
<span id="$envmapsphere"></span> | <span id="$envmapsphere"></span> | ||
{{MatParam|$envmapsphere|bool|Determines whether the material's envmap should be a spheremap (using matcap shading like {{gldsrc}} | {{MatParam|$envmapsphere|bool|Determines whether the material's envmap should be a spheremap (using matcap shading like {{gldsrc}} {{L|MDL (GoldSrc)|"chrome"}} textures) instead of a cubemap. Set this to 1 to use a spheremap. | ||
: {{bug|In | : {{bug|In {{L|DirectX Versions|DirectX 9}} mode, this will instead act like a regular cubemap with all 6 faces being identical.}}|deprecated=1|removed={{as}}|also={{gmod}}}} | ||
<span id="$noenvmapmip"></span> | <span id="$noenvmapmip"></span> | ||
{{MatParam|$noenvmapmip|bool|Only use the top-level mipmap of the cubemap.|only={{csgo}}|shaders=LightmappedGeneric}} | {{MatParam|$noenvmapmip|bool|Only use the top-level mipmap of the cubemap.|only={{csgo}}|shaders=LightmappedGeneric}} | ||
[[File:Reflection tinting example.png|thumb|200px|A vent without and with reflection tinting. The bottom image lists the material parameters used to create the effect.]] | [[File:Reflection tinting example.png|thumb|200px|A vent without and with reflection tinting. The bottom image lists the material parameters used to create the effect.]] | ||
<span id="$fresnelreflection"></span> | <span id="$fresnelreflection"></span> | ||
{{MatParam|$fresnelreflection|float|Adds a [http://www.3drender.com/glossary/fresneleffect.htm Fresnel effect] to the reflection. 0 is none, while 1 applies the full effect, similar to <code> | {{MatParam|$fresnelreflection|float|Adds a [http://www.3drender.com/glossary/fresneleffect.htm Fresnel effect] to the reflection. 0 is none, while 1 applies the full effect, similar to <code>{{L|Water_(shader)|Water}}</code>. The effect becomes multiplied with values higher than 1. | ||
{{bug|Value behaves inverted in {{bms}}, 0 applies the full effect, while 1 is none.}}|since={{src06}}|shaders=LightmappedGeneric, Lightmapped_4WayBlend, WorldVertexTransition}} | {{bug|Value behaves inverted in {{bms}}, 0 applies the full effect, while 1 is none.}}|since={{src06}}|shaders=LightmappedGeneric, Lightmapped_4WayBlend, WorldVertexTransition}} | ||
<span id="$envmapfresnel"></span> | <span id="$envmapfresnel"></span> | ||
Line 121: | Line 121: | ||
<span id="$envmapfresnelminmaxexp"></span> | <span id="$envmapfresnelminmaxexp"></span> | ||
{{MatParam|$envmapfresnelminmaxexp|vector|Sets fresnel ranges for <code>VertexLitGeneric</code> materials using <code>$envmapfresnel</code> without phong. By default <code>"[0 1 2]"</code>, making surfaces facing the viewer less reflective than surfaces facing sideways. | {{MatParam|$envmapfresnelminmaxexp|vector|Sets fresnel ranges for <code>VertexLitGeneric</code> materials using <code>$envmapfresnel</code> without phong. By default <code>"[0 1 2]"</code>, making surfaces facing the viewer less reflective than surfaces facing sideways. | ||
: {{Note|The fresnel values for this parameter are '''not''' the same as those for <code> | : {{Note|The fresnel values for this parameter are '''not''' the same as those for <code>{{L|$phong|$phongfresnelranges.}}</code>Instead, the first value is the minimum amount of fresnel, the second value is the maximum, and the final value is exponent.}} | ||
: {{bug|Cannot be used with {{ent|$bumpmap}}. <code>$phongfresnelranges</code> must be used instead.}}|since={{l4d}}|shaders=VertexLitGeneric}} | : {{bug|Cannot be used with {{ent|$bumpmap}}. <code>$phongfresnelranges</code> must be used instead.}}|since={{l4d}}|shaders=VertexLitGeneric}} | ||
<span id="$envmaplightscale"></span> | <span id="$envmaplightscale"></span> | ||
Line 137: | Line 137: | ||
== Console commands == | == Console commands == | ||
{{IO| | {{IO|{{L|buildcubemaps}}|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.}} | ||
{{IO|envmap|Generates an environment map at the player's position and dumps it in cubemap_screenshots/, in six separate PFM files (or, if running without HDR, TGA files). | {{IO|envmap|Generates an environment map at the player's position and dumps it in cubemap_screenshots/, in six separate PFM files (or, if running without HDR, TGA files). | ||
: {{tip|Cubemaps created this way will capture dynamic entities and models in them, which are normally hidden when using <code>buildcubemaps</code>.}}}} | : {{tip|Cubemaps created this way will capture dynamic entities and models in them, which are normally hidden when using <code>buildcubemaps</code>.}}}} | ||
Line 149: | Line 149: | ||
== See also == | == See also == | ||
* | * {{L|$envmapmask}} (specular mask) | ||
* | * {{L|$phong}} (for diffuse reflection) | ||
* | * {{L|Cubemap}} |
Revision as of 08:46, 11 July 2024

You can help by updating the translation.
Also, please make sure the article complies with the alternate languages guide.
It most commonly used to approximate the specular reflections seen on smooth surfaces, such as metals and plastics. This is achieved by mapping the vertex normals of a model to positions on a cubemap - specified by $envmap
- and adding the sampled color from the cubemap to the model's surface. Typically, the cubemap is a simple, static "environment map" which has been pre-rendered (although a custom cubemap can be animated).
When $envmap
is set to env_cubemap
and buildcubemaps has been run on the map, the engine will automatically select the environment map contained in the BSP which is nearest to the model as it moves through the world, providing a very rough approximation of dynamic reflections.
The other form of specularity supported by Source is the Phong type, which provides simpler reflections on both static and dynamic models.
Availability
$envmap
was introduced in Source with
and
. It is available in all subsequent games.


$envmap
if it uses an env_cubemap
, but the buildcubemaps command does not work properly. If the cubemaps are built in another game and then the BSP is added into HL:S, they will work fine. Is not clear if in older versions there were more issues; but, due such problems, Valve used static reflective images for every reflective texture in the game. [нужно проверить в ?]Syntax
$envmap env_cubemap
"env_cubemap" is typically used, which 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.

$envmap
is used without specifying $basetexture, the specular reflections will be force drawn regardless of anything.

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.




In VTFEdit
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.


$envmapsphere
parameter. VTFEdit can generate this face automatically, via the "Advanced" tab when importing.To the right hand side of this page you will find two guide images to aid in properly rotating each side of your environment render.
Save one or both of those guides on your computer and then import your environment render onto it or recreate it in a smaller scale, then rotate your sides as instructed by the images.
Save every side as a separate image file, their names should be the number found on that specific square. This will ensure that the environment texture will be built correctly, as the numbers also represent the import order in VTFEdit .
Once you have all the image sides ready you can just import them all into VTFEdit and select "Environment Map". Texture format is up to you, generally DXT1 will do.
Enable the "Clamp S" and "Clamp T" texture flags.
Then just save it all as a .vtf file and use it in your VMT like so:
"$Envmap" "effects/my_cubemap"
"effects" is the usual folder for environments/cubemaps You may put yours anywhere you like
In VTEX
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, but to make them work properly with Vtex.exe you must use HDRShop (but before you need to change textures format to BMP, because HDRShop can only work with that kind of format) and then covert them to PFM files format.
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 // read .pfm file instead of .tga
pfmscale 1 // higher values will result in a brighter sky
nocompress 1 // disable compression (HDR compression is only supported by skyboxes)
Put these files into materialsrc and then just drag-n-drop .txt file into vtex.exe 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.
Parameters and Effects
$envmapmask
$envmaptint
$envmapcontrast
$envmapsaturation
$envmapframe
$envmapmode
$basetexturenoenvmap
$envmapoptional
$envmapsphere
$noenvmapmip
$fresnelreflection
$envmapfresnel
$envmapfresnelminmaxexp
$envmaplightscale
$envmaplightscaleminmax
$envmapanisotropy
$envmapanisotropyscale
Console commands
- buildcubemaps
- 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.
- envmap
- Generates an environment map at the player's position and dumps it in cubemap_screenshots/, in six separate PFM files (or, if running without HDR, TGA files).
Совет:Cubemaps created this way will capture dynamic entities and models in them, which are normally hidden when using
buildcubemaps
.
- mat_envmaptgasize <целое число >
- Sets the resolution for the files created with
envmap
. Default value: 32
- mat_fastspecular <булева переменная >
- Quickly disable or enable specular rendering without reloading materials. This does not affect performance, only appearance.
mat_specular
must be used for proper performance testing. Баг:Doesn't work in some games. [нужно проверить в ?]
Примечание:Despite common misconception, setting this to 0 does not enable a "fancy specular" mode, it simply disables specular rendering entirely.
- mat_specular <булева переменная >
- Disable or enable specular reflections, unloading or loading the specular materials from memory. Default 1.
- r_showenvcubemap <булева переменная >
- 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
- $envmapmask (specular mask)
- $phong (for diffuse reflection)
- Cubemap