Infected shader is used in Left 4 Dead 2 to dynamically render wounded zombies and body parts.
Instead of relying on gibbed variations of all models, this shader is used on the models to remove whichever body part was shot at to look more realistic, and allows for adding different types of slashes and dynamic gore and flesh effects.
The model will simply render hollow, however. So the programmer or artist would need to place skeleton and flesh models inside of the holes that were created, in order to create a convincing effect. To do: Add some images from the game or the presentation here.
To do: How does this shader relate to $shinyblood of VertexLitGeneric?
left4dead2/materials/models/infected/common/l4d2/bp_head_include.vmt for a sample material that uses the shader.
- Unlike other shaders, this parameter serves a completely different role. It acts as a mask texture, where each channel serves a different purpose:
- Red*: Detail blend mask
- Green*: Blood blend mask
- Blue: Skin mask
- Alpha*: Eyeglow mask
- Additionally, the vtf is split up similarly to a sprite sheet. All channels marked with a * are affected by this.
- To compensate, scale down these channels to half their size and place them in one of the four quarters of the texture. This allows for more "variations" without using animation frames.
- Determines whether the backsides of faces can be seen. If a model is sliced open, you will see the insides of the model as well.
- Disables dynamic shadows on the model.
- According to a vmt comment: "test stuff, doesn’t do anything right now".
- Unknown. May be related to RTT shadow rendering. Default value is 0, setting to 1 changes shader combination and renders the model as white.
- Unknown. Possibly allows for a translucent render pass.
- Unknown. Possibly related to wounds.
- Unknown. Possibly controlled using code?
- Enables ambient occlusion on the model (for example in Source Filmmaker).
The most interesting part of this shader is the wound calculation. Set
$wounded 1 to enable it.
To debug the wounds, you can use following shader parameters:
- Enables debugging ellipsoids. These can be positioned using other shader parameters to mess with the effect.
- There are two debugging ellipsoids with different functionality. Only the second one is currently known to work: it bursts a hole into the model where it intersects.
- Leaving out the 2 from the next four shader parameters controls the ellipsoid 1, but no effects could be seen.
- Center of the ellipsoid 2, in local space (0 0 0 should be the entity's origin).
- The up axis of ellipsoid 2. Z-up (0 0 1) by default.
- The direction that the ellipsoid 2 faces.
- The size of the ellipsoid 2, in local coordinates.
- Unknown. 0 seems to be regular culling of ellipsoid 2, other values disable the ellipsoid. (This parameter does not exist for ellipsoid 1.)
The following shader parameters are unknown in function, but seem to be related to the wound rendering. They do not seem to influence the debugging ellipsoid culling at all.
- Texture containing masks for blood and shapes of the wounds.
- When the cutout texture should mask the wound. Values below 0.5 hide the entire model when using debugging ellipsoids.
- See the relevant articles for these commands. They function identically to VertexLitGeneric's counterparts. However, $phongexponent related options do not work. See below for replacement options.
- Equivalent to $phongexponent, except for any unmasked parts of the texture.
The detail pass is controlled by the red channel of the $basetexture. Unlike other textures in Source, this texture is actually transformed differently.
In order to convert a regular $basetexture to the equivalent $detail texture (with same UV mapping), you will need to:
- Take the original vtf file
- Mirror it horizontally
- Rotate it by 90° counter-clockwise
- Use a $detailscale of 1
Besides these parameters, $detailframe and $detailblendfactor are also supported.
To do: How is the alpha channel handled?
To do: Is the $basetexture transformed like this as well?
The skin pass is controlled by the blue channel of the $basetexture. It also is the only channel that does not allow for variation using texture indexes (see below).
- Unknown. Possibly controlled using code?
- Equivalent to $phongexponent, except for skin parts of the texture (blue channel).
The blood pass is controlled by the green channel of the $basetexture.
- Color of the blood pass. To do: Is this multiplied with anything, or just overlaid as it is?
- Equivalent to $phongexponent, except for blood parts of the texture (green channel).
- To do: Does this increase or set the $phongboost of bloody parts?
- Unknown. Seems to modify the phong shape on blood.
- Controls whether the material should appear burning. Does not seem to do anything.
- Opacity of the burning effect. Defaults to 0.
- Unknown. Most likely the texture to use for the burning effect, implemented similarly to how Team Fortress 2 handles burning models (overlaying a $detail texture).
The eyeglow pass is controlled by the alpha channel of the $basetexture.
- Set to 1 to enable the effect. Causes an additive color overlay, as well as different phong settings.
- Color of the effect.
- Phong boost for the effect, in case the model is hit by projected texture lighting such as the flashlight.
Since Source Filmmaker version 0.9.8.9 (released 27 Aug, 2014), the Infected shader is supported and integrated into the program.
Creating an animation set with the shader will automatically generate the following attributes as part of the DmeGameModel:
- Unknown. May be related to the gradient texture controls.
- Controls which of the four quarters of the $basetexture get selected for display (see above for detailed information).
- 0 is top left, 1 is top right, 2 is bottom left, 3 is bottom right.