This article's documentation is for anything that uses the Source engine. Click here for more information.

$detail: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (→‎Parameters and Effects: Added CS:GO to the list of games in which `$detailtint` is broken.)
($detailblendmode - What Game, which Shader, what Mode works? Thank me later)
Line 19: Line 19:
:There are 12 different detail blend methods that can be used.
:There are 12 different detail blend methods that can be used.
:The blend modes are implemented in <code>stdshaders/common_ps_fx.h</code>.
:The blend modes are implemented in <code>stdshaders/common_ps_fx.h</code>.
{{Note|Modes 1, 2, 3, 4, 5, 6, and 8 are not supported in {{csgo}} for LightmappedGeneric.}}  
{{Important|Below is listed, what blendmodes, work in which games, on what shaders. Using a non-supported Blendmode can/will result in "Missing Shader Combo" errors flooding the Console. The Material will not Render!}}
:{{TODO|Which other shaders does this apply to?}}
In {{csgo}} {{ent|LightmappedGeneric}} Modes 1-6 and 8 are not supported. 9 not with {{ent|$bumpmap}}, {{ent|$envmap}}, {{ent|$selfillum}}.
{{Note|Modes 1, 4, 6, 9, and 10 cause shader combo flags errors in {{l4d2}}.}}
 
In {{csgo}} {{ent|WorldVertexTransition}} Modes 1-6, 8-9 are not supported. 7 Does not work with {{ent|$blendmodulatetexture}}.
 
In {{csgo}} {{ent|VertexLitGeneric}} Modes 0-9 are supported '''without''' {{ent|$bumpmap}}, 0-7 '''with'''. However only with {{ent|$phong}}, 5 & 6 usable. The Shader without {{ent|$phong}} doesn't have the code to use 5 & 6.
 
In {{csgo}} {{ent|Lightmapped_4WayBlend}} Modes 1-6 are not supported.
 
In {{src13}} {{tf2}} {{ent|LightmappedGeneric}} Modes 2-9 are not supported.
 
In {{src13}} {{tf2}} {{as}}{{ent|VertexLitGeneric}} Modes 0-9 are supported '''without''' {{ent|$bumpmap}}, 0-6 '''with'''. However only with {{ent|$phong}}, 5 & 6 usable. The Shader without {{ent|$phong}} doesn't have the code to use 5 & 6.
 
In {{as}}{{ent|LightmappedGeneric}} and {{ent|WorldVertexTransition}} Mode 6 is not supported. Additionally 7 does not work with {{ent|$bumpmap2}}, {{ent|$softedges}} and {{ent|$blendmodulatetexture}}.
 
In {{l4d2}} Modes 1, 4, 6, 9, and 10 cause "Missing Shader Combo" errors, and are thus not supported.


[[Image:Detail_blend_modes_l4d2.jpg||320px|thumb|right|Blend modes in L4D2, factor .8 (Left to right modes 0 to 11, base texture only and detail only. Top row detail opacity 100%, bottom 50%).]]
[[Image:Detail_blend_modes_l4d2.jpg||320px|thumb|right|Blend modes in L4D2, factor .8 (Left to right modes 0 to 11, base texture only and detail only. Top row detail opacity 100%, bottom 50%).]]
Line 41: Line 54:
:Only the red and alpha channels of the detail texture are used. This operates like the {{ent|DecalModulate}} shader or blend mode 0, but the base alpha channel fades between using the red (0) or alpha (255) detail channel as the modulation source. This effectively allows two detail materials, although both are greyscale.
:Only the red and alpha channels of the detail texture are used. This operates like the {{ent|DecalModulate}} shader or blend mode 0, but the base alpha channel fades between using the red (0) or alpha (255) detail channel as the modulation source. This effectively allows two detail materials, although both are greyscale.
*8 {{=}} Multiply
*8 {{=}} Multiply
:The color of the base channel is multiplied by that of the detail texture.{{bug|Not compatible with {{ent|$phong}} due to missing shader combinations.}}
:The color of the base channel is multiplied by that of the detail texture.
*9 {{=}} Base Mask via Detail Alpha
*9 {{=}} Base Mask via Detail Alpha
:Only the detail alpha channel is used. It is multiplied with the base texture's alpha channel to produce the final alpha value.
:Only the detail alpha channel is used. It is multiplied with the base texture's alpha channel to produce the final alpha value.

Revision as of 03:51, 15 February 2023

English (en)Français (fr)中文 (zh)Translate (Translate)
A detail texture (noise_detail_01), and its effect when applied to a material (left).

Template:Shaderparam It specifies a texture which Source will use to add high-resolution detail to a material when it is viewed up close, by darkening or lightening the albedo appropriately, depending on the $detailblendmode. You can also use a full color (as opposed to grayscale) image and blend it using $detailblendmode 2. It is very effective for increasing the apparent resolution of a texture, and was used extensively in Half-Life 2: Episode Two Half-Life 2: Episode Two.

Icon-Bug.pngBug:Detail textures do not currently work in conjunction with $seamless_scale. Enabling them to work together would require a programmer to edit the used shader.  [todo tested in ?]
Icon-Bug.pngBug:Detail textures are not compatible with $blendmodulatetexture except in Counter-Strike: Global Offensive.  [todo tested in ?]

Syntax

$detail <texture>

You will probably want to use at least $detailscale (see below) as well.

Parameters and Effects

$detailtexturetransform

Icon-Bug.pngBug:Does not currently function at all in Counter-Strike: Global Offensive.  [todo tested in ?]

$detailscale $detailblendfactor $detailblendmode $detailtint $detailframe $detail_alpha_mask_base_texture

Counter-Strike: Global Offensive WorldVertexTransition Parameters

Confirm:are these limited to Counter-Strike: Global Offensive, or are they in some/all CS:GO engine branch–branch games?

$detail2 $detailscale2 $detailblendfactor2 $detailframe2 $detailtint2

Valve's Detail Textures

Valve's stock detail textures (available in OB only) are best used with the following pre-configured values:

$detail detail\noise_detail_01 // e.g. for brickwork, concrete...
$detailscale 7.74
$detailblendfactor 0.8
$detailblendmode 0
$detail detail\metal_detail_01
$detailscale 4.283
$detailblendfactor .65
$detailblendmode 0
$detail detail\rock_detail_01
$detailscale 11
$detailblendfactor 1
$detailblendmode 0
$detail detail\plaster_detail_01
$detailscale 6.783
$detailblendfactor .8
$detailblendmode 0

The below parameters come from models\props_forest\LadderWood.vmt. It is the only Valve Stock texture VMT file to use this particular detail texture. Because the detail texture (detail\wood_detail_01) is a high resolution (1024×1024), the $detailscale is lower than the others, with the exception of rock_detail_01.

$detail detail\wood_detail_01
$detailscale 2.563
$detailblendfactor .8
$detailblendmode 0

Additionally, there are 2 other stock detail textures. detail\detailash001a and detail\detaildirt001a. These files were used in the "leaked" version of Half-Life 2 Half-Life 2 and in Half-Life 2: Episode One Half-Life 2: Episode One using the following parameters.

Concrete/concretefloor009a in Episode One materials:

$detail detail/detaildirt001a
$detailscale 0.27

Metal/metalfloor005a in Episode One materials:

$detail detail/detailash001a
$detailscale 0.50

See Also

Hiding large-scale tiling with detail textures - How to make texture repeating less noticeable using $detail