Difference between revisions of "$flesh"

From Valve Developer Community
Jump to: navigation, search
(stub)
(Filled up the page with all shader parameters and basic usage information/limitations.)
Line 1: Line 1:
{{stub}}
+
[[File:Alyxrevive.png|thumbnail|right|The flesh shader in action.]]
 +
 
 
New in the Orange Box: inside-your-body rendering effects!
 
New in the Orange Box: inside-your-body rendering effects!
  
Use in conjunction with the [[point_flesh_effect_target]] entity, which creates a sphere within which the flesh interior will be rendered instead of skin.
+
While it was only used during the cutscene in Half-Life 2: Episode Two where Alyx is revived, it is pretty versatile due to its amount of parameters.
 +
 
 +
It displays a second rendering pass on top of the base material which can be blended by adding [[point_flesh_effect_target]] entities. When your model gets close to the sphere of these entities, the flesh will start to appear.
 +
 
 +
{{note|The flesh effects will only work when using [[VertexLitGeneric]] as your material's shader. Due to this, it only works on models.}}
 +
 
 +
== Usage ==
 +
 
 +
In addition to specifying the essential shader parameters for a [[VertexLitGeneric]] material, you have to ensure that your material defines a proxy as such:
 +
 
 +
  "Proxies"
 +
  {
 +
      "FleshInterior"
 +
      {
 +
      }
 +
  }
 +
 
 +
This is required to make the shader work, as it has to interact with the world and needs to also animate and update in real-time.
 +
 
 +
{{bug|This shader does not get illuminated from dynamic lighting of [[Source Filmmaker]] or [[env_projectedtexture]]. Ensure that the map lighting suffices and the player can not use their flashlight (or the map doesn't use this kind of lighting) when a model with this material is shown.}}
 +
 
 +
=== Shader Parameters ===
 +
 
 +
The following shader parameters allow you to enable and control the flesh effect:
 +
 
 +
; <code>$fleshinteriorenabled <[[bool]]></code>
 +
: Enables or disables the flesh effect for the material.
 +
; <code>$fleshinteriortexture <texture></code>
 +
: The texture used as a base for rendering the flesh. Its alpha value functions as a mask, whereas a higher alpha value (visible) result in that part of the texture showing flesh when an effect target comes close.
 +
; <code>$fleshnormaltexture <texture></code>
 +
: Normal map for the flesh effect.
 +
; <code>$fleshbordertexture1d <texture></code>
 +
: A texture similar to those used by <code>[[$lightwarptexture]]</code>. {{todo|Where on the texture is the "inside" or "outside" of the border effect?}} {{note|Even when using a fully white border texture and tint, a black tint can still be seen on the border. This is a limitation of the shader and can not be changed.}}
 +
; <code>$fleshsubsurfacetexture <texture></code>
 +
: A texture which is multiplied with the <code>$fleshinteriortexture</code> texture. Use a fully white texture (e.g. <code>vgui/white</code>) to skip this rendering pass.
 +
; <code>$fleshsubsurfacetint "[<red [[float]]> <green float> <blue float>]"</code>
 +
: Allows tinting the <code>$fleshsubsurfacetexture</code>. Default is <code>"[1 1 1]"</code>.
 +
; <code>$fleshinteriornoisetexture <texture></code>
 +
: Used on the border of the flesh effect, adding a distortion effect on the transition between exterior and interior. Scrolls based on the value of <code>$fleshscrollspeed</code>.
 +
; <code>$fleshscrollspeed <[[float]]></code>
 +
: Determines how fast the <code>$fleshinteriornoisetexture</code> should scroll.
 +
; <code>$fleshbordernoisescale <float></code>
 +
: Changes the scale of the <code>$fleshinteriornoisetexture</code>.
 +
; <code>$fleshborderwidth <float></code>
 +
: Determines the width of the border transition between interior and exterior. May change from which camera angles the effect is visible, as well. Must be greater than 0.
 +
; <code>$fleshbordersoftness <[[normal]]></code>
 +
: Changes how soft the transition between interior and exterior is. Values must be bigger than 0 but no higher than 0.5.
 +
; <code>$fleshbordertint "[<red [[float]]> <green float> <blue float>]"</code>
 +
: Allows tinting the effect border. Default is <code>"[1 1 1]"</code>.
 +
; <code>$fleshcubetexture <texture></code>
 +
: The cubemap texture to use for reflections on the flesh interior. Accepts values similar to <code>[[$envmap]]</code> (including <code>env_cubemap</code>).
 +
; <code>$fleshglossbrightness <float></code>
 +
: Changes the strength or brightness of the cubemap reflection (if <code>$fleshcubetexture</code> is specified).
 +
 
 +
=== Debugging ===
  
{{TODO|How the dickens does all this work?}}
+
Some shader parameters were included to allow for easier debugging, but don't have much use otherwise:
  
''// Flesh Interior Pass''
+
; <code>$fleshglobalopacity <normal></code>
$FleshInteriorEnabled 1 ''// Enables effect''
+
: Opacity of the entire flesh effect. Essentially a <code>[[$alpha]]</code> for the entire effect. {{note|Since this effect is rendered as a second pass on top of the existing material, you can *not* see through the material when setting this to values less than one. You will instead be seeing the original material behind the flesh effect.}}
$FleshInteriorTexture models/Alyx/alyx_flesh_color ''// Mask in alpha''
+
; <code>$fleshdebugforcefleshon <bool></code>
$FleshNormalTexture models/Alyx/alyx_flesh_normal
+
: If set to 1, shows the flesh rendering pass on the entire model, regardless of the mask specified on the <code>$fleshinteriortexture</code> or the effect targets.
$FleshBorderTexture1D models/Alyx/alyx_flesh_border
+
; <code>$flesheffectcenterradius<1/2/3/4> "[<x float> <y float> <z float> <radius float>]"</code>
$FleshInteriorNoiseTexture engine/noise-blur-256x256
+
: If any of these shader parameters are specified, a flesh effect target is created at the specified location ({{todo|using local or world coordinates?}}) using the specified radius. This functions the same as adding a [[point_flesh_effect_target]] entity.
$FleshSubsurfaceTexture models/Alyx/alyx_flesh_subsurface
+
: {{todo|Can you have more than four [[point_flesh_effect_target]] entities? If not, will these parameters interfere with those entities / override their settings?}}
$FleshCubeTexture          env_cubemap
 
$FleshBorderNoiseScale 3 ''// Flesh Noise UV scalar for border''
 
$FleshBorderWidth 0.2 ''// Width of flesh border''
 
$FleshBorderSoftness 0.5 ''// Border softness must be greater than 0.0 and up tp 0.5''
 
$FleshBorderTint "[.2 .2 .4]" ''// Tint / brighten the border 1D texture''
 
$FleshGlossBrightness 1.0 ''// Change the brightness of the glossy layer''
 
$FleshDebugForceFleshOn 0 ''// DEBUG: This will force on full flesh for testing''
 
$time 0
 
 
Proxies
 
{
 
FleshInterior
 
{
 
}
 
CurrentTime
 
{
 
resultVar $time
 
}
 
}
 
  
 
[[Category:List of Shader Parameters|F]]
 
[[Category:List of Shader Parameters|F]]

Revision as of 05:43, 3 March 2018

The flesh shader in action.

New in the Orange Box: inside-your-body rendering effects!

While it was only used during the cutscene in Half-Life 2: Episode Two where Alyx is revived, it is pretty versatile due to its amount of parameters.

It displays a second rendering pass on top of the base material which can be blended by adding point_flesh_effect_target entities. When your model gets close to the sphere of these entities, the flesh will start to appear.

Note.png Note: The flesh effects will only work when using VertexLitGeneric as your material's shader. Due to this, it only works on models.

Usage

In addition to specifying the essential shader parameters for a VertexLitGeneric material, you have to ensure that your material defines a proxy as such:

 "Proxies"
 {
     "FleshInterior"
     {
     }
 }

This is required to make the shader work, as it has to interact with the world and needs to also animate and update in real-time.

Bug.png Bug: This shader does not get illuminated from dynamic lighting of Source Filmmaker or env_projectedtexture. Ensure that the map lighting suffices and the player can not use their flashlight (or the map doesn't use this kind of lighting) when a model with this material is shown.

Shader Parameters

The following shader parameters allow you to enable and control the flesh effect:

$fleshinteriorenabled <bool>
Enables or disables the flesh effect for the material.
$fleshinteriortexture <texture>
The texture used as a base for rendering the flesh. Its alpha value functions as a mask, whereas a higher alpha value (visible) result in that part of the texture showing flesh when an effect target comes close.
$fleshnormaltexture <texture>
Normal map for the flesh effect.
$fleshbordertexture1d <texture>
A texture similar to those used by $lightwarptexture. To do: Where on the texture is the "inside" or "outside" of the border effect?
Note.png Note: Even when using a fully white border texture and tint, a black tint can still be seen on the border. This is a limitation of the shader and can not be changed.
$fleshsubsurfacetexture <texture>
A texture which is multiplied with the $fleshinteriortexture texture. Use a fully white texture (e.g. vgui/white) to skip this rendering pass.
$fleshsubsurfacetint "[<red float> <green float> <blue float>]"
Allows tinting the $fleshsubsurfacetexture. Default is "[1 1 1]".
$fleshinteriornoisetexture <texture>
Used on the border of the flesh effect, adding a distortion effect on the transition between exterior and interior. Scrolls based on the value of $fleshscrollspeed.
$fleshscrollspeed <float>
Determines how fast the $fleshinteriornoisetexture should scroll.
$fleshbordernoisescale <float>
Changes the scale of the $fleshinteriornoisetexture.
$fleshborderwidth <float>
Determines the width of the border transition between interior and exterior. May change from which camera angles the effect is visible, as well. Must be greater than 0.
$fleshbordersoftness <normal>
Changes how soft the transition between interior and exterior is. Values must be bigger than 0 but no higher than 0.5.
$fleshbordertint "[<red float> <green float> <blue float>]"
Allows tinting the effect border. Default is "[1 1 1]".
$fleshcubetexture <texture>
The cubemap texture to use for reflections on the flesh interior. Accepts values similar to $envmap (including env_cubemap).
$fleshglossbrightness <float>
Changes the strength or brightness of the cubemap reflection (if $fleshcubetexture is specified).

Debugging

Some shader parameters were included to allow for easier debugging, but don't have much use otherwise:

$fleshglobalopacity <normal>
Opacity of the entire flesh effect. Essentially a $alpha for the entire effect.
Note.png Note: Since this effect is rendered as a second pass on top of the existing material, you can *not* see through the material when setting this to values less than one. You will instead be seeing the original material behind the flesh effect.
$fleshdebugforcefleshon <bool>
If set to 1, shows the flesh rendering pass on the entire model, regardless of the mask specified on the $fleshinteriortexture or the effect targets.
$flesheffectcenterradius<1/2/3/4> "[<x float> <y float> <z float> <radius float>]"
If any of these shader parameters are specified, a flesh effect target is created at the specified location (To do: using local or world coordinates?) using the specified radius. This functions the same as adding a point_flesh_effect_target entity.
To do: Can you have more than four point_flesh_effect_target entities? If not, will these parameters interfere with those entities / override their settings?