This article's documentation is for anything that uses the Source engine. Click here for more information.

EyeRefract: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
 
(23 intermediate revisions by 15 users not shown)
Line 1: Line 1:
{{stub}}
{{Source topicon}} {{LanguageBar}}
 
== EyeRefract ==
[[File:Eyerefract.jpg|right|300px]]
[[File:Eyerefract.jpg|right|300px]]
'''Description'''
{{For|about=the shader|the preceding shader|{{ent|Eyes}}|the [[QC]] property of {{ent|$model}}|[[Eyeball]]|the tool|[[qc_eyes]]}}
 
{{this is a|vertex shader|since=Source 2007|name=EyeRefract}} This shader is a successor to the {{ent|Eyes}} shader from {{src04|1}}. Like it, {{code|EyeRefract}} is used to create life-like eyes, with more realistic shading, cornea parallax, and a wider set of supported effects than {{code|Eyes}}.  
{{todo|Add Pictures and Additional Information.}}
{{Bug|Although this shader has support for {{ent|$emissiveblend}}, it is not fully implemented and does not work properly.}}
 
{{Bug|The shader doesn't work in {{csgo|2.bold}}, where eyes are always directed to the map's center. Standard models use static eyes.}} {{confirm|is this just CS:GO, or is it all {{csgobranch|2}} games?}}
EyeRefract 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.
{{Bug|On {{src13|3.1}}, it's been observed to cause issues when used in scenes with [[expensive]] [[water]], causing flickering and tears or disappearing of the water itself. It is advised to stick to the more stable {{code|Eyes}} shader, unless you're sure you can avoid these issues.}}
 
There are many other parameters and features yet to be discovered which are found with each new build of Source.
 
 
 
 
 
 
== Shader Parameters ==
== Shader Parameters ==
{{todo|Finish Table.}}
{{MatParamDef|$iris|texture|The texture used for the iris. The alpha channel masks the iris against the sclera, which makes the iris more prominent. Opaque values mark the sclera, and transparent values mark the iris.}}
 
{{MatParamDef|$irisframe|int|The frame to start an animated <code>$iris</code> on.}}
{|border="1" cellpadding="5" cellspacing="0" align="center"
{{MatParamDef|$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 <code>$iris</code> is warped in various ways the normals will not match 1-to-1 with the base texture. {{todo|Requires more testing. Source code: eye_refract_ps2x.fxc - search for "fIrisHighlightMask"}}}}
|-
{{MatParamDef|$corneabumpstrength|float|Strength of the <code>$corneatexture.</code>}}
! scope="col" style="background:#5F5F5F;color:white;" | Shader Parameter
{{MatParamDef|$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>.}}
! scope="col" style="background:#5F5F5F;color:white;" | Description
{{MatParamDef|$dilation|normal|Dilates the pupil using the cornea texture to determine the shape of dilation. Default <code>0.5</code>.}}
! scope="col" style="background:#5F5F5F;color:white;" | Default Value
{{MatParamDef|$lightwarptexture|texture|1-dimensional texture which remaps lighting colors.}}
! scope="col" style="background:#5F5F5F;color:white;" | Example
{{MatParamDef|$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>.}}
|-
{{MatParamDef|$glossiness|float|The opacity of the cubemap reflection. Does not affect the eye glint. Default <code>0.5</code>.}}
|$Iris
{{MatParamDef|$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).}}
|Base model to use for the iris.
{{MatParamDef|$ambientocclcolor|RGB matrix|Tints the <code>$ambientoccltexture</code>. Default <code>"[0.33 0.33 0.33]"</code>.}}
|N/A
{{MatParamDef|$ambientocclusion|float|Strength of the dynamic ambient occlusion. Default <code>1</code>. {{todo|Strength for SSAO?}}|since={{l4d}}}}
|"$Iris"              "models/cra0kalo/ct_swat/eye-iris-brown"
{{MatParamDef|$halflambert|bool|Enables half-lambertian lighting.}}
|-
{{MatParamDef|$raytracesphere|bool|Enables sphere raytracing. Each pixel is raytraced to allow sharper angles to look more accurate.}}
|$Irisframe
{{MatParamDef|$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.}}
|Frame for the iris texture, 0 being the default frame
{{MatParamDef|$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>.}}
|0
|"$Irisframe" "0"
|}
 
----
'''Example Code'''
<pre>
"EyeRefract"
{
"$Iris"              "models/cra0kalo/ct_swat/eye-iris-brown"     // Iris color in RGB with cornea noise in A
"$Irisframe" "0"    // Frame for the iris texture, 0 being the default frame
"$AmbientOcclTexture" "models/cra0kalo/ct_swat/eye_ao"      // Ambient occlusion in RGB, A unused // default texture eyeball_l_ambient
//"$Envmap"            "models/cra0kalo/ct_swat/cubemap"    // Reflection environment map static
"$Envmap"            "models/cra0kalo/ct_swat/eye-reflection-cubemap-"    // Reflection environment map
"$CorneaTexture"      "models/cra0kalo/ct_swat/eye-cornea"                // Special texture that has 2D cornea normal in RG and other data in BA
"$lightwarptexture" "models/cra0kalo/ct_swat/eye_lightwarp"  // 1D ramp texture for tinting scalar diffuse term
 
"$EyeballRadius" "0.5"    // Default 0.5
"$AmbientOcclColor" "[0.36 0.25 0.2]" // Default 0.33, 0.33, 0.33
"$Dilation" "0.4"    // Default 0.5
"$Glossiness" "1"    // Glossiness of eye (1 is default, 0 is not glossy at all)
"$ParallaxStrength" "0.25"          // Default 0.25
"$CorneaBumpStrength" "1.25"  // Default 1.0
 
"$halflambert" "1"
"$nodecal" "1"
 
// These effects are only available in ps.2.0b and later
"$RaytraceSphere" "0"    // Default 1 - Enables raytracing in the pixel shader to make the eyeball look round
"$SphereTexkillCombo" "0"  // Default 1 - Enables killing pixels that don't ray-intersect the sphere
 
 
//Unknown Parameters


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


{{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?}}
// Eyerefract SDK_EyeRefract 2007 shader used in the popular Tf2 and l4d games
// Check Discussion tab for more params
</pre>

Latest revision as of 11:45, 23 August 2025

English (en)Translate (Translate)
Eyerefract.jpg
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 is a Vertex shader available in all Source Source games since Source 2007 Source 2007. This shader is a successor to the Eyes shader from Source 2004. Like it, EyeRefract is used to create life-like eyes, with more realistic shading, cornea parallax, and a wider set of supported effects than Eyes.

Icon-Bug.pngBug:Although this shader has support for $emissiveblend, it is not fully implemented and does not work properly.  [todo tested in ?]
Icon-Bug.pngBug:The shader doesn't work in Counter-Strike: Global Offensive Counter-Strike: Global Offensive, where eyes are always directed to the map's center. Standard models use static eyes.  [todo tested in ?]
Confirm:is this just CS:GO, or is it all CS:GO engine branch CS:GO engine branch games?
Icon-Bug.pngBug:On Source 2013, it's been observed to cause issues when used in scenes with expensive water, causing flickering and tears or disappearing of the water itself. It is advised to stick to the more stable Eyes shader, unless you're sure you can avoid these issues.  [todo tested in ?]

Shader Parameters

The texture used for the iris. The alpha channel masks the iris against the sclera, which makes the iris more prominent. Opaque values mark the sclera, and transparent values mark the iris.
The frame to start an animated $iris on.
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.
Todo: Requires more testing. Source code: eye_refract_ps2x.fxc - search for "fIrisHighlightMask"
Strength of the $corneatexture.
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.
Dilates the pupil using the cornea texture to determine the shape of dilation. Default 0.5.
1-dimensional texture which remaps lighting colors.
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.
The opacity of the cubemap reflection. Does not affect the eye glint. Default 0.5.
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).
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.
Todo: Strength for SSAO?
Enables half-lambertian lighting.
Enables sphere raytracing. Each pixel is raytraced to allow sharper angles to look more accurate.
Requires $raytracesphere 1. Causes pixels which don't hit the raytraced sphere to be transparent, instead of rendering the "non-raytraced" eye behind it.
Requires $raytracesphere 1. Radius of the eyeball. Should be the diameter of the eyeball divided by 2. Default 0.5.

Other Parameters

Eyeball origin. Most likely derived from the QC eyes definition.
Todo: This material shader parameter has not been described.
U/V projection vector for the iris. Default "[0 1 0 0]" and "[0 0 1 0]", respectively.
Eyes are used on a model in Half-Life 2: Episode One Half-Life 2: Episode One's intro cutscene. Adds another shader pass.
Requires $intro 1. How far into the warp animation we are.
Requires $intro 1. World-space location of the entity, required to correctly animate the warp.
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?