From Valve Developer Community
Jump to: navigation, search
This article is about the shader. For the preceding shader, see Eyes. For the QC property of $model, see Eyeball. For the tool, see qc_eyes.

EyeRefract (DX9+) is a material shader available in all Source games since <Source><Source> Source 2007. It is used to create realistic eyes, which are affected by map lighting and dynamic lighting, such as those from flashlights. This shader is a successor to the Eyes shader from <Half-Life 2> Half-Life 2.

Bug.png Bug: Although this shader has support for $emissiveblend, it is not fully implemented and does not work properly.
Bug.png Bug: The shader doesn't work in Counter-Strike: Global Offensive. Eyes always directed to map center. Standard models use static eyes

Shader Parameters

$iris <texture>
The texture for the iris. The alpha channel controls the noisiness of the cornea.
$irisframe <integer>
The frame to start an animated $iris on.
$corneatexture <texture>
A texture to specify the shape of the cornea, similar to a normal map. Influences lighting and dilation. The red and green channels are used for the normal mapping, the blue channel is a mask for parallax mapping (straight multiply), and the alpha channel seems to be a multiplier for lighting. Because the $iris is warped in various ways the normals will not match 1-to-1 with the base texture. To do: Requires more testing. Source code: eye_refract_ps2x.fxc - search for "fIrisHighlightMask".
$corneabumpstrength <float>
Strength of the $corneatexture.
$parallaxstrength <float>
How much the viewing angle should influence the positioning of the eye. Stronger values cause the iris to be smaller, but also move slower, making it seem "inset further". Default 0.25.
$dilation <normal>
Dilates the pupil using the cornea texture to determine the shape of dilation. Default 0.5.
$lightwarptexture <texture>
1-dimensional texture which remaps lighting colors.
$envmap <texture>
Enables cubemap reflections. This shader has a specific cubemap made for it, engine/eye-reflection-cubemap-.vtf, but others can be used, including env_cubemap.
$glossiness <float>
The opacity of the cubemap reflection. Does not affect the eye glint. Default 0.5.
$ambientoccltexture <texture>
An ambient occlusion texture 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 texture is multiplicative (white changes nothing, black turns the result darker).
$ambientocclcolor <RGB matrix>
Tints the $ambientoccltexture. Default "[0.33 0.33 0.33]".
$ambientocclusion <float> (in all games since <Left 4 Dead>)
Strength of the dynamic ambient occlusion. Default 1. To do: Strength for SSAO?
$halflambert <boolean>
Enables half-lambertian lighting.
$raytracesphere <boolean>
Enables sphere raytracing. Each pixel is raytraced to allow sharper angles to look more accurate.
$spheretexkillcombo <boolean>
Requires $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>
Requires $raytracesphere 1. Radius of the eyeball. Should be the diameter of the eyeball divided by 2. Default 0.5.

Other Parameters

$eyeorigin <vector3>
Eyeball origin. Most likely derived from the qc eyes definition.
$irisu <vector4>
$irisv <vector4>
U/V projection vector for the iris. Default "[0 1 0 0]" and "[0 0 1 0]", respectively.
$intro <boolean>
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 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?