$specmap texture: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
 
(41 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{langsp}}
{{LanguageBar}}
[[File:NewSpecular.png| thumb | right | 720px |New specular shader, example in <code>bs_c3m0d</code>. You can see how the floor reflects the red light source, the same for the floodlight.]]
{{This is a|shader parameter|name=$specmap_texture|game=Black Mesa}}  
{{Shaderparam|New Specular|e0|game=Black Mesa}} This shader using for surfaces to give PBR style shiny speculars. For models this shader enables with [[phong]] shader automatically, for world geometry you're need to add some specific parameters to make it working. This shader work ''only'' with deferred rendering lighting entities which support and use <code>SpecularMultiplier</code> parametr (in the game code or as kayvalue), the entities is: [[NewLight_Point]], [[NewLight_Spot]], [[npc_zombie_hev]], [[prop_barrel_cactus]], [[prop_barrel_cactus_semilarge]], [[prop_barrel_interloper]], [[prop_barrel_interloper_small]], [[env_cascade_light]].
[[File:NewSpecular=.jpg|thumb|right|New specular shader, example in <code>bs_c3m0d</code>. You can see how the floor reflects the red light source, same with the floodlight.]]  
{{ModernConfirm|Is this full list of entities ?}}
Shader used on surfaces to give them PBR style speculars. Works with {{ent|VertexLitGeneric}} and {{ent|LightmappedGeneric}}. This shader ''only'' works with deferred rendering lighting entities, which are using the <code>SpecularMultiplier</code> parameter. Those entities are: {{ent|NewLight_Point}}, {{ent|NewLight_Spot}}, {{ent|npc_zombie_hev}} (flashlight), {{ent|prop_barrel_cactus}}, {{ent|prop_barrel_cactus_semilarge}}, {{ent|prop_barrel_interloper}}, {{ent|prop_barrel_interloper_small}}, {{ent|env_cascade_light}}, {{ent|bmortar}}, {{ent|npc_plantlight}}, {{ent|npc_plantlight_stalker}}, and {{ent|player}} (flashlight).
{{warning| This is pretty expensive shader for video cards, in large quantities may not cause optimization problems, but it will heat up your video card very much. Use wisely.}}
 
Mainly used with {{ent|LightmappedGeneric}}, because it is the only option for glossy effects on world geometry and [[bmodel | brush models]]. {{ent|VertexLitGeneric}} is mainly used with {{ent|$phong}} instead, because {{ent|$phong}} supports new lights, while this shader only supports baked lights and has a lot of parameters. The only exception to this is {{ent|prop_static}}.
{{Confirm|Is this list full?}}
{{warning|This shader is pretty expensive for the GPU. Not necessarily FPS drops, but it will heat up your GPU. Use wisely.}}
 
{{note|Doesn't work if [[$phong]] is enabled.}}
 
{{bug|hidetested=1|If a material with [[$alphatest]] applied has a specular, and beneath it, there is another material with the same shader, will cause artifacts under a light source. This bug started occurring after Crowbar Collective fixed the outline artifacts for materials with [[$alphatest]].}}
 
{{note|{{ent|env_cascade_light}} doesn't work with this shader (at least on [[Bmodel|brush models]] and world geometry).}}
{{back | Black Mesa Level Creation}}
{{back | Black Mesa Level Creation}}


== Parameters and Effects ==
== Parameters and Effects ==
{{MatParam|$specmap_texture|texture|Defines a [[specularmap]] texture that will use specular.
{{MatParamDef|$specmap_texture|texture|Defines a [[specularmap]] texture for the shader.
{{expand|title=An example.|
{{expand|title=An example.|
<br>
<br>
<gallery mode=packed heights=710px>
<gallery mode=packed heights=410px>
File:bs_fy_basement_floor01_spec.png |An example of [[specularmap]] from {{bmsbs|4}}.
File:Bs_fy_basement_floor01_spec=.jpg|An example of [[specularmap]] from {{bmsbs|4}}.
</gallery>
</gallery>
}}
}}
}}
}}
{{MatParam|$specularcolor|RGB matrix|Controls the color and saturation of the specularity. If all three values are the same - the color obtained from deferred rendering light source will be used.
{{MatParamDef|$specularcolor|RGB matrix|Controls the color and saturation of the specularity. If all three values are the same, the color obtained from deferred rendering light source will be used instead. Also affects specular intensity.
{{expand|title=Examples.|
{{expand|title=Examples.|
<br>
<br>
<gallery mode=packed heights=410px>
<gallery mode=packed heights=290px>
File:1 1 1.png |$specularcolor - 1 1 1.
File:1 1 1=.jpg|$specularcolor - 1 1 1.
File:1 0 0.png |$specularcolor - 1 0 0.
File:1 0 0=.jpg|$specularcolor - 1 0 0.
File:1 0 1.png |$specularcolor - 1 0 1.
File:1 0 1=.jpg|$specularcolor - 1 0 1.
</gallery>
</gallery>
}}
}}
}}
}}
{{MatParam|$specmap_mode|int|Defines style and behaviour for speculars, there are 3 available values - 0, 1 and 2.
{{MatParamDef|$specmap_mode|int|Defines style and behaviour for speculars. Only 3 applicable values: 0, 1, and 2.
{{expand|title=Examples.|
{{expand|title=Examples.|
<br>
<br>
<gallery mode=packed heights=410px>
<gallery mode=packed heights=290px>
File:mode 0.png |$specmap_mode - 0.
File:mode 0=.jpg|$specmap_mode - 0. Seems to ignore $specmap_texture.
File:mode 1.png |$specmap_mode - 1.
File:mode 1=.jpg|$specmap_mode - 1. Seems to use $specmap_texture as glossiness map.
File:mode 2.png |$specmap_mode - 2.
File:mode 2=.jpg|$specmap_mode - 2. Seems to use $specmap_texture as tint map.
</gallery>
}}
}}
{{MatParamDef|$speculargloss|float|Defines glossiness. Works differently depending on <code>$specmap_mode</code> value.
{{expand|title=Examples of $specmap_mode - 0.|
<br>
<gallery mode=packed heights=290px>
File:mode 0 10=.jpg|$specmap_mode - 0. $speculargloss - 10
File:mode 0 100=.jpg|$specmap_mode - 0. $speculargloss - 100
File:mode 0 500=.jpg|$specmap_mode - 0. $speculargloss - 500
</gallery>
</gallery>
}}
}}
{{expand|title=Examples of $specmap_mode - 1.|
<br>
<gallery mode=packed heights=290px>
File:mode 1 10=.jpg|$specmap_mode - 1. $speculargloss - 10
File:mode 1 100=.jpg|$specmap_mode - 1. $speculargloss - 100
File:mode 1 500=.jpg|$specmap_mode - 1. $speculargloss - 500
</gallery>
}}
}}
{{MatParam|$speculargloss|float|Defines gloss scale. Works differently depending on <code>$specmap_mode</code> value.
{{expand|title=Examples of $specmap_mode - 2.|
{{expand|title=Examples.|
<br>
<br>
<gallery mode=packed heights=610px>
<gallery mode=packed heights=290px>
File:mode 0 10.png |$specmap_mode - 0. $speculargloss - 10
File:mode 2 10=.jpg|$specmap_mode - 2. $speculargloss - 10
File:mode 0 100.png |$specmap_mode - 0. $speculargloss - 100
File:Mode_2=.jpg|$specmap_mode - 2. $speculargloss - 100
File:mode 0 500.png |$specmap_mode - 0. $speculargloss - 500
File:mode 2 500=.jpg|$specmap_mode - 2. $speculargloss - 500
 
File:mode 1 10.png |$specmap_mode - 1. $speculargloss - 10
File:mode 1 100.png |$specmap_mode - 1. $speculargloss - 100
File:mode 1 500.png |$specmap_mode - 1. $speculargloss - 500
 
File:mode 2 10.png |$specmap_mode - 2. $speculargloss - 10
File:Mode_2.png |$specmap_mode - 2. $speculargloss - 100
File:mode 2 500.png |$specmap_mode - 2. $speculargloss - 500
</gallery>
</gallery>
}}
}}
}}
{{MatParamDef|$normalmapalphaenvmapmask|bool|Use the alpha channel of the {{code|$bumpmap}} or {{code|$normalmap}} as a specular mask. {{code|$specmap_texture}} will be used as an additional mask or glossiness mask if {{code|$specmap_mode}} is set. This allows a blendable specular mask on {{code|LightmappedGeneric}}.
{{todo|Check to see if parameters such as {{code|$envmapmask}} or {{code|$basealphaenvmapmask}} and others affect new specular lights.}}
}}
{{MatParamDef|$fresnelreflection|float|If an [[$envmap]] is also defined, adds a fresnel effect to specularity. Operates the same as it does on [[$envmap]]. 0 is full effect, 1 is no fresnel.
{{tip|Use a value of ~0.8 for metal, ~0.1 for everything else to adhere to PBR.}}
}}
}}


==Issues==
Example VMT:
====World geometry doesn't work with [[env_cascade_light]]====
Unlike models - speculars doesn't work with [[env_cascade_light]] for world geometry.
<gallery mode=packed heights=510px>
File: WGDWECL.png | frame | An example.
</gallery>


====Fullbright glitch with <code>$specmap_mode</code>====
{{CodeBlock|<nowiki>"VertexlitGeneric"
If values are used in $specmap_mode that were not thought out for use - surface will get fullbright and you'll get message in the console:
{
{{CodeBlock|<nowiki>*************************************************
"$basetexture" "models/props_hc/t0a0/generic16"
Shader 'shaders\fxc\gbbrush_ps30.vcs' - Couldn't load combo 184025856 of shader (dyn=384)
"$bumpmap" "models/props_hc/t0a0/generic16_normal"
static combos: BASETEXTURE2=0 BUMPMAP=1 BUMPMAP2=0 CUBEMAP=0 ENVMAPMASK=0 BASEALPHAENVMAPMASK=0 SELFILLUM=0 NORMALMAPALPHAENVMAPMASK=0 WARPLIGHTING=0 FANCY_BLENDING=0 SEAMLESS=0 DETAIL_BLEND_MODE=0 MOSS=0 NEW_SPECMAP=0 SHADER_SPECIAL_MODE=0
"$surfaceprop" "Metal"
*************************************************
*************************************************
"$specmap_texture" "models/props_hc/t0a0/generic16_spec"
Shader 'shaders\fxc\gbbrush_gbuffer_ps30.vcs' - Couldn't load combo 48 of shader (dyn=4)
"$specmap_mode" "2"
static combos: ALPHACLIP=0 NEW_SPECMAP=0
"$speculargloss" "800"
*************************************************
"$specularcolor" "[ 1 1 1 ]"
}
</nowiki>}}
</nowiki>}}
<gallery mode=packed heights=510px>
File: HAHAHAHAHAHAHAHAAH.png | frame | An example.
</gallery>


== See also ==
== See also ==
* [[$phong]] (for diffuse reflection)
* {{ent|$moss_enable}} - moss shader.
* {{ent|newLight_Point}}
* {{ent|$pomscale}} - parallax occlusion mapping shader.
* {{ent|newLight_Spot}}
* {{ent|Lightmapped_4WayBlend}} - 4 way blend shader.
* {{ent|NewLights_settings}}
* {{ent|$halflambert_gbuffer_off}} - gbuffer's halflambert option.
* {{ent|env_cascade_light}}
* {{ent|newLight_Dir}} - directional sun light with godrays only.
* {{ent|light_environment}}
* {{ent|NewLights_Spawner}} - spawner of deferred point lights.
* [[Advanced Lighting]]
* {{ent|env_lensflare}} - cinematic dynamic lens flare.
* [[Effect flags]] (dynamic light effects)
* {{ent|newLight_Spot}} - spot deferred light entity.
* [https://chetanjags.wordpress.com/2023/07/18/blackmesa-xenengine-part-4-lighting-shadows/ BlackMesa XenEngine: Part 4 – Lighting & Shadows] (page from Black Mesa developer about new lights)
* {{ent|newLights_settings}} - entity that changes deferred light settings.
* [https://chetanjags.wordpress.com/2023/07/11/blackmesa-xenengine-part2-how-a-frame-is-rendered/ BlackMesa XenEngine: Part2 – How a Frame is Rendered] (page from Black Mesa developer about how a frame rendered, include Godrays.)
* {{ent|godrays_settings}} - entity that changes godrays settings.
* [https://chetanjags.wordpress.com/2022/06/01/blackmesa-xenengine-part1-a-heavily-modified-source-engine/ BlackMesa XenEngine: Part1 – Heavily Modified Source Engine] (page from Black Mesa developer about Black Mesa engine, better known as [[Xenengine]])
* {{ent|env_cascade_light}} - deferred cascade sun light entity.
* [[New Lights Editor]] - in game deferred lights editor.
* [[Effect flags]] - effects flags, some of them are dynamic light effects.
* [https://chetanjags.wordpress.com/2023/07/18/blackmesa-xenengine-part-4-lighting-shadows/ BlackMesa XenEngine: Part 4 – Lighting & Shadows] - page from Chetan (lead programmer for Black Mesa) about new lights.
* [https://chetanjags.wordpress.com/2023/07/11/blackmesa-xenengine-part2-how-a-frame-is-rendered/ BlackMesa XenEngine: Part2 – How a Frame is Rendered] - page from Chetan (lead programmer for Black Mesa) about how a frame is rendered.
* [https://chetanjags.wordpress.com/2022/06/01/blackmesa-xenengine-part1-a-heavily-modified-source-engine/ BlackMesa XenEngine: Part1 – Heavily Modified Source Engine] page from Chetan (lead programmer for Black Mesa) about {{xe|4}}.

Latest revision as of 12:06, 23 August 2025

English (en)Translate (Translate)

$specmap_texture is a material shader parameter available in Black Mesa Black Mesa.

New specular shader, example in bs_c3m0d. You can see how the floor reflects the red light source, same with the floodlight.

Shader used on surfaces to give them PBR style speculars. Works with VertexLitGeneric and LightmappedGeneric. This shader only works with deferred rendering lighting entities, which are using the SpecularMultiplier parameter. Those entities are: NewLight_Point, NewLight_Spot, npc_zombie_hev (flashlight), prop_barrel_cactus, prop_barrel_cactus_semilarge, prop_barrel_interloper, prop_barrel_interloper_small, env_cascade_light, bmortar, npc_plantlight, npc_plantlight_stalker, and player (flashlight).

Mainly used with LightmappedGeneric, because it is the only option for glossy effects on world geometry and brush models. VertexLitGeneric is mainly used with $phong instead, because $phong supports new lights, while this shader only supports baked lights and has a lot of parameters. The only exception to this is prop_static.

Confirm:Is this list full?
Warning.pngWarning:This shader is pretty expensive for the GPU. Not necessarily FPS drops, but it will heat up your GPU. Use wisely.
Note.pngNote:Doesn't work if $phong is enabled.
Icon-Bug.pngBug:If a material with $alphatest applied has a specular, and beneath it, there is another material with the same shader, will cause artifacts under a light source. This bug started occurring after Crowbar Collective fixed the outline artifacts for materials with $alphatest.
Note.pngNote:env_cascade_light doesn't work with this shader (at least on brush models and world geometry).
Black Mesa Level Creation

Parameters and Effects

Defines a specularmap texture for the shader.
An example.


Controls the color and saturation of the specularity. If all three values are the same, the color obtained from deferred rendering light source will be used instead. Also affects specular intensity.
Examples.


Defines style and behaviour for speculars. Only 3 applicable values: 0, 1, and 2.
Examples.


Defines glossiness. Works differently depending on $specmap_mode value.
Examples of $specmap_mode - 0.


Examples of $specmap_mode - 1.


Examples of $specmap_mode - 2.


Use the alpha channel of the $bumpmap or $normalmap as a specular mask. $specmap_texture will be used as an additional mask or glossiness mask if $specmap_mode is set. This allows a blendable specular mask on LightmappedGeneric.
Todo: Check to see if parameters such as $envmapmask or $basealphaenvmapmask and others affect new specular lights.
If an $envmap is also defined, adds a fresnel effect to specularity. Operates the same as it does on $envmap. 0 is full effect, 1 is no fresnel.
Tip.pngTip:Use a value of ~0.8 for metal, ~0.1 for everything else to adhere to PBR.

Example VMT:

"VertexlitGeneric" { "$basetexture" "models/props_hc/t0a0/generic16" "$bumpmap" "models/props_hc/t0a0/generic16_normal" "$surfaceprop" "Metal" "$specmap_texture" "models/props_hc/t0a0/generic16_spec" "$specmap_mode" "2" "$speculargloss" "800" "$specularcolor" "[ 1 1 1 ]" }

See also