$phong: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Added a note to $phongexponenttexture)
No edit summary
Line 1: Line 1:
[[Image:Alyx phong closeup.jpg|thumb|Phong shading provides Alyx's skin, hairband and lip highlights.]]
[[File:Alyx phong closeup.jpg|thumb|Phong shading provides Alyx's skin, hairband and lip highlights.]]


The '''<code>$phong</code>''' [[VMT]] command provides diffuse reflections. For a full explanation, see [[Phong materials]].
The '''<code>$phong</code>''' [[VMT]] command provides diffuse reflections. It is only available with <code>[[VertexLitGeneric]]</code>. For a full explanation, see [[Phong materials]].
 
{{note|Phong shading is only available with [[VertexLitGeneric]].}}


==VMT syntax==
==VMT syntax==
Line 11: Line 9:
The Phong shader ''should'' use the default values for any configuration parameters that you omit from your material. However it appears that this doesn't happen. Therefore all of the below parameters are required, even if they stay on their default values.
The Phong shader ''should'' use the default values for any configuration parameters that you omit from your material. However it appears that this doesn't happen. Therefore all of the below parameters are required, even if they stay on their default values.


[[VertexLitGeneric]]
<syntaxhighlight lang=php>
{
VertexLitGeneric
$phong 1
{
$phong 1
[[$bumpmap]] <texture>
 
$phongexponent 5 ''// either/or''
$bumpmap [texture]
$phongexponenttexture <texture> ''// either/or''
$phongexponent 5 // either/or
$phongboost 1.0
$phongexponenttexture [texture] // either/or
$phongfresnelranges "[0 0.5 1]"
$phongboost 1.0
}
$phongfresnelranges "[0 0.5 1]"
}
</syntaxhighlight>
 
== Parameters ==


== Additional parameters ==
=== Masking ===


; <code>$bumpmap <texture></code>
; <code>$bumpmap <[[texture]]></code>
: See <code>[[$bumpmap]]</code>. Its [[alpha channel]] acts as a Phong mask.
: There must be a [[$bumpmap|bump map]]. Its [[alpha channel]] acts as a Phong mask by default.
; <code>$basemapluminancephongmask <1/0></code>
; <code>$basemapluminancephongmask <[[bool]]></code>
: {{stub}}
: {{todo|Brightness of albedo determines amount of phong?}}
;<code>$basemapalphaphongmask <1/0></code>
;<code>$basemapalphaphongmask <bool></code>
: Enable this if the Phong mask is in the <code>[[$basetexture]]</code> [[alpha channel]].
: Reads the Phong mask from <code>[[$basetexture]]</code>'s [[alpha channel]] instead of <code>$bumpmap</code>'s.
; <code>$phongexponent <[[int]]></code>
; <code>$phongexponent <[[int]]></code>
; <code>$phongexponenttexture <texture></code>  
; <code>$phongexponenttexture <texture></code>  
: See [[Phong materials#Phong mask and exponent texture|Phong mask and exponent texture]]. The texture value is overridden by the numeric value if both are present. NOTE: An engine update broke this, Valve stated that they will fix the problem in a later update. $phongexponent is unaffected and still works correctly
: An global [[Phong materials#Phong mask and exponent texture|exponent]] value, or a per-texel exponent texture map. The numeric value wins if both are present. In an exponent map:
; <code>$phongboost <int></code>
:* '''Red channel:''' Exponent (size of highlight, higher is larger)
: Phong overbrightening factor. The phong mask channel should be authored to account for this.
:* '''Green channel:''' Albedo tint (if <code>$phongalbedotint 1</code>, higher is more tint)
:* '''Blue channel:''' Nothing
:* '''Alpha channel:''' <code>[[$rimlight]]</code> mask
; <code>$phongalbedotint <bool></code>
: Allows the <code>[[$basetexture]]</code> to affect the colour of the Phong highlight. The amount of tint is defined by the green channel of the exponent texture (see above).
 
=== Brightness ===
 
; <code>$phongboost <[[int]]></code>
: Phong brightness factor. The phong mask channel should be authored to account for this.
; <code>$phongfresnelranges <matrix></code>
: See [[Phong materials#Phong Fresnel ranges|Phong Fresnel ranges]]. Default is <code>"[0 0.5 1]"</code>.
; <code>$phongdisablehalflambert <int></code>
; <code>$phongdisablehalflambert <int></code>
: Used in [[Portal 2]] on the Personality Cores such as Wheatley, disables functionality of $halflambert. MAY need <code>$halflambert 0</code>!
: Used in [[Portal 2]] on the Personality Cores such as Wheatley, disables functionality of $halflambert. MAY need <code>$halflambert 0</code>!
;<code>$ambientocclusiontexture <texture></code>
: A "dirtmap". Mentioned in the SDK samples and seen in the VMT for Alyx's face. [[$ambientocclusion|Ambient Occlusion]] is generally used for the eyes and face.
=== Colours ===
; <code>$phongtint "[<red [[float]]> <green float> <blue float>]"
; <code>$phongtint "[<red [[float]]> <green float> <blue float>]"
: Modifies the colour of the phong reflection. <code>"[0 0 0]"</code> means the feature is disabled.
: Modifies the colour of the phong reflection. <code>"[0 0 0]"</code> means the feature is disabled.
; <code>$phongfresnelranges <matrix></code>
: See [[Phong materials#Phong Fresnel ranges|Phong Fresnel ranges]]. Default is <code>"[0 0.5 1]"</code>.
; <code>$phongwarptexture <texture></code> {{EP2 add}}
; <code>$phongwarptexture <texture></code> {{EP2 add}}
: Used to create an iridescence effect, as seen on [[npc_hunter]]s.
: {{todo|Used to create an iridescence effect, as seen on [[npc_hunter]]s.}}
: {{TODO|Needs documentation.}}
; <code>$phongalbedotint <?></code>
: Allow the [[albedo]] (i.e. [[$basetexture]]) to affect the colour tint of the Phong highlight? Possibly related to the green channel of the Phong exponent mask. Seen in some Day of Defeat: Source player model VMTs.
: {{TODO|Needs documentation.}}
;<code>$ambientocclusiontexture <texture></code>
: A "dirtmap". Mentioned in the SDK samples and seen in the VMT for Alyx's face. [[$ambientocclusion|Ambient Occlusion]] is generally used for the eyes and face.
;<code>"GPU>=2?$phong" 1</code>
: (Use with <code>$phong 0</code>) Only uses phong if the current PC is using dual GPUs.
: {{TODO|Check if correct, it may be wrong}}


== See also ==
== See also ==


* [[Phong materials]]
* [[Phong materials]]
* [[$basetexture]]
* [[$envmapmask]] (specular mask)
* [[$envmap]] (environment map)
* [[$envmap]] (environment map)
* [[$lightwarptexture]]
* [[$lightwarptexture]]
* [[$rimlight]]
* [[$rimlight]]


[[Category:List of Shader Parameters|P]]
[[Category:List of Shader Parameters|P]]
[[Category:VMT Lighting]]
[[Category:VMT Lighting]]

Revision as of 03:04, 11 July 2011

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

The $phong VMT command provides diffuse reflections. It is only available with VertexLitGeneric. For a full explanation, see Phong materials.

VMT syntax

$phong <bool>

The Phong shader should use the default values for any configuration parameters that you omit from your material. However it appears that this doesn't happen. Therefore all of the below parameters are required, even if they stay on their default values.

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 bump map. Its alpha channel acts as a Phong mask by default.
$basemapluminancephongmask <bool>
Todo: Brightness of albedo determines amount of phong?
$basemapalphaphongmask <bool>
Reads the Phong mask from $basetexture's alpha channel instead of $bumpmap's.
$phongexponent <int>
$phongexponenttexture <texture>
An global exponent value, or a per-texel exponent texture map. The numeric value wins if both are present. In an exponent map:
  • Red channel: Exponent (size of highlight, higher is larger)
  • Green channel: Albedo tint (if $phongalbedotint 1, higher is more tint)
  • Blue channel: Nothing
  • Alpha channel: $rimlight mask
$phongalbedotint <bool>
Allows the $basetexture to affect the colour of the Phong highlight. The amount of tint is defined by the green channel of the exponent texture (see above).

Brightness

$phongboost <int>
Phong brightness factor. The phong mask channel should be authored to account for this.
$phongfresnelranges <matrix>
See Phong Fresnel ranges. Default is "[0 0.5 1]".
$phongdisablehalflambert <int>
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

$phongtint "[<red float> <green float> <blue float>]"
Modifies the colour of the phong reflection. "[0 0 0]" means the feature is disabled.
$phongwarptexture <texture> Template:EP2 add
Todo: Used to create an iridescence effect, as seen on npc_hunters.

See also