Difference between revisions of "EyeRefract"

From Valve Developer Community
Jump to: navigation, search
(Added all shader parameter descriptions, formatted according to other pages.)
Line 1: Line 1:
{{stub}}
 
 
== EyeRefract ==
 
 
[[File:Eyerefract.jpg|right|300px]]
 
[[File:Eyerefract.jpg|right|300px]]
'''Description'''
 
 
{{todo|Add Pictures and Additional Information.}}
 
 
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.
 
 
There are many other parameters and features yet to be discovered which are found with each new build of Source.
 
 
 
 
 
 
 
== Shader Parameters ==
 
{{todo|Finish Table.}}
 
 
{|border="1" cellpadding="3" cellspacing="0" align="center"
 
|-
 
! scope="col" style="background:#5F5F5F;color:white;" | Shader Parameter
 
! scope="col" style="background:#5F5F5F;color:white;" | Description
 
! scope="col" style="background:#5F5F5F;color:white;" | Default Value
 
! scope="col" style="background:#5F5F5F;color:white;" | Example
 
|-
 
|$Iris <[[string]]>
 
|Base model texture to use for the iris.
 
|N/A
 
|"$Iris"              "models/cra0kalo/ct_swat/eye-iris-brown"
 
|-
 
|$Irisframe <[[string]]>
 
|Frame for the iris texture.
 
|0
 
|"$Irisframe" "0"
 
|-
 
|$AmbientOcclTexture <[[string]]>
 
|Texture to use for the iris.
 
|eyeball_l_ambient
 
|"$AmbientOcclTexture"              "models/cra0kalo/ct_swat/eye_ao"
 
|-
 
|$Envmap <[[string]]>
 
|Reflection environment map.
 
|N/A
 
|"$Envmap"            "models/cra0kalo/ct_swat/eye-reflection-cubemap-"
 
|-
 
|$CorneaTexture <[[string]]>
 
|Texture to use for the cornea.
 
|N/A
 
|"$CorneaTexture"      "models/cra0kalo/ct_swat/eye-cornea"
 
|-
 
|$lightwarptexture <[[string]]>
 
|1D ramp texture for tinting scalar diffuse.
 
|N/A
 
|"$lightwarptexture"              "models/cra0kalo/ct_swat/eye_lightwarp"
 
|-
 
|
 
|
 
|
 
|
 
|-
 
|$EyeballRadius <[[float]]>
 
|Radius of Eyeball.
 
|0.5
 
|"$EyeballRadius"              "0.56"
 
|}
 
  
----
+
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. 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.
'''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
+
= Shader Parameters =
"$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
 
  
 +
; <code>$iris <[[texture]]></code>
 +
: 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.
 +
; <code>$irisframe <[[int]]></code>
 +
: Current frame value for $iris, if it is animated. 0 is the default starting frame.
 +
; <code>$corneatexture <texture></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"}}.
 +
; <code>$corneabumpstrength <[[float]]></code>
 +
: Changes how strong of an effect the $corneatexture has.
 +
; <code>$parallaxstrength <float></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".
 +
; <code>$dilation <float></code>
 +
: Dilates the pupil using the cornea texture to determine the shape of dilation. Default value is 0.5.
 +
; <code>[[$lightwarptexture]] <texture></code>
 +
: 1-dimensional texture which remaps lighting colors.
 +
; <code>[[$envmap]] <texture></code>
 +
: Enables cube map reflections.
 +
; <code>$glossiness <float></code>
 +
: Changes the opacity of $envmap. 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. {todo|Does this have an effect in EyeRefract?}
 +
; <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.
  
//Unknown Parameters
+
== Other Parameters ==
 
  
"$eyeorigin" "[0 0 0]" // Origin for the eyes
+
; <code>$eyeorigin <vector3></code>
"$irisu" "[0 1 0 0]"
+
: Eyeball origin. Most likely derived from the qc eyes definition.
"$irisv" "[0 0 1 0]"
+
; <code>$irisu <vector4></code> and <code>$irisv <vector4></code>
"$Entityorigin" "4.0"
+
: U/V projection vector for the iris.
 +
; <code>$intro <bool></code>
 +
: Eyes are used on a model in Episode 1's intro cutscene. Adds another shader pass.
 +
; <code>$warpparam <float></code>
 +
: Requires $intro 1. How far into the warp animation we are.
 +
; <code>$entityorigin <vector3></code>
 +
: Requires $intro 1. World-space location of the entity, required to correctly animate the warp.
  
 +
{{todo|Include cloak parameters and emissive blend 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>
 

Revision as of 05:15, 26 January 2019

Eyerefract.jpg

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?