$envmap
$envmap - это материальный параметр шейдера, доступно для всех игр на движке
Source.
You can help by updating the translation.
Also, please make sure the article complies with the alternate languages guide.
Чаще всего используется для имитации
зеркальных отражений, наблюдаемых на гладких поверхностях, таких как металлы, стекло и пластмассы. Это достигается путём сопоставления нормалей вершин модели с точками изображения карты-куба, заданной параметром $envmap, и добавления результирующего цвета от карты-куба к поверхности модели. Как правило, карта-куб является просто статичной "картой окружения", которая была предварительно отрисована (хотя пользовательская карта-куб может быть анимирована).
Когда в объекте env_cubemap указан параметр $envmap и на карте выполнена команда buildcubemaps, движок автоматически выберет карту окружения, содержащуюся в BSP-файле карты, которая находится ближе всего к модели при её перемещении в мире, обеспечивая очень упрощённую имитацию динамических отражений.
Другим типом имитации зеркального отражения, поддерживаемым Source, является затенение Фонга, которое обеспечивает простые отражения как на статичных, так и на динамичных моделях.
Доступность
$envmap был представлен в
Source в
и
. Также доступен во всех поздних играх.
env_cubemap. Поэтому если вы уже создали карты-кубы, то большинство из этих текстур продолжат использовать статичные изображения отражений, до тех пор пока их .vmt файлы не будут отредактированы.
Синтаксис
$envmap env_cubemap
Обычно используется значение "env_cubemap", которое указывает VBSP подменить имя ближайшего env_cubemap при компиляции карты. Однако можно использовать статичное изображение карты-куба, созданное самостоятельно.
$envmap использован без указания $basetexture, то даже в этом случае зеркальные отражения будут отображены.
env_cubemap, будут использовать ближайшую к игроку карту-куб, а не ближайшую к самой наклейке! Создание собственной текстуры карты-куба
В некоторых случаях может потребоваться создание собственной текстуры карты-куба, которая иногда используется в некоторых моделях Valve.
.hdr.vtf equivalent for an sRGB-encoded SDR .vtf cubemap, or encode the SDR cubemap in regular RGB.
В 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
В 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.
Параметры и эффекты
- $envmapmask <texture>
- Смотреть $envmapmask. Текстура, которая по-тексельно определяет яркость зеркального отражения.
- $envmaptint <КЗС матрица>
- Контролирует яркость отражения красного, зелёного и синего канала. Использоваться может любое положительное число. По умолчанию:
"[1 1 1]", что означает 100% яркость.
Важно: На VertexLitGeneric этот параметр конвертируется из гамма в линейное пространство. Вводимые значения преобразуются в X^2.2f. Например, 0.25 равно не 25% отражения, а ~5%!
Примечание: Вы обязаны использовать кавычки, так как внутри значения есть пробелы.
Примечание: Можно указать значение одиночным числом с плавающей запятой. В таком случае это значение будет применено ко всем трём каналам одинаково (Например $envmaptint 0.5 будет равен $envmaptint "[0.5 0.5 0.5]"). Однако, судя по всему, этот метод не является полностью надёжным.[подтвердить]
Совет: Этот параметр часто используется для того, чтобы приглушить яркость зеркального отражения без использования выше описанной $envmapmask.
- $envmapcontrast <норма>
- Контролирует контраст отражения. 0 - натуральный контраст, а 1 возводит цвет в квадратную степень (т.е. цвет*цвет).
Примечание: Не работает при включённом $phong.
Совет: Use higher contrasts to diminish relatively darker areas and increase "hot spots".
- $envmapsaturation <КЗС матрица>
- Контролирует цветовую насыщенность отражения. 0 - серые тона, а 1 - натуральный цвет. Красный, Зелёный и Синий цвета можно изменять используя
"[к з с]"соответственно.
Примечание: In the Shadercode for
Source 2013 and
Alien Swarm 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.
Примечание: Не работает при включённом на моделях $phong.
Баг:
Работает только на моделях. [нужно проверить в ?]
- $envmapframe <целое число>
- Указывает стартовый кадр анимированной карты-куба.
- $envmapmode <целое число>
- Depreciated MATERIAL_VAR_ENVMAPMODE = (1 << 25), // OBSOLETE
- $basetexturenoenvmap and $basetexture2noenvmap <булева переменная> (DX9 SM2) (удалено начиная с
)
- Shader(s): WorldVertexTransition
- Used for materials with two albedos, to make one or the other matte. See also $basetexture and $basetexture2.
Примечание: Superseded in
by $envmapmask2.
- $envmapoptional <варианты выбора> (удалено начиная с
)
- Указывает нижнюю версию DirectX, при которой будут отображать отражения. Выбирается из вариантов:
80(DirectX 8)81(DirectX 8.1)90(DirectX 9)95(DirectX 9 с Shader Model 3)
- $envmapsphere <булева переменная>
(также в
) (удалено начиная с
)
- Determines whether the material's envmap should be a spheremap (using matcap shading like
"chrome" textures) instead of a cubemap. Set this to 1 to use a spheremap.
- $noenvmapmip <булева переменная> (только в
)
- Shader(s): LightmappedGeneric
- Only use the top-level mipmap of the cubemap.
- $fresnelreflection <число с плавающей запятой> (Во всех играх начиная с
)
- Shader(s): LightmappedGeneric, Lightmapped_4WayBlend, WorldVertexTransition
- Добавляет эффект Френеля отражению. 0 - нет эффекта, а 1 - накладывает полный эффект, схож с
Water. Эффект умножается при значениях выше 1.
Баг:Значения инвертированы в
, 0 - накладывает полный эффект, а 1 - нет эффекта. [нужно проверить в ?]
- $envmapfresnel <число с плавающей запятой> (DX9 SM2) (Во всех играх начиная с
)
- Shader(s): VertexLitGeneric
- Тоже самое что и
$fresnelreflection, но дляVertexLitGeneric. По умолчанию будет использовать диапазон установленный$phongfresnelranges.
Примечание: Работает только если сначала был включён $phong
.
- $envmapfresnelminmaxexp <вектор данных> (Во всех играх начиная с
)
- Shader(s): VertexLitGeneric
- Устанавливает диапазон френеля для материалов, использующих
$envmapfresnelбез фонга. По умолчанию:"[0 1 2]".
Примечание: Значения френеля для этого параметра отличаются от $phongfresnelranges. Первое значение - минимальное количество френеля, второе значение - максимальное количество френеля, а третье значение - экспонента.
- $envmaplightscale <число с плавающей запятой> (Во всех играх начиная с
) (также в
)
- Shader(s): LightmappedGeneric, Lightmapped_4WayBlend
, VertexLitGeneric
, WorldVertexTransition
- Tint the surface's specular reflection with its lightmap. This matches a surface's reflection with its diffuse lighting and acts as rudimentary reflection occlusion. With a value of 1, a surface will have no reflection if it isn't lit at all. For models in
, vertex lighting is used for the tinting instead of a lightmap.
Примечание: Values above 1 for this parameter are technically permitted, but start inverting the effect.
- $envmaplightscaleminmax <вектор данных2> (только в
) (также в
)
- Shader(s): LightmappedGeneric, Lightmapped_4WayBlend, VertexLitGeneric, WorldVertexTransition
- Thresholds for the lightmap reflection tinting effect. Setting the minimum value higher increases the minimum light amount at which the reflection gets nerfed to nothing.
- $envmapanisotropy <булева переменная> (только в
)
- Shader(s): LightmappedGeneric, Lightmapped_4WayBlend, WorldVertexTransition
- Enables anisotropic reflection emulation by warping the reflection downwards.
For this it uses the alpha channel of the $bumpmap.
It linearly interpolates between a normal reflection vector and an anisotropic one.
This means that values of 0 in the alpha will result in normal reflections, and a value of 1 will result in anisotropic reflections.
Баг:Does not work with $normalmapalphaenvmapmask [нужно проверить в ?]
Баг:Does not work with $basealphaenvmapmask except Lightmapped_4WayBlend [нужно проверить в ?]
Примечание: Requires a $bumpmap to be present.
- $envmapanisotropyscale <норма> (только в
)
- Shader(s): LightmappedGeneric, Lightmapped_4WayBlend, WorldVertexTransition
- Multiplier for how much the reflection should be warped.
Команды управления
| Cvar/Command | Parameters or default value | Descriptor | Effect |
|---|---|---|---|
| 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).
buildcubemaps.
|
||
| mat_envmaptgasize | 32 | int | Устанавливает разрешение для файлов созданных с помощью envmap. |
| mat_fastspecular | 0 disables, 1 enables | 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.
|
|
| mat_specular | 1 | 0 disables, 1 enables | Отключает или включает зеркальные отражения, выгружает или загружает зеркальные материалы из памяти. |
| r_showenvcubemap | bool | Команда для отображения всех карт-кубов на всех динамических объектах в полную яркость. Использована для создания изображения в начале статьи. |
Смотреть также
- $envmapmask (маска зеркального отражения)
- $phong (для рассеянного отражения)
- Карта-куб (cubemap)
