Wrinkle maps: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
 
(17 intermediate revisions by 10 users not shown)
Line 1: Line 1:
[[Image:Valve_l4d2_wrinkle.png|thumb|200px|Coach's wrinklemap from Left4Dead2.]]
{{LanguageBar|Wrinkle maps|title=Wrinkle Maps}}
[[File:Wrinkle mapping.jpg|thumb|Wrinkle maps add fine detail to the forehead.]]


WrinkleMaps are texture maps that accompany wrinkles in low polygon models for games. Since there is a limit to the amount of polygons a model can be for game engines artists bake out these so called wrinklemaps from the high polygon meshes and utilize them in the engine to produce the same render as if it was a high polygon model. This same concept is also done with normalmaps and is very useful in game engines.
[[Wrinkle maps]] are a component of [[DMX model|DMX]] [[Flex animation|flex shapes]] used by the {{ent|VertexLitGeneric}} shader to make per-vertex [[texture]] changes when the flex shape is applied. They were introduced in {{Src07|4}}.
Source has no documentation of wrinklemaps so I have decided to write this article to help other people understand the concept and learn how to go about producing them for Source.


{{note|WrinkleMaps can only work with models that get compiled from .dmx files.}}
They are typically used to add fine wrinkling detail to a character's skin.
{{note|DMXEDIT.exe will need to be used to author them (found in the SFM SDK)}}


The term "wrinkle map" is confusing, because it can refer to the act of adding ''or removing'' wrinkles. The terms "compress" and "stretch" are used to refer to these two effects.


== The WrinkleMap diference ==
{{Warning|{{hlmvpp|4}} (at least the L4D2 version) often times does not show wrinkle maps on custom models, while the default {{hlmv|4}} does show them just fine.}}
== Generation ==
Wrinkle maps are generated programmatically before a model is compiled. The important value is the wrinkle "scale," which defines the upper limit of wrinkling. A scale of 1 means that only the vert which moves the furthest is fully wrinkled; a scale of 2 means that the top 50% of moving verts are fully wrinkled.
* Positive wrinkle scales lead to the compress texture being applied.
* Negative wrinkle scales lead to the stretch texture being applied.


Here is a picture showing the difference of utilizing this feature.
It isn't possible for a single shape to both stretch and compress; if that effect is needed, make a flex controller which wraps multiple shapes.
[[Image:Wrinklemaps_src_small.png|centre|900px]]
As you can see in the left picture the creases on his left cheek and forehead as apposed to the one without wrinkles.


== Textures ==
===<tt>dmxedit</tt>===
Wrinklemaps in Source work with two different textures you can examples inside the [[Left 4 Dead]] files located at <code>L4D root/materials/models/survivors/coach/</code>
The official SDK tool for creating wrinkle maps is {{ent|dmxedit}}. It is run on an exported DMX using a simple [[w:Lua (programming language)|Lua]] script like this:
[[Image:Diffuse_on.png|centre|300px]]
[[Image:Normal_on.png|centre|300px]]


<source lang=lua>
Load("C:/heavy_morphs_high.dmx")


== Using WrinkleMaps ==
SetWrinkleScale("BrowInV", "WrinkleNose", -0.5) -- controller name, shape name, scale
SetWrinkleScale("BrowInV", "RaiseBrowIn", 2)
-- etc.


=== Example VMT Syntax ===
ComputeWrinkles()
The following example is taken from one of the characters that will be shown in [http://alleyproject.net AlleyProject]
<pre>
"vertexlitgeneric"
{
"$compress" "models/cra0kalo/kovic/Kovic_compress"
"$stretch" "models/cra0kalo/kovic/Kovic_stretch"
"$bumpcompress" "models/cra0kalo/kovic/Kovic_normal_compress"
"$bumpstretch" "models/cra0kalo/kovic/Kovic_normal_stretch"
}
</pre>


=== VMT Parameters ===
Save("C:/heavy_morphs_high.dmx")
The following is a list of VMT parameters that are needed to enable the WrinkleMaps:
</source>
:<code>$compress "path/to/vtf"</code> -Compression wrinklemap diffuse
:<code>$stretch "path/to/vtf"</code>  -Expansion wrinklemap diffuse
:<code>$bumpcompress "path/to/vtf"</code> -Compression wrinklemap normal
:<code>$bumpstretch "path/to/vtf"</code> -Expansion wrinklemap normal


=== Other VMT Params ===
If you are using {{sfm|2}}, you will find a collection of helper files at <tt>SourceFilmmaker\game\sdktools\lua\</tt>. These can be used to set up your model in the same way as Valve's.


<pre>
=== {{blender|4}} Source Tools ===
// ------------------------------------
The [[Blender Source Tools]] can generate wrinkle maps when exporting your model. Enable [[Blender SMD Tools Help#Flex properties|Advanced flex mode]], generate a flex controller block, and set a non-zero <code>wrinkleScales</code> value in the relevant flex controller definitions.
// Displacement Maps
// ------------------------------------
// Displacement map
"$displacementmap" "models/cra0kalo/basetexture"
// Displacement map contains wrinkle displacements
"$displacementwrinkle" "0" //boolean


=== Wall Worm Model Tools ===
[[Wall Worm Model Tools]] can now export wrinkle maps. Simply add a Vertex Paint Modifier to any morph target and name it "wrinkle." Paint the wrinkle weights into that vertex paint. Black is full compress. White is full stretch. Gray is no stretch or compress.


</pre>
You can find the [http://dev.wallworm.com/document/162/wrinklemaps.html docs and a tutorial on doing wrinklemaps in 3ds Max here].


== References ==
== Materials and Textures ==
[[File:Valve_l4d2_wrinkle.png|thumb|A <code>$compress</code> texture from {{l4d2|2}}.]]


*[http://www.youtube.com/watch?v=yrzAeZyogbU Source Engine WrinkleMaps HWM [SFM]]
Implementing wrinkle maps requires a {{ent|VertexLitGeneric}} material with {{ent|$phong}} enabled.


There are four shader parameters involved:
{{MatParamDef|$compress|texture|}}
{{MatParamDef|$stretch|texture|Textures which are applied when a flex controller compresses or stretches the mesh.}}
{{MatParamDef|$bumpcompress|texture|}}
{{MatParamDef|$bumpstretch|texture|Optional [[bump map]] textures for <code>$compress</code> and <code>$stretch</code>.}}


[[Category:Source]]


 
[[Category:Modeling]]
[[Category:List of Shader Parameters|A]]
[[Category:VMT Lighting]]

Latest revision as of 11:45, 23 August 2025

English (en)Translate (Translate)
Wrinkle maps add fine detail to the forehead.

Wrinkle maps are a component of DMX flex shapes used by the VertexLitGeneric shader to make per-vertex texture changes when the flex shape is applied. They were introduced in Source 2007 Source 2007.

They are typically used to add fine wrinkling detail to a character's skin.

The term "wrinkle map" is confusing, because it can refer to the act of adding or removing wrinkles. The terms "compress" and "stretch" are used to refer to these two effects.

Warning.pngWarning:HLMV++ HLMV++ (at least the L4D2 version) often times does not show wrinkle maps on custom models, while the default HLMV HLMV does show them just fine.

Generation

Wrinkle maps are generated programmatically before a model is compiled. The important value is the wrinkle "scale," which defines the upper limit of wrinkling. A scale of 1 means that only the vert which moves the furthest is fully wrinkled; a scale of 2 means that the top 50% of moving verts are fully wrinkled.

  • Positive wrinkle scales lead to the compress texture being applied.
  • Negative wrinkle scales lead to the stretch texture being applied.

It isn't possible for a single shape to both stretch and compress; if that effect is needed, make a flex controller which wraps multiple shapes.

dmxedit

The official SDK tool for creating wrinkle maps is dmxedit. It is run on an exported DMX using a simple Lua script like this:

Load("C:/heavy_morphs_high.dmx")

SetWrinkleScale("BrowInV", "WrinkleNose", -0.5) -- controller name, shape name, scale
SetWrinkleScale("BrowInV", "RaiseBrowIn", 2)
-- etc.

ComputeWrinkles()

Save("C:/heavy_morphs_high.dmx")

If you are using Source Filmmaker Source Filmmaker, you will find a collection of helper files at SourceFilmmaker\game\sdktools\lua\. These can be used to set up your model in the same way as Valve's.

Blender Blender Source Tools

The Blender Source Tools can generate wrinkle maps when exporting your model. Enable Advanced flex mode, generate a flex controller block, and set a non-zero wrinkleScales value in the relevant flex controller definitions.

Wall Worm Model Tools

Wall Worm Model Tools can now export wrinkle maps. Simply add a Vertex Paint Modifier to any morph target and name it "wrinkle." Paint the wrinkle weights into that vertex paint. Black is full compress. White is full stretch. Gray is no stretch or compress.

You can find the docs and a tutorial on doing wrinklemaps in 3ds Max here.

Materials and Textures

A $compress texture from Left 4 Dead 2 Left 4 Dead 2.

Implementing wrinkle maps requires a VertexLitGeneric material with $phong enabled.

There are four shader parameters involved:

Todo: This material shader parameter has not been described.
Textures which are applied when a flex controller compresses or stretches the mesh.
Todo: This material shader parameter has not been described.
Optional bump map textures for $compress and $stretch.