SurfaceGGX

From Valve Developer Community
Jump to navigation Jump to search
English (en)Translate (Translate)
HLMV preview of SurfaceGGX shader from Day of Infamy Day of Infamy with 3 lights

SurfaceGGX is a Pixel shader available in Day of Infamy Day of Infamy and Insurgency Insurgency. It was first introduced in Day of Infamy and back ported to Insurgency. It supports PBR.

Icon-Bug.pngBug:This shader won't receive light properly from env_projectedtextures like the player's flashlight, instead making the material appear pure black. If the player is allowed to use a flashlight, the best case scenario is to only use this shader on props in lit up areas. This shader applied to weapon view models is safe from this however.  [todo tested in ?]
Note.pngNote: $translucent does not include the blending inherent to other Valve shaders.

Examples

American character skin

SurfaceGGX
{
 	$basetexture models\player\american\american_flesh_01
 	$bumpmap models\player\american\american_flesh_01_normal
 	$phongexponenttexture models\player\american\american_flesh_01_exp
 	$detail vgui/white
 	$detailblendfactor 0
 	$detailscale 2
	$detailnormal models/player/skin_detail_nm
	$detailnormalblendfactor 0.5
	$subsurfacescattering 1
	$roughnessmultiplier 1.1
	$fuzz 1
	$fuzzmultiplier 0.2
	Proxies
	{
		CauseOfDeath
		{
			resultVar	$detail
		}
	}
}

American character clothes

SurfaceGGX
{
	$basetexture models\player\american\american_clothes
	$bumpmap models\player\american\american_clothes_normal
	$phongexponenttexture models\player\american\american_clothes_exp
	$detail vgui/white
	$detailblendfactor 0
	$detailscale 2
	$metal 1
	$roughnessmultiplier 1.15
	$fuzz 1
	$fuzzmultiplier 0.15
	Proxies
	{
		CauseOfDeath
		{
			resultVar	$detail
		}
		PlayerMaterialProxy
		{
		}
	}
}


Supported Parameters

Skin $detailnormal on the German officer in Day of Infamy Day of Infamy
$basetexture <texture>
Diffuse texture.
$bumpmap <texture>
Normal mapping.
Icon-Bug.pngBug:Animated bump maps aren't possible as the shader lacks the $bumpframe parameter.
$color <RGB matrix>
Color tinting.
$detail <texture>
Detail texturing.
$detailnormal <texture>
Bump as Detail texturing.
$detailnormalblendfactor <float>
Blending factor of $detailnormal.
$envmap <texture>
Specular reflections.
$alphatest <boolean>
Alpha testing.
$treeSway <boolean> (in all games since Left 4 Dead) (also in Team Fortress 2MapbaseGarry's ModBlack Mesa)
Vertex manipulation to give the effect of trees swaying in the wind.

Metalness Parameters

$metal <boolean>
Enables use of the green channel of $phongexponenttexture.
$phongexponenttexture <texture>
Despite the name, this is a mask that defines the metalness of the material.

Specular/Gloss Parameters

$pbr <boolean>
Enables PBR reflections.
$masks <texture>
A mask for specular and glossiness. $pbr must be enabled to work.

Misc. Parameters

$fuzz <boolean>
Enables a asperity/fuzz scattering pass on the material.
$fuzzmultiplier <float>
Multiplier for the fuzz effect, default is 1.0.
$roughnessmultiplier <float>
Multiplier for roughness.
Todo: More detail, what is roughness?
$subsurfacescattering <boolean>
Enables Subsurface scattering on the material. Used for faces and skin.
$diffusionweights <RGB matrix>
Used by $subsurfacescattering.
$diffusionweights2 <RGB matrix>
Used by $subsurfacescattering.
$disableenvmap <boolean>
Enabling disables $envmap reflections. The shader will use $envmap by default even if it isn't specified, unless this is enabled.

Configuring the masks

$phongexponenttexture

The RGB channels of $phongexponenttexture is configured as follows:

Channel/Info Data
Red Glossiness (roughness inverted)
Green Metalness inverted
Blue Sub-surface scattering mask. Translucency/Fuzz mask (optional, used for characters and cloth on models).
Format DXT1 for 3-channel, ATI2N for 2-channel

$metal must be set to 1 in order to use the green channel.

Note.pngNote: $fuzz and $detailnormal use the inverse of the blue channel.

$masks

The RGB and alpha channels of $masks is configured as follows:

Channel/Info Data
RGB Specular tint
Alpha Glossiness
Format DXT5

$pbr must be enabled to make use of $masks.

See also

  • WorldGGX, similar shader used for brushes and displacements.