Multiple Skins for a Single Model: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(adapted from Creating a Material Tutorial's Talk page)
 
(→‎Further annotations: that's really not a solution)
 
(53 intermediate revisions by 22 users not shown)
Line 1: Line 1:
[[Category:Material System]][[Category:Modeling]]
{{LanguageBar}}


Creating multiple skins under one model requires a $texturegroup definition in the.qc file following the $body.
[[File:plasticcrate01.jpg|frame|center|{723x111px|1 model, 5 skins]]In some cases, it can be helpful for a mapper to be able to choose between different skins for the model. It's easy to add more variety to your custom models with multiple skins without creating a totally new model.


'''It must follow the $body definition or else the .qc will simply not compile.
The advantage of having several skins in one model instead of compiling several new models are:
* Easier to find because the model overview isn't cluttered
* Less disk space and in-game model load time
* Faster than compiling a new model for each skin
* Skins can be changed dynamically via the <code>Skin</code> input


''$body studio "models/test/test.smd"


''$texturegroup skinfamilies
__TOC__
{{clr}}
== Basic example with one skin replaced ==


''{
The example here is a lamp that is either on or off, a different skin for each situation will make the model look a lot better.


''{ "test1.vtf" }  
<pre>$modelname mymodelfolder/mylamp.mdl
$cdmaterials modeltextures/mytexturefolder
$surfaceprop metal
$staticprop
$body studio "mylamp.smd"
$texturegroup skinfamilies
{
{ "lampon"  }
{ "lampoff" }
}
$sequence idle "mylamp.smd" fps 1
$collisionmodel "mylamp_phys.smd"</pre>
[[File:lampon_lampoff.jpg|frame|Two skins are used to display the lamp either on or off.]]
{{note|<code>$texturegroup</code> needs to follow <code>$body</code>.}}
{{warning|If you omit the spaces between the brackets and your skin name the compiler will ignore it!}}


''{ "test2.vtf" }
You define your different textures between <code>$texturegroup skinfamilies {</code> and <code>}</code>. The name of the first texture (in this case "lampon") needs to be similar to the texturename you used in your model (If you are not sure, open the [[SMD | .smd]] with a [[text editor]], in the [[SMD file format#Triangle block | triangles block]] you'll find the name). Otherwise <code>studiomdl.exe</code> doesn't know which one to replace.


''}  
In the following lines, you can define the new textures between <code>{</code> and <code>}</code> that will be rendered instead of the original one.{{clr}}


The textures can be named anything as long as you've referenced them correctly in the .qc. 
== Creating Multiple Skin Combinations ==


Each material that you apply to a model can have a seperate propertySo for a character, you'd have a material for their body and then a material for their head, or you could be really fancy and make several clusters, one for each aspect of their make up. So a material for their leather gloves, one for their cloth pants, one for their metal armor, and one for their flesh head. These would all be seperate materials with their own seperate .vmts and such.  However, using multiple materials on the same model creates a significant performance hit, so this should be done sparingly.
In some circumstances, you may choose to divide your model texture into more than one material.  This allows for multiple combinations that otherwise would require a larger amount of individual modelsIf, for example, you wanted to create a light that had two housing styles but three bulb colors, you could create these combinations under the <code>$texturegroup</code>. 
$texturegroup skinfamilies
{
{ "lampnew"    "lightbulbred"  }
{ "lampnew"    "lightbulbgreen" }
{ "lampnew"    "lightbulbblue"  }
{ "lamprusty"  "lightbulbred"  }
{ "lamprusty"  "lightbulbgreen" }
{ "lamprusty"  "lightbulbblue"  }
}
 
Once again, you must ensure that your model uses the material names in the first line.
 
As you can see, creating a matrix of skin combinations has distinct advantages, however, using multiple materials on the same model creates a significant performance hit, so this technique should be used sparingly!
 
== General definition ==
 
Here's a general definition for reference if you have to use several skins:
 
$texturegroup skinfamilies
{
{ "original1"  "original2"  ...  "originalX"  }
{ "replace1_1"  "replace1_2"  ...  "replace1_X" }
{ ...          ...          ...  ...          }
{ "replaceX_1"  "replaceX_2"  ...  "replaceX_X" }
}
 
== Further annotations ==
{{bug|tested={{src13mp}}{{tf2branch}}|Translucent models will only cast the shadows of the first skin, or [[$shadowlod]] if dynamically lit.}}
 
== See also ==
* [[$texturegroup]]
* [[Source_model_skin_editor|Source model skin editor]]
[[Category:Material System]][[Category:Modeling]][[Category:Tutorials]]

Latest revision as of 11:02, 18 June 2025

English (en)Italiano (it)Translate (Translate)
1 model, 5 skins

In some cases, it can be helpful for a mapper to be able to choose between different skins for the model. It's easy to add more variety to your custom models with multiple skins without creating a totally new model.

The advantage of having several skins in one model instead of compiling several new models are:

  • Easier to find because the model overview isn't cluttered
  • Less disk space and in-game model load time
  • Faster than compiling a new model for each skin
  • Skins can be changed dynamically via the Skin input


Basic example with one skin replaced

The example here is a lamp that is either on or off, a different skin for each situation will make the model look a lot better.

$modelname mymodelfolder/mylamp.mdl
$cdmaterials modeltextures/mytexturefolder
$surfaceprop metal
$staticprop
$body studio "mylamp.smd"
$texturegroup skinfamilies
{
	{ "lampon"  }
	{ "lampoff" }
}
$sequence idle "mylamp.smd" fps 1
$collisionmodel "mylamp_phys.smd"
Two skins are used to display the lamp either on or off.
Note.pngNote:$texturegroup needs to follow $body.
Warning.pngWarning:If you omit the spaces between the brackets and your skin name the compiler will ignore it!

You define your different textures between $texturegroup skinfamilies { and }. The name of the first texture (in this case "lampon") needs to be similar to the texturename you used in your model (If you are not sure, open the .smd with a text editor, in the triangles block you'll find the name). Otherwise studiomdl.exe doesn't know which one to replace.

In the following lines, you can define the new textures between { and } that will be rendered instead of the original one.

Creating Multiple Skin Combinations

In some circumstances, you may choose to divide your model texture into more than one material. This allows for multiple combinations that otherwise would require a larger amount of individual models. If, for example, you wanted to create a light that had two housing styles but three bulb colors, you could create these combinations under the $texturegroup.

$texturegroup skinfamilies
{
	{ "lampnew"    "lightbulbred"   }
	{ "lampnew"    "lightbulbgreen" }
	{ "lampnew"    "lightbulbblue"  }
	{ "lamprusty"  "lightbulbred"   }
	{ "lamprusty"  "lightbulbgreen" }
	{ "lamprusty"  "lightbulbblue"  }
}

Once again, you must ensure that your model uses the material names in the first line.

As you can see, creating a matrix of skin combinations has distinct advantages, however, using multiple materials on the same model creates a significant performance hit, so this technique should be used sparingly!

General definition

Here's a general definition for reference if you have to use several skins:

$texturegroup skinfamilies
{
	{ "original1"   "original2"   ...  "originalX"  }
	{ "replace1_1"  "replace1_2"  ...  "replace1_X" }
	{ ...           ...           ...  ...          }
	{ "replaceX_1"  "replaceX_2"  ...  "replaceX_X" }
}

Further annotations

Icon-Bug.pngBug:Translucent models will only cast the shadows of the first skin, or $shadowlod if dynamically lit.  (tested in: Source 2013 MultiplayerTeam Fortress 2 branch)

See also