From Valve Developer Community
Revision as of 05:15, 26 January 2019 by Doublethinking (talk | contribs) (Added all shader parameter descriptions, formatted according to other pages.)
Jump to: navigation, search

EyeRefract is the latest eye shader by Valve. It is used in their popular titles <Team Fortress 2> Team Fortress 2 and <Left 4 Dead> Left 4 Dead. EyeRefract is a specialized shader that is used on character eyes to increase realism. Unlike the Eyes shader, this one looks like actual eyes by including some more features, such as sphere raytracing and dilation using normal maps. It also handles the eye glint without using a second shader, and supports both lighting from the map and from flashlights.

Shader Parameters

$iris <texture>
The texture to use for the iris. This replaces the role of $basetexture in this shader. The alpha channel describes how noisy the cornea should be (see below). This can be left to 0 if your cornea texture is already of a high enough resolution.
$irisframe <int>
Current frame value for $iris, if it is animated. 0 is the default starting frame.
$corneatexture <texture>
Used to specify the shape of the cornea. Functions similar to a normal map, and usually looks like a sphere's. Influences lighting and dilation. Only red and green channels are used for the normal mapping. Blue is a mask for parallax mapping (straight multiply). Alpha seems to be a multiplier for lighting To do: Requires more testing. Source code: eye_refract_ps2x.fxc - search for "fIrisHighlightMask".
$corneabumpstrength <float>
Changes how strong of an effect the $corneatexture has.
$parallaxstrength <float>
Changes how much the viewing angle should influence the positioning of the eye. Default value is 0.25. Stronger values cause the iris to be smaller, but also move slower, making it seem "inset further".
$dilation <float>
Dilates the pupil using the cornea texture to determine the shape of dilation. Default value is 0.5.
$lightwarptexture <texture>
1-dimensional texture which remaps lighting colors.
$envmap <texture>
Enables cube map reflections.
$glossiness <float>
Changes the opacity of $envmap. Default value is 0.5, and it can go above 1 as well. Does not influence the eye glint.
$ambientoccltexture <texture>
This texture is overlaid onto the entire eye (be sure to adjust the iris scale of the Eyeball in the qc to make it fit) to make it appear darker near the borders. The colors are multiplied (white changes nothing, black turns the result darker).
$ambientocclcolor <color>
Tints the $ambientoccltexture. Default value is "[0.33 0.33 0.33]"
$halflambert <bool>
Enables the Half Lambert lighting. {todo|Does this have an effect in EyeRefract?}
$raytracesphere <bool>
Enables more accurate rendering of the eyeball as a sphere. Each pixel is raytraced to allow sharper angles to look more accurate.
$spheretexkillcombo <bool>
Only works with $raytracesphere 1. Causes pixels which don't hit the raytraced sphere to be transparent, instead of rendering the "non-raytraced" eye behind it.
$eyeballradius <float>
Only works with $raytracesphere 1. Radius of the eyeball (looks best if you have accurate eye positions set up, and set the radius to the eye's actual diameter divided by 2). Default value is 0.5.

Other Parameters

$eyeorigin <vector3>
Eyeball origin. Most likely derived from the qc eyes definition.
$irisu <vector4> and $irisv <vector4>
U/V projection vector for the iris.
$intro <bool>
Eyes are used on a model in Episode 1's intro cutscene. Adds another shader pass.
$warpparam <float>
Requires $intro 1. How far into the warp animation we are.
$entityorigin <vector3>
Requires $intro 1. World-space location of the entity, required to correctly animate the warp.

To do: Include cloak parameters and emissive blend parameters in here?

To do: Can this shader be used outside of a model with qc eyes, by using proxies (or in SFM override materials) to modify these shader values?