$specmap texture: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{LanguageBar}}
{{LanguageBar}}
{{cleanup|grammar}} {{This is a|shader parameter|name=$specmap_texture|game=Black Mesa}}  
{{This is a|shader parameter|name=$specmap_texture|game=Black Mesa}}  
[[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, the same for the floodlight.]]  
[[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.]]  
This shader is used for surfaces to give PBR style shiny speculars. Works with {{ent|VertexLitGeneric}} and {{ent|LightmappedGeneric}}. This shader works ''only'' with deferred rendering lighting entities which are using <code>SpecularMultiplier</code> parameter (in the game code or as the property), the 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}}, {{ent|player}} (flashlight).
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.


This shader is mainly used for {{ent|LightmappedGeneric}}, because this is the only option to have gloss effect on world geometry and [[bmodel]]. For {{ent|VertexLitGeneric}} mainly used {{ent|$phong}}, because new lights are also support this shader; this shader works with baked lights and have a lot of parameters, the only exception is {{ent|prop_static}}.
This shader is 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 new specular supports only new lights, while {{ent|$phong}} also supports baked lights and has a lot of parameters, the only exception to this is {{ent|prop_static}}.
{{ModernConfirm|Is this list is full ?}}
{{warning|This shader is pretty expensive for GPU. May not cause FPS drops, but it will heat up your GPU very much. Use wisely.}}


{{note|Doesn't work if [[$phong]] is enabled.}}
{{ModernConfusion|The game does not support the PBR shader itself, only similar glossy effects.}}
{{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]]. Example in this [https://youtu.be/cb6Fw4rVXXo video].}}


{{bug|hidetested=1|If [[$alphatest|alpha tested]] material has a specular, and beneath it, there is also a material with the same shader, and in combination with new lights or a flashlight, this all will cause artifacts appear. This occurred after Crowbar Collective fixed the outline artifacts for alpha tested materials. [https://youtu.be/cb6Fw4rVXXo Example] (use full screen mode to watch).}}
{{note|{{ent|env_cascade_light}} doesn't work with this shader (at least on [[Bmodel|brush models]] and world geometry).}}


{{note|{{ent|env_cascade_light}} doesn't work with this shader (at least on [[Bmodel|bmodels]] and world geometry).}}
{{back | Black Mesa Level Creation}}
{{back | Black Mesa Level Creation}}
==List of entities this shader works with==
* {{ent|NewLight_Point}}, {{ent|NewLight_Spot}} - controlled using <code>SpecularMultiplier</code> keyvalue.
* {{ent|npc_zombie_hev}} - flashlight used by this entity (if enabled).
* {{ent|npc_plantlight}}, {{ent|npc_plantlight_stalker}} - light bulb from plant eye.
* {{ent|player}} - first person flashlight (if enabled). Controlled using {{command|gb_flashlight_SpecMul}}, the default value is 0.8.
* {{ent|env_cascade_light}} - works only with {{ent|VertexLitGeneric}}.
* {{ent|prop_barrel_cactus}} - lighting from this entity.
* {{ent|prop_barrel_cactus_semilarge}} - lighting from this entity.
* {{ent|prop_barrel_interloper}}  - lighting from this entity.
* {{ent|prop_barrel_interloper_small}} - lighting from this entity.
* {{ent|bmortar}} - lighting from this entity.
{{Confirm|Is the entity list is full?}}


== 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>
Line 24: Line 36:
}}
}}
}}
}}
{{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>
Line 34: Line 46:
}}
}}
}}
}}
{{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>
Line 44: Line 56:
}}
}}
}}
}}
{{MatParam|$speculargloss|float|Defines gloss scale. Works differently depending on <code>$specmap_mode</code> value.
{{MatParamDef|$speculargloss|float|Defines glossiness. Works differently depending on <code>$specmap_mode</code> value.
{{expand|title=Examples of $specmap_mode - 0.|
{{expand|title=Examples of $specmap_mode - 0.|
<br>
<br>
Line 70: Line 82:
}}
}}
}}
}}
{{MatParam|$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}}.
{{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 newlight specular.}}
}}
{{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.}}
}}
}}


Line 88: Line 102:
}
}
</nowiki>}}
</nowiki>}}
{{todo|Check to see if parameters such as {{code|$envmapmask}} or {{code|$basealphaenvmapmask}} and others affect new specular lights.}}


== See also ==
== See also ==

Latest revision as of 09:15, 4 November 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.

This shader is 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 new specular supports only new lights, while $phong also supports baked lights and has a lot of parameters, the only exception to this is prop_static.

Warning.pngRisk of Confusion:The game does not support the PBR shader itself, only similar glossy effects.
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. Example in this video.
Note.pngNote:env_cascade_light doesn't work with this shader (at least on brush models and world geometry).
Black Mesa Level Creation

List of entities this shader works with

Confirm:Is the entity list is full?

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.
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 ]" }
Todo: Check to see if parameters such as $envmapmask or $basealphaenvmapmask and others affect new specular lights.

See also