Multiple Skins for a Single Model: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(Major overhaul because several ppl had problems at VERC: Easy, simplified examples, longer explenations, complete .qc example)
Line 1: Line 1:
[[Category:Material System]][[Category:Modeling]]{{stub}}
[[Category:Material System]][[Category:Modeling]][[Category:Tutorials]]
Creating multiple skins under one model requires a $texturegroup definition in the.qc file following the $body.
In some cases it can be helpful for a mapper if he can choose between different skins for the model. It's easy to add more variety to your custom models with multiple skins without as much work as creating a totally new model and skin.


'''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:
<pre>
* easier to find because the model overview isn't cluttered
$body studio "models/test/test.smd"
* less disc space and ingame model load
$texturegroup skinfamilies
* faster than compiling a new model for each skin
 
 
__TOC__
 
== 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.
 
<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>
 
{{note|<code>$texturegroup</code> needs to follow <code>$body</code>.}}
 
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.
 
== Example with two skins replaced several times ==
 
If your model does have several textures, you can replace all of those. Here's another example: You got a lamp in which you want to insert either a red, green or blue lightbulb. However the lamp itself can either be new or old and rusty.
 
<pre>$texturegroup skinfamilies{
{ "lampnew", "lightbulbred" }
{ "lampnew", "lightbulbgreen" }
{ "lampnew", "lightbulbblue" }
{ "lamprusty", "lightbulbred" }
{ "lamprusty", "lightbulbgreen" }
{ "lamprusty", "lightbulbblue" }
}</pre>
 
Once again you have to make sure that your model uses the material names in the first line.
 
However, using multiple materials on the same model creates a significant performance hit, so this should be done sparingly!
 
== General definition ==
 
Here's a general definition for reference if you have to use several skins:
 
<pre>$texturegroup skinfamilies
{
{
     {  "original1.vtf",      "original2.vtf",      ...,      "originalX.vtf" }
     {  "original1.vtf",      "original2.vtf",      ...,      "originalX.vtf" }
Line 11: Line 59:
     {            "...",                "...",      ...,                "..." }
     {            "...",                "...",      ...,                "..." }
     { "replaceX_1.vtf",      "replaceX_2.vtf",      ...,      "replaceX_X.vtf" }
     { "replaceX_1.vtf",      "replaceX_2.vtf",      ...,      "replaceX_X.vtf" }
}
}</pre>
</pre>


{{note|Translucent models will only cast the shadows of the first skin}}
== Further annotations ==


The textures can be named anything as long as you've referenced them correctly in the .qc. 
* Translucent models will only cast the shadows of the first skin


Each material that you apply to a model can have a separate property.  So 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 separate materials with their own separate .vmts and such.  However, using multiple materials on the same model creates a significant performance hit, so this should be done sparingly.
With the use of $shadowlod you should be able to address the problem

Revision as of 00:39, 31 March 2006

In some cases it can be helpful for a mapper if he can choose between different skins for the model. It's easy to add more variety to your custom models with multiple skins without as much work as creating a totally new model and skin.

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 disc space and ingame model load
  • faster than compiling a new model for each skin


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"
Note.pngNote:$texturegroup needs to follow $body.

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.

Example with two skins replaced several times

If your model does have several textures, you can replace all of those. Here's another example: You got a lamp in which you want to insert either a red, green or blue lightbulb. However the lamp itself can either be new or old and rusty.

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

Once again you have to make sure that your model uses the material names in the first line.

However, using multiple materials on the same model creates a significant performance hit, so this should be done sparingly!

General definition

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

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

Further annotations

  • Translucent models will only cast the shadows of the first skin

With the use of $shadowlod you should be able to address the problem