EyeRefract: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (DX9 requirement)
(Rewritten, changed to use Shader and MatParam templates, added $ambientocclusion from L4D)
Line 1: Line 1:
[[File:Eyerefract.jpg|right|300px]]
[[File:Eyerefract.jpg|right|300px]]


<code>EyeRefract</code> {{dx9}} is the latest eye [[shader]] by Valve. It is used in their popular titles {{tf2}} [[Team Fortress 2]] and {{l4d}} [[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|EyeRefract|dx9=1|since=Half-Life 2: Episode Two}} 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 {{ent|Eyes}} shader from {{Game link|Half-Life 2}}.
{{Bug|Although this shader has support for {{ent|$emissiveblend}}, it is not fully implemented and does not work properly.}}


= Shader Parameters =
== Shader Parameters ==


; <code>$iris <[[texture]]></code>
{{MatParam|$iris|texture|The texture for the iris. The alpha channel controls the noisiness of the cornea.}}
: 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.
{{MatParam|$irisframe|int|The frame to start an animated <code>$iris</code> on.}}
; <code>$irisframe <[[int]]></code>
{{MatParam|$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. {{todo|Requires more testing. Source code: eye_refract_ps2x.fxc - search for "fIrisHighlightMask"}}.}}
: Current frame value for $iris, if it is animated. 0 is the default starting frame.
{{MatParam|$corneabumpstrength|float|Strength of the <code>$corneatexture.</code>}}
; <code>$corneatexture <texture></code>
{{MatParam|$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 <code>0.25</code>.}}
: 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 {{todo|Requires more testing. Source code: eye_refract_ps2x.fxc - search for "fIrisHighlightMask"}}.
{{MatParam|$dilation|normal|Dilates the pupil using the cornea texture to determine the shape of dilation. Default <code>0.5</code>.}}
; <code>$corneabumpstrength <[[float]]></code>
{{MatParam|[[$lightwarptexture]]|texture|1-dimensional texture which remaps lighting colors.}}
: Changes how strong of an effect the $corneatexture has.
{{MatParam|[[$envmap]]|texture|Enables cubemap reflections. This shader has a specific cubemap made for it, <code>engine/eye-reflection-cubemap-.vtf</code>, but others can be used, including <code>env_cubemap</code>.}}
; <code>$parallaxstrength <float></code>
{{MatParam|$glossiness|float|The opacity of the cubemap reflection. Does not affect the eye glint. Default <code>0.5</code>.}}
: 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".
{{MatParam|$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).}}
; <code>$dilation <float></code>
{{MatParam|$ambientocclcolor|RGB matrix|Tints the <code>$ambientoccltexture</code>. Default <code>"[0.33 0.33 0.33]"</code>.}}
: Dilates the pupil using the cornea texture to determine the shape of dilation. Default value is 0.5.
{{MatParam|$ambientocclusion|float|Strength of the dynamic ambient occlusion. Default <code>1</code>. {{todo|Strength for SSAO?}}|since=L4D}}
; <code>[[$lightwarptexture]] <texture></code>
{{MatParam|[[$halflambert]]|bool|Enables half-lambertian lighting.}}
: 1-dimensional texture which remaps lighting colors.
{{MatParam|$raytracesphere|bool|Enables sphere raytracing. Each pixel is raytraced to allow sharper angles to look more accurate.}}
; <code>[[$envmap]] <texture></code>
{{MatParam|$spheretexkillcombo|bool|Requires <code>$raytracesphere 1</code>. Causes pixels which don't hit the raytraced sphere to be transparent, instead of rendering the "non-raytraced" eye behind it.}}
: Enables cube map reflections. <code>engine/eye-reflection-cubemap-.vtf</code> is what Valve uses for this parameter.
{{MatParam|$eyeballradius|float|Requires <code>$raytracesphere 1</code>. Radius of the eyeball. Should be the diameter of the eyeball divided by 2. Default <code>0.5</code>.}}
; <code>$glossiness <float></code>
: Changes the opacity of the cubemap. Default value is 0.5, and it can go above 1 as well. Does not influence the eye glint.
; <code>$ambientoccltexture <texture></code>
: 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).
; <code>$ambientocclcolor <color></code>
: Tints the $ambientoccltexture. Default value is "[0.33 0.33 0.33]"
; <code>[[$halflambert]] <[[bool]]></code>
: Enables the Half Lambert lighting.  
; <code>$raytracesphere <bool></code>
: Enables more accurate rendering of the eyeball as a sphere. Each pixel is raytraced to allow sharper angles to look more accurate.
; <code>$spheretexkillcombo <bool></code>
: 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.
; <code>$eyeballradius <float></code>
: 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 ==
== Other Parameters ==


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


{{todo|Include cloak parameters and emissive blend parameters in here?}}
{{todo|Include cloak parameters in here?}}


{{todo|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?}}
{{todo|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?}}


[[Category:Shaders|E]]
==See also==
*[[Eyeball]]
*[[qc_eyes]]

Revision as of 12:45, 7 June 2019

Eyerefract.jpg

Shader-ball.png EyeRefract 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 .

Icon-Bug.pngBug:Although this shader has support for $emissiveblend, it is not fully implemented and does not work properly.  [todo tested in ?]

Shader Parameters

$iris $irisframe $corneatexture $corneabumpstrength $parallaxstrength $dilation [[$lightwarptexture|$lightwarptexture]] [[$envmap|$envmap]] $glossiness $ambientoccltexture $ambientocclcolor $ambientocclusion [[$halflambert|$halflambert]] $raytracesphere $spheretexkillcombo $eyeballradius

Other Parameters

$eyeorigin $irisu $irisv $intro $warpparam $entityorigin

Todo: Include cloak parameters in here?
Todo: 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?

See also