$phong: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Updated dead link)
(Removed $allowdiffusemodulation, doesn't seem to be related to phong if the $allowdiffusemodulation article is any indication)
Line 47: Line 47:
; {{L4D add|<code>$shinybloodexponent <int></code>}}
; {{L4D add|<code>$shinybloodexponent <int></code>}}
: {{todo|1=See ''[https://steamcdn-a.akamaihd.net/apps/valve/2010/GDC10_ShaderTechniquesL4D2.pdf#page=33 Shading a Bigger, Better Sequel: Techniques in Left 4 Dead 2]''.}}
: {{todo|1=See ''[https://steamcdn-a.akamaihd.net/apps/valve/2010/GDC10_ShaderTechniquesL4D2.pdf#page=33 Shading a Bigger, Better Sequel: Techniques in Left 4 Dead 2]''.}}
; <code>$allowdiffusemodulation <int></code>
: {{todo}}
; <code>$DiffuseExp</code>
; <code>$DiffuseExp</code>
: {{todo|Does this have something to do with the ''$phongexponent'', ''$phongexponenttexture or both?}}
: {{todo|Does this have something to do with the ''$phongexponent'', ''$phongexponenttexture or both?}}

Revision as of 21:12, 23 April 2019

Phong shading provides Alyx's skin, hairband and lip highlights.

The $phong VMT command provides diffuse reflections. In most engine branches it is only available with VertexLitGeneric; Counter-Strike: Global Offensive Counter-Strike: Global Offensive (as of early 2015) allows it to a limited extent on LightmappedGeneric. For a full explanation, see Phong materials.

VMT syntax

$phong <bool>
Note.pngNote:All parameters must be specified otherwise the phong shader won't show up at all, except in Insurgency.
Todo: Other games that don't require all phong parameters present (likely Portal 2 and up)
VertexLitGeneric
{
	$phong 1

	$bumpmap				[texture]
	$phongexponent			5			// either/or
	$phongexponenttexture	[texture]	// either/or
	$phongboost				1.0
	$phongfresnelranges		"[0 0.5 1]"
}

Parameters

Masking

$bumpmap <texture>
There must be a Phong mask. The alpha channel of a bump map acts as a Phong mask by default.
$BasemapAlphaPhongMask <bool>
Uses $basetexture's alpha channel as the Phong mask instead of $bumpmap's. The phong will not be influenced by the bumpmap, however.
Template:L4D add
Phong intensity is based on the brightness of $basetexture.
$PhongExponent <int>
The numeric value overrides an exponent mask if present.
$PhongExponentTexture <texture>
A global exponent value, or a per-texel exponent texture map. In an exponent map:
  • Red channel: Exponent (size of highlight, 0-255, where a value of 0 is a large highlight, 255 small.)
  • Green channel: Albedo tint (if $phongalbedotint 1, higher is more tint)
  • Blue channel: Nothing
  • Alpha channel: $rimlight mask
$InvertPhongMask <bool>
Appears to invert the value of the phong mask, as the name suggests.
Todo: What types of mask does this work on?
$PhongExponentFactor <int>
This number will be used to multiply the exponent texture.
Template:L4D add
Template:L4D add
$DiffuseExp
Todo: Does this have something to do with the $phongexponent, $phongexponenttexture or both?

Brightness

$phongboost <float>
Phong brightness factor. Larger values create a more intense highlight, useful for surfaces like metal and glass.
$PhongFresnelRanges <matrix>
See Phong Fresnel ranges. Default is "[0 0.5 1]".
$PhongDisableHalfLambert <bool> Template:P2 add
Used in Portal 2 on the Personality Cores such as Wheatley, disables functionality of $halflambert. MAY need $halflambert 0!
$AmbientOcclusionTexture <texture>
A "dirtmap". Mentioned in the SDK samples and seen in the VMT for Alyx's face. Ambient Occlusion is generally used for the eyes and face.

Colours

$PhongAlbedoTint <bool>
Allows the $basetexture to affect the colour of the Phong highlight. The amount of tint is defined by the green channel of $phongexponenttexture (see above).
$phongtint "[<red float> <green float> <blue float>]"
Modifies the colour of the phong reflection. The channels are interpreted relative to each other (so "[0 0 0]" and "[1 1 1]" are the same).
Icon-Bug.pngBug:This does not work with $basemapalphaphongmask.  [todo tested in ?]
$PhongWarpTexture <texture> Template:EP2 add
Todo: Used to create an iridescence effect, as seen on npc_hunters.
Note.pngNote:Does not work in Left 4 Dead 2, despite the game being released in 2009

Phong shading on brush faces

A May 2015 update to Counter-Strike: Global Offensive Counter-Strike: Global Offensive added limited support for Phong-based highlights on LightmappedGeneric materials. Currently it only works when the material is directly lit by an env_cascade_lighting, using the dynamic shadows as a mask (although traditional Phong masking is supported on top of this). It is known to work on displacements as well as WorldVertexTransition materials, but not water or Lightmapped_4WayBlend.

New Parameters

$phongMaskContrastBrightness "[<float> <float>]"
Defines the contrast level between light and dark areas in the mask, and the overall brightness, respectively. Added along with support for phong-shaded lightmapped textures.
Todo: Find out the range of both values, and whether or not it can be used on models.
$phongAmount "[<red float> <green float> <blue float> <brightness> float]"
Controls the tint and brightness. The fourth value can go beyond 1, but affects the brightness of the whole texture, not just the highlight.

See also