$alphatest: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (→‎See also: changed all transparency-related articles' see-also's to link oneanother)
mNo edit summary
Line 1: Line 1:
{{Shaderparam|$alphatest}} It specifies a mask to use to determine binary opacity. White represents fully opaque, while black represents fully transparent. Any values in-between are rounded to either 0 or 1. This effect is similar to {{ent|$translucent}}, except that it can not be semi-opaque, is much faster to render, and the engine can sort it properly when layered.
{{lang|$alphatest|title=<code>$alphatest</code>}}
'''<code>$alphatest</code>''' is a [[material]] [[shader]] parameter avaliable in all [[Source]] games. It specifies a mask to use to determine binary opacity. White represents fully opaque, while black represents fully transparent. Any values in-between are rounded to either 0 or 1. This effect is similar to <code>[[$translucent]]</code>, except that it can not be semi-opaque, is much faster to render, and the engine can sort it properly when layered.


==VMT syntax example==
==VMT syntax example==
  $alphatest <[[bool]]>
  $alphatest <[[bool]]>


  [[LightmappedGeneric]]
  [[LightmappedGeneric]]
  {
  {
  [[$basetexture]] glass\window001a
  [[$basetexture]] "glass\window001a"
  '''$alphatest 1'''
        ''' '''
  '''$alphatest 1'''
        '''$alphatestreference .5'''
        '''$allowalphatocoverage 1'''
'''$alphatestreference .5'''
'''$allowalphatocoverage 1'''
  }
  }


==Additional parameters==
==Additional parameters==
{{MatParam|$alphatestreference|float|Specifies the minimum color value of the alpha channel in which the effect is rounded to 255. A value of ".3" will create a thicker shape while a value of ".7" will create a thinner shape.
{{MatParam|$alphatestreference|float|Specifies the minimum color value of the alpha channel in which the effect is rounded to 255. A value of ".3" will create a thicker shape while a value of ".7" will create a thinner shape.
: {{bug|<code>$alphatestreference</code> cannot be updated in real time with [[Material_proxies|proxies]].}}
: {{bug|<code>$alphatestreference</code> cannot be updated in real time with [[Material_proxies|proxies]].}}
Line 22: Line 23:
: {{note|MSAA must be enabled in order for this to have effect.}}}}
: {{note|MSAA must be enabled in order for this to have effect.}}}}


==Comparison with $translucent==
==Comparison with <code>$translucent</code>==


{|class=wikitable
{|class=wikitable
! $translucent||$alphatest
! <code>$translucent</code>||<code>$alphatest</code>
|-
|-
| [[File:Alphatest_preview_original.png|thumb|512px|Original image, rendered with $translucent]] || [[File:Alphatest_preview.gif|thumb|512px|Animated preview of the same image, but with $alphatest. The first image shows the effect of $allowalphatocoverage 1. The rest show alphatest with $alphatestreference ranging from 0.1 to 0.9]]
| <div>[[File:Alphatest_preview_original.png|thumb|50%|center|Original image, rendered with $translucent]] || [[File:Alphatest_preview.gif|thumb|50%|center|Animated preview of the same image, but with $alphatest. The first image shows the effect of $allowalphatocoverage 1. The rest show alphatest with $alphatestreference ranging from 0.1 to 0.9]] </div>
|}
|}
Notice how the right circle hardly changes.
Notice how the right circle hardly changes.


== See also ==
==See also==
 
*<code>[[$alpha]]</code>
*<code>[[$alpha]]</code>, for texture-wide translucency
*<code>[[$distancealpha]]</code>
*<code>[[$distancealpha]]</code>, for vector-like alpha edges
*<code>[[$vertexalpha]]</code>
*<code>[[$vertexalpha]]</code>
*<code>[[$translucent]]</code>, for per-pixel opacity.


[[Category:List of Shader Parameters|T]]
[[Category:List of Shader Parameters]]
[[Category:Glossary]]

Revision as of 23:37, 6 June 2021

English (en)Español (es)Русский (ru)中文 (zh)Translate (Translate)

$alphatest is a material shader parameter avaliable in all Source games. It specifies a mask to use to determine binary opacity. White represents fully opaque, while black represents fully transparent. Any values in-between are rounded to either 0 or 1. This effect is similar to $translucent, except that it can not be semi-opaque, is much faster to render, and the engine can sort it properly when layered.

VMT syntax example

$alphatest <bool>
LightmappedGeneric
{
	$basetexture		"glass\window001a"

	$alphatest		1

	$alphatestreference	.5

	$allowalphatocoverage	1
}

Additional parameters

$alphatestreference $allowalphatocoverage

Comparison with $translucent

$translucent $alphatest
Original image, rendered with $translucent
Animated preview of the same image, but with $alphatest. The first image shows the effect of $allowalphatocoverage 1. The rest show alphatest with $alphatestreference ranging from 0.1 to 0.9

Notice how the right circle hardly changes.

See also