Difference between revisions of "$detail"

From Valve Developer Community
Jump to: navigation, search
m (Parameters and Effects)
 
(21 intermediate revisions by 9 users not shown)
Line 4: Line 4:
 
[[Image:Detail.jpg|frame|right|A detail texture (noise_detail_01), and its effect when applied to a material (left).]]
 
[[Image:Detail.jpg|frame|right|A detail texture (noise_detail_01), and its effect when applied to a material (left).]]
  
The '''<code>$envmap</code>''' [[VMT]] parameter specifies a [[texture]] with which Source will add high-resolution detail when the material 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 <code>$detailblendmode 2</code>. It is very effective for increasing the apparent resolution of a texture, and was used extensively in [[Episode Two]]. The effect exists in all Source Engine based games.
+
{{shaderparam|$detail}} 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 <code>$detailblendmode</code>. You can also use a full color (as opposed to grayscale) image and blend it using <code>$detailblendmode 2</code>. It is very effective for increasing the apparent resolution of a texture, and was used extensively in [[Episode Two]].
  
 
{{bug|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.}}
 
{{bug|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.}}
 +
{{bug|Detail textures are not compatible with [[$blendmodulatetexture]]}}
  
 
== Syntax ==
 
== Syntax ==
Line 16: Line 17:
 
== Parameters and Effects ==
 
== Parameters and Effects ==
  
=== <code>$detailtexturetransform <matrix></code> ===
+
{{MatParam|$detailtexturetransform|matrix|Rotates, scales, etc. the detail texture. {{VMT UVtransform}}|dx9=1}}
 +
:{{bug|Does not currently function at all in {{csgo}}.}}
 +
{{MatParam|$detailscale|float|Fits the detail texture onto the material the given number of times (default {{=}} 4). Generally used instead of <code>$detailtexturetransform</code> with a value of around 7 or 8 for a 128px detail texture. To independently scale the X and Y coordinates, place your values in brackets: <code>$detailscale "[ 4 8 ]"</code> }}
 +
{{MatParam|$detailblendfactor|normal|Controls the amount that the detail texture affects the base texture. The precise use of this depends on the blend factor; in most cases it acts similarly to [[$alpha]]. A value of 0 usually makes the detail texture have no effect, whilst a value of 1 applies the full effect.}}
 +
{{MatParam|$detailblendmode|int|How to combine the detail material with the albedo.
 +
:There are 12 different detail blend methods that can be used.
 +
: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}}.}}
 +
: {{Note|Modes 1, 4, 6, 9, and 10 cause shader combo flags errors in {{l4d2}}.}}
  
: Rotates, scales, etc. the detail texture. Requires DX9. {{VMT UVtransform}}
+
[[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%).]]
;
 
=== <code>$detailscale <[[float]]></code> ===
 
  
: Fits the detail texture onto the material the given number of times (default = 4). Generally used instead of <code>$detailtexturetransform</code> with a value of around 7 or 8 for a 128px detail texture.
+
;*0 {{=}} DecalModulate
;
 
=== <code>$detailblendfactor <[[normal]]></code> ===
 
 
 
: Controls the amount that the detail texture affects the base texture. The precise use of this depends on the blend factor; in most cases it acts similarly to [[$alpha]]. A value of 0 usually makes the detail texture have no effect, whilst a value of 1 applies the full effect.
 
 
 
===  <code>$detailblendmode <[[int]]></code> ===
 
 
 
: How to combine the detail material with the albedo.
 
 
 
There are 12 different detail blend methods that can be used.
 
The blend modes are implemented in <code>stdshaders/common_ps_fx.h</code>.
 
 
 
;*0 = DecalModulate
 
 
: This functions the same as the [[DecalModulate]] shader - colors below 128 darken the image, colors above lighten the image.
 
: This functions the same as the [[DecalModulate]] shader - colors below 128 darken the image, colors above lighten the image.
;*1 = Additive
+
;*1 {{=}} Additive
 
: The color of the detail texture is added to the base texture. This is the same as [[$additive]].
 
: The color of the detail texture is added to the base texture. This is the same as [[$additive]].
 
+
;*2 {{=}} Translucent Detail
;*2 = Translucent Detail
 
 
: The detail texture is applied as a translucent overlay on top of the base texture.
 
: The detail texture is applied as a translucent overlay on top of the base texture.
 
+
;*3 {{=}} Blend Factor Fade
;*3 = Blend Factor Fade
+
: The detail texture is applied as a translucent overlay, but ignoring its alpha channel. Instead the blend factor is used to determine how much of the base texture shows through underneath.
: The detail texture is applied as a transulcent overlay, but ignoring its alpha channel. Instead the blend factor is used to determine how much of the base texture shows through underneath.
+
;*4 {{=}} Translucent Base
;*4 = Translucent Base
 
 
: This effectively flips the normal layering of the two textures. The detail texture appears "below", with the base alpha channel controlling it as a translucent overlay. The detail alpha channel controls the overall material alpha - for translucency, masking or other uses.
 
: This effectively flips the normal layering of the two textures. The detail texture appears "below", with the base alpha channel controlling it as a translucent overlay. The detail alpha channel controls the overall material alpha - for translucency, masking or other uses.
;*5 = Unlit Additive
+
;*5 {{=}} Unlit Additive
 
: The color of the detail texture is added to the base texture identically to mode 1, but this color is unaffected by lighting and therefore appears to glow.
 
: The color of the detail texture is added to the base texture identically to mode 1, but this color is unaffected by lighting and therefore appears to glow.
;*6 = Unlit Additive Threshold Fade
+
;*6 {{=}} Unlit Additive Threshold Fade
: This adds color unnaffected by lighting like mode 5, but first modifies the colour added in two modes, depending on if the blend factor is above or below 0.5. {{todo|Screenshots of how this appears.}}
+
: This adds color unnaffected by lighting like mode 5, but first modifies the colour added in two modes, depending on if the blend factor is above or below 0.5.
;*7 = Two-Pattern DecalModulate
+
;*7 {{=}} Two-Pattern DecalModulate
 
: Only the red and alpha channels of the detail texture are used. This operates like the [[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 [[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.
 
: The color of the base channel is multiplied by that of the detail texture.
::{{bug|Not compatible with [[$phong]] due to missing shader combinations.}}
+
:{{bug|Not compatible with [[$phong]] due to missing shader combinations.}}
;*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 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.
;*10 = Self-Shadowed Bumpmap
+
;*10 {{=}} Self-Shadowed Bumpmap
 
: The detail texture is used as a (possibly additional) [[$ssbump]] bumpmap. The blend factor is ignored.
 
: The detail texture is used as a (possibly additional) [[$ssbump]] bumpmap. The blend factor is ignored.
;*11 = SSBump Albedo
+
: {{Note|You can use this to get a standard bumpmap and a self-shadowing bumpmap on the same material. However, this is expensive and should be used very sparingly.}}
 +
;*11 {{=}} SSBump Albedo
 
: Unknown function, used internally. The comment says, "shader does the magic here - no user needs to specify mode 11".
 
: Unknown function, used internally. The comment says, "shader does the magic here - no user needs to specify mode 11".
 
;*12+
 
;*12+
: Any other values will disable the detail effect.
+
: Any other values will disable the detail effect.}}
 +
{{MatParam|$detailtint|RGB matrix|Color tint of the detail texture.
 +
:{{bug|Does not work with [[$blendtintbybasealpha]].}}
 +
::{{todo|Verify which games this is broken in (tested in L4D2, TF2 and Portal 2).}}}}
 +
{{MatParam|$detailframe|int|The frame to start an animated <code>$detail</code> texture on.|dx9=1}}
 +
{{MatParam|$detail_alpha_mask_base_texture|bool|{{ent|WorldVertexTransition}} only. When enabled, causes the level of detail alpha to determine "base texture blending". {{todo|''Which'' base texture? Is this actually fully implemented?}}|removed={{csgo}}}}
  
=== <code>$detailtint "<[[RGB]] matrix>"</code> ===
+
===CS:GO WorldVertexTransition Parameters===
 
+
{{MatParam|$detail2|texture|Detail texture for {{ent|WorldVertexTransition}}'s second layer.
: Modifies the colour of the detail texture.
+
:{{note|{{ent|LightmappedGeneric}} technically has support for these parameters and other <code>WorldVertexTransition</code> parameters, but they may not work as expected.}}|only={{csgo}}|shaders=WorldVertexTransition}}
::{{bug|Doesn't work.}}
+
{{MatParam|$detailscale2|float|Detail scale for <code>$detail2</code>.|only={{csgo}}|shaders=WorldVertexTransition}}
;
+
{{MatParam|$detailblendfactor2|normal|Detail blend factor for <code>$detail2</code>.|only={{csgo}}|shaders=WorldVertexTransition}}
=== <code>$detailframe <int></code> ===
+
{{MatParam|$detailframe2|int|The frame to start an animated <code>$detail2</code> texture on.|only={{csgo}}|shaders=WorldVertexTransition}}
 
+
{{MatParam|$detailtint2|RGB matrix|Color tint for <code>$detail2</code>.|only={{csgo}}|shaders=WorldVertexTransition}}
: The frame to start animated detail texture on. Requires DX9.
 
;
 
=== <code>$detail_alpha_mask_base_texture <[[bool]]></code> ===
 
 
 
: <code>[[WorldVertexTransition]]</code> only. When enabled, causes the level of detail alpha to determine "base texture blending". {{todo|''Which'' base texture? Is this actually fully implemented?}}
 
  
 
== Valve's detail textures ==
 
== Valve's detail textures ==
Line 126: Line 119:
  
 
[[Category:List of Shader Parameters|D]]
 
[[Category:List of Shader Parameters|D]]
 +
 +
== See Also ==
 +
[https://web.archive.org/web/20191215081655/https://blog.maxofs2d.net/post/83154062767/hiding-large-scale-tiling-with-detail-textures Hiding large-scale tiling with detail textures] - How to make texture repeating less noticeable using $detail

Latest revision as of 06:58, 24 September 2020

Français
A detail texture (noise_detail_01), and its effect when applied to a material (left).

$detail is a material shader parameter available in all Source games. 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 Episode Two.

Bug: 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.
Bug: Detail textures are not compatible with $blendmodulatetexture

Syntax

$detail <texture>

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

Parameters and Effects

$detailtexturetransform <matrix>  (DX9+)
Rotates, scales, etc. the detail texture.
The default position is "center .5 .5 scale 1 1 rotate 0 translate 0 0".
  1. center defines the point of rotation. Only useful if rotate is being used.
  2. scale fits the texture into the material the given number of times. '2 1' is a 50% scale in the X axis.
  3. rotate rotates the texture counter-clockwise in degrees. Accepts any number, including negatives.
  4. translate shifts the texture by the given numbers. '.5' will shift it half-way.
Note:All values must be included!
Bug: Scaling the texture may cause odd issues where the Texture Lock tool in Hammer will not actually lock the texture in place.
Bug: Rotating textures applied on brushes will rotate around the map origin (confirm: Orangebox engine only?). A fix for this is to change the center position in the VMT to the brush's origin.
Bug: Does not currently function at all in <Counter-Strike: Global Offensive>.
$detailscale <float>
Fits the detail texture onto the material the given number of times (default = 4). Generally used instead of $detailtexturetransform with a value of around 7 or 8 for a 128px detail texture. To independently scale the X and Y coordinates, place your values in brackets: $detailscale "[ 4 8 ]"
$detailblendfactor <normal>
Controls the amount that the detail texture affects the base texture. The precise use of this depends on the blend factor; in most cases it acts similarly to $alpha. A value of 0 usually makes the detail texture have no effect, whilst a value of 1 applies the full effect.
$detailblendmode <integer>
How to combine the detail material with the albedo.
There are 12 different detail blend methods that can be used.
The blend modes are implemented in stdshaders/common_ps_fx.h.
Note:Modes 1, 2, 3, 4, 5, 6, and 8 are not supported in <Counter-Strike: Global Offensive>.
Note:Modes 1, 4, 6, 9, and 10 cause shader combo flags errors in <Left 4 Dead 2>.
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%).
  • 0 = DecalModulate
This functions the same as the DecalModulate shader - colors below 128 darken the image, colors above lighten the image.
  • 1 = Additive
The color of the detail texture is added to the base texture. This is the same as $additive.
  • 2 = Translucent Detail
The detail texture is applied as a translucent overlay on top of the base texture.
  • 3 = Blend Factor Fade
The detail texture is applied as a translucent overlay, but ignoring its alpha channel. Instead the blend factor is used to determine how much of the base texture shows through underneath.
  • 4 = Translucent Base
This effectively flips the normal layering of the two textures. The detail texture appears "below", with the base alpha channel controlling it as a translucent overlay. The detail alpha channel controls the overall material alpha - for translucency, masking or other uses.
  • 5 = Unlit Additive
The color of the detail texture is added to the base texture identically to mode 1, but this color is unaffected by lighting and therefore appears to glow.
  • 6 = Unlit Additive Threshold Fade
This adds color unnaffected by lighting like mode 5, but first modifies the colour added in two modes, depending on if the blend factor is above or below 0.5.
  • 7 = Two-Pattern DecalModulate
Only the red and alpha channels of the detail texture are used. This operates like the 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
The color of the base channel is multiplied by that of the detail texture.
Bug: Not compatible with $phong due to missing shader combinations.
  • 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.
  • 10 = Self-Shadowed Bumpmap
The detail texture is used as a (possibly additional) $ssbump bumpmap. The blend factor is ignored.
Note:You can use this to get a standard bumpmap and a self-shadowing bumpmap on the same material. However, this is expensive and should be used very sparingly.
  • 11 = SSBump Albedo
Unknown function, used internally. The comment says, "shader does the magic here - no user needs to specify mode 11".
  • 12+
Any other values will disable the detail effect.
$detailtint <RGB matrix>
Color tint of the detail texture.
Bug: Does not work with $blendtintbybasealpha.
To do: Verify which games this is broken in (tested in L4D2, TF2 and Portal 2).
$detailframe <integer>  (DX9+)
The frame to start an animated $detail texture on.
$detail_alpha_mask_base_texture <boolean>  (removed in <Counter-Strike: Global Offensive>)
WorldVertexTransition only. When enabled, causes the level of detail alpha to determine "base texture blending". To do: Which base texture? Is this actually fully implemented?

CS:GO WorldVertexTransition Parameters

$detail2 <texture> (only in <Counter-Strike: Global Offensive>)
Detail texture for WorldVertexTransition's second layer.
Note:LightmappedGeneric technically has support for these parameters and other WorldVertexTransition parameters, but they may not work as expected.
Shaders: WorldVertexTransition
$detailscale2 <float> (only in <Counter-Strike: Global Offensive>)
Detail scale for $detail2.
Shaders: WorldVertexTransition
$detailblendfactor2 <normal> (only in <Counter-Strike: Global Offensive>)
Detail blend factor for $detail2.
Shaders: WorldVertexTransition
$detailframe2 <integer> (only in <Counter-Strike: Global Offensive>)
The frame to start an animated $detail2 texture on.
Shaders: WorldVertexTransition
$detailtint2 <RGB matrix> (only in <Counter-Strike: Global Offensive>)
Color tint for $detail2.
Shaders: WorldVertexTransition

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 (1024x1024), 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 & in 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