$texturegroup: Difference between revisions
| Trigger hurt (talk | contribs)  (Major formatting and syntactical improvements to the body text, improved overall clarity, provided more examples, and introduced some new information based on my testing.) | No edit summary | ||
| (33 intermediate revisions by 12 users not shown) | |||
| Line 1: | Line 1: | ||
| {{ | {{LanguageBar|title = $texturegroup}} | ||
| | | {{tabsBar|main=gs|base=$texturegroup}} | ||
| }} | {{this is a|QC command|name=$texturegroup}} | ||
| {{toc-right}} | |||
| It allows a model to have multiple [[skin]]s consisting of one or more materials.<br> | |||
| Alternate skins are typically included in props to  | Alternate skins are typically included in props to allow more variety in model appearances, without needing to create more models. | ||
| [[File:Plasticcrate01.jpg|723x111px|frameless|left]]{{cls}} | |||
| == Syntax == | == Syntax == | ||
|   $texturegroup <name> | |||
|   { |   { | ||
|   	{ "<default material>" } //Skin 0 (default) |   	{ "<default material>" } //Skin 0 (default) | ||
| Line 16: | Line 16: | ||
| ; name | ; name | ||
| : The name of the texturegroup. {{ | : The name of the texturegroup. | ||
| :{{note|A name is required by [[studiomdl]], but it goes entirely unused, being leftover from {{goldsrc}}, where it was the name of the $body or $bodygroup which contained the specified textures. <code>skinfamilies</code> is often used instead.}} | |||
| ; default material | ; default material | ||
| : The name of a [[Material System| | : The name of a [[Material System|material]] ([[VMT]]) on a reference mesh. | ||
| ; new material | ; new material | ||
| : The name of a  | : The name of a material (VMT) that will replace the material above it. | ||
| For models with multiple materials, <code>$texturegroup</code> accepts multiple materials per line. When used like this, the first skin should be treated as a set of column headings in a table. Only materials present in the first skin can change in any subsequent skins. | For models with multiple materials, <code>$texturegroup</code> accepts multiple materials per line. When used like this, the first skin should be treated as a set of column headings in a table. Only materials present in the first skin can change in any subsequent skins. | ||
|   $texturegroup <name> | |||
|   { |   { | ||
|   	{ "<default material 1>" "<default material 2>" [...] } //Skin 0 (default) |   	{ "<default material 1>" "<default material 2>" [...] } //Skin 0 (default) | ||
| Line 32: | Line 33: | ||
|   } |   } | ||
| [[Studiomdl | [[Studiomdl]] allows up to 32 unique materials to exist on a model. This limit is hard-coded, but ''can'' be raised with a [[$texturegroup#External_links|hacked studiomdl]]. | ||
| {{tip|If all you want to do is have a different texture on each skin, simply clone your original VMT (e.g. <code>skin_0.vmt</code>), give it a unique name (e.g. <code>skin_1.vmt</code>), and change its {{ent|$basetexture}} to the path of the new texture.}} | |||
| {{tip|If all you want to do is have a different texture on each skin, simply clone your original VMT (e.g. <code>skin_0.vmt</code>), give it a unique name (e.g. <code>skin_1.vmt</code>), and change its  | {{modernImportant|If not using quotes, you must add whitespace between the braces <code>{}</code> and the material name. <code>{skin_0}</code> will not work, but <code>{"skin_0"}</code> or <code>{ skin_0 }</code> will.}} | ||
| {{ | |||
| == Examples == | == Examples == | ||
| Line 55: | Line 55: | ||
|   } |   } | ||
|   $cdmaterials models\player\hvyweapon | |||
|   $texturegroup skinfamilies |   $texturegroup skinfamilies | ||
|   { |   { | ||
| Line 70: | Line 70: | ||
|   	{ heavy_head_blue_invun eyeball_invun  eyeball_invun  hvyweapon_blue_zombie_invun hvyweapon_blue_zombie_invun       } |   	{ heavy_head_blue_invun eyeball_invun  eyeball_invun  hvyweapon_blue_zombie_invun hvyweapon_blue_zombie_invun       } | ||
|   } |   } | ||
| {{tip|You can use {{ent|$renamematerial}} to temporarily change the default material names when working on your alternate skins instead of continuously switching to them or overriding the default material files.}} | |||
| == Multiple  | {{bug| When the default material in the $texturegroup parameter is not the same as the one referenced in the SMD/DMX, it may bug out and causes every skin to be of the default material referenced in the SMD/DMX. This can be circumvented by renaming the default material using {{ent|$renamematerial}} and using it for the alternate skin. |tested = {{gmod}} }} | ||
| Using more than one <code>$texturegroup</code> is allowed | == Multiple Texture Groups == | ||
| Using more than one <code>$texturegroup</code> is allowed but '''not''' recommended. The behavior of multiple texture groups is unintuitive at best. | |||
| {{bug|The number of skins is determined ''only'' by the first texture group. As such, in order to access the other texture groups, the model's skin number must advance beyond 31 (32 in [[HLMV]]).}} | {{bug|The number of skins is determined ''only'' by the first texture group. As such, in order to access the other texture groups, the model's skin number must advance beyond 31 (32 in [[HLMV]]).}} | ||
| {{bug|Instead of being represented as unique, texture groups are sectioned off into chunks of 32 skins. No more than 32 skins are used on any texture group beyond the first.}} | {{bug|Instead of being represented as unique, texture groups are sectioned off into chunks of 32 skins. No more than 32 skins are used on any texture group beyond the first.}} | ||
| {{bug|Each material that is to be changed by a texture group needs to be present in the first texture group's first skin. As a result, all texture groups must have the same number of materials in their first skin in order for materials to not get swapped around.}} | {{bug|Each material that is to be changed by a texture group needs to be present in the first texture group's first skin. As a result, all texture groups must have the same number of materials in their first skin in order for materials to not get swapped around.}} | ||
| As a result of the above problems, despite what the syntax would imply, using multiple <code>$texturegroup</code> commands will not actually allow multiple states of a model's skins to be switched between, unlike  | As a result of the above problems, despite what the syntax would imply, using multiple <code>$texturegroup</code> commands will not actually allow multiple states of a model's skins to be switched between, unlike {{ent|$bodygroup}}. | ||
| If  | If a model needs to have multiple texture states, they will have to be done by setting up skins in a fashion similar to this: | ||
|   $texturegroup skinfamilies |   $texturegroup skinfamilies | ||
|   { |   { | ||
| Line 89: | Line 90: | ||
|   } |   } | ||
| ==  | == Replacing Material With Material of Same Name From Different Folder == | ||
| To replace a material with a material using the same name from a different folder, add ".." to the replacement material, followed by the new folder name of the replacement material.<br> | |||
| ".." pops the directory your original material is in, allowing you to enter a new folder, similar to {{ent|$popd}}.<br> | |||
| Adding {{ent|$cdmaterials}} lines for the replacement materials locations is not required in this case.<br> | |||
| If you just want to use another material that does not have the same name, you can just use another <code>$CDMaterials</code> line instead. | |||
| Example from the {{l4d2|2}} rescue helicopter: | |||
|  $CDMaterials "models\c2m5_helicopter_extraction\" | |||
|  $TextureGroup "skinfamilies" | |||
|  { | |||
|  	{ "helicopter_news_adj"                "helicopter_news2"                } //helicopter_news2 from models\c2m5_helicopter_extraction\ | |||
|  	{ "..\hybridPhysx\helicopter_news_adj" "..\hybridPhysx\helicopter_news2" } //helicopter_news2 from models/hybridPhysx | |||
|  	{ "..\hybridPhysx\helicopter_army"     "..\hybridPhysx\helicopter_army2" } //Could also add second $cdmaterials line and just use "helicopter_army2" | |||
|  } | |||
| == Further Information == | |||
| * Skin options can also be used to provide {{ent|$bumpmap}}, {{ent|$envmap}}, etc. options for the model in each [[VMT]]. For optimization, See also {{ent|$lod}} and [[LOD Models]]. | |||
| * All alternative VTF textures should follow the same [[UV map]] layout. | * All alternative VTF textures should follow the same [[UV map]] layout. | ||
| * Even though [[studiomdl]] has a hardcoded limit of 32 unique materials, it technically supports up to 1024 total skins, so long as each skin is an arrangement of those 32 materials. | * Even though [[studiomdl]] has a hardcoded limit of 32 unique materials, it technically supports up to 1024 total skins, so long as each skin is an arrangement of those 32 materials. | ||
| Line 97: | Line 114: | ||
| == See also == | == See also == | ||
| * [[Multiple Skins for a Single Model]] | * [[Multiple Skins for a Single Model]] | ||
| *  | * {{ent|$cdmaterials}} | ||
| *  | * {{ent|$renamematerial}} | ||
| * {{ent|$bodygroup}} - Same concept as {{mono|$texturegroup}}, but for submodels | |||
| [[ | ==External links== | ||
| Any of these modifications to studiomdl will allow you to compile with more than 32 materials: | |||
| * [https://github.com/2010kohtep/StdPatch StdPatch] | |||
| * [https://knockout.chat/thread/6801 QuickMdl] | |||
| * [https://cra0.net/blog/posts/archived/2014/studiomdl-2013 Cra0kalo2013] | |||
| * [[NekoMDL]] | |||
Latest revision as of 17:56, 3 August 2025
$texturegroup  is a   QC command  available in all  Source games.
 Source games.
It allows a model to have multiple skins consisting of one or more materials.
Alternate skins are typically included in props to allow more variety in model appearances, without needing to create more models.
Syntax
$texturegroup <name>
{
	{ "<default material>" } //Skin 0 (default)
	{ "<new material>"     } //Skin 1
 	[...]
}
- name
- The name of the texturegroup.
 Note:A name is required by studiomdl, but it goes entirely unused, being leftover from Note:A name is required by studiomdl, but it goes entirely unused, being leftover from , where it was the name of the $body or $bodygroup which contained the specified textures. , where it was the name of the $body or $bodygroup which contained the specified textures.- skinfamiliesis often used instead.
- default material
- The name of a material (VMT) on a reference mesh.
- new material
- The name of a material (VMT) that will replace the material above it.
For models with multiple materials, $texturegroup accepts multiple materials per line. When used like this, the first skin should be treated as a set of column headings in a table. Only materials present in the first skin can change in any subsequent skins.
$texturegroup <name>
{
	{ "<default material 1>" "<default material 2>" [...] } //Skin 0 (default)
	{ "<new material 1>"     "<new material 2>"     [...] } //Skin 1
	[...]
}
Studiomdl allows up to 32 unique materials to exist on a model. This limit is hard-coded, but can be raised with a hacked studiomdl.
 Tip:If all you want to do is have a different texture on each skin, simply clone your original VMT (e.g.
Tip:If all you want to do is have a different texture on each skin, simply clone your original VMT (e.g. skin_0.vmt), give it a unique name (e.g. skin_1.vmt), and change its $basetexture to the path of the new texture. Important:If not using quotes, you must add whitespace between the braces
Important:If not using quotes, you must add whitespace between the braces {} and the material name. {skin_0} will not work, but {"skin_0"} or { skin_0 } will.Examples
$texturegroup rockcliff_cluster01
{
	{ rockcliff02a }
	{ rockcliff02b }
	{ rockcliff02c }
}
$cdmaterials models\bots\sniper models\effects $texturegroup skinfamilies { { sniper_bot_red sniper_bot_head_red } { sniper_bot_blue sniper_bot_head_blue } { invulnfx_red invulnfx_red } { invulnfx_blue invulnfx_blue } }
$cdmaterials models\player\hvyweapon
$texturegroup skinfamilies
{
	{ heavy_head_red        eyeball_r      eyeball_l      hvyweapon_red               hvyweapon_red_sheen               }
	{ heavy_head_blue       eyeball_r      eyeball_l      hvyweapon_blue              hvyweapon_blue_sheen              }
	{ heavy_head_red_invun  eyeball_invun  eyeball_invun  hvyweapon_red_invun         hvyweapon_red_invun               }
	{ heavy_head_blue_invun eyeball_invun  eyeball_invun  hvyweapon_blue_invun        hvyweapon_blue_invun              }
	{ heavy_head_zombie     eyeball_zombie eyeball_zombie heavy_red_zombie_alphatest  heavy_red_zombie_alphatest_sheen  }
	{ heavy_head_zombie     eyeball_zombie eyeball_zombie heavy_blue_zombie_alphatest heavy_blue_zombie_alphatest_sheen }
	{ heavy_head_red_invun  eyeball_invun  eyeball_invun  hvyweapon_red_zombie_invun  hvyweapon_red_zombie_invun        }
	{ heavy_head_blue_invun eyeball_invun  eyeball_invun  hvyweapon_blue_zombie_invun hvyweapon_blue_zombie_invun       }
}
 Tip:You can use $renamematerial to temporarily change the default material names when working on your alternate skins instead of continuously switching to them or overriding the default material files.
Tip:You can use $renamematerial to temporarily change the default material names when working on your alternate skins instead of continuously switching to them or overriding the default material files. Bug: When the default material in the $texturegroup parameter is not the same as the one referenced in the SMD/DMX, it may bug out and causes every skin to be of the default material referenced in the SMD/DMX. This can be circumvented by renaming the default material using $renamematerial and using it for the alternate skin.   (tested in:
Bug: When the default material in the $texturegroup parameter is not the same as the one referenced in the SMD/DMX, it may bug out and causes every skin to be of the default material referenced in the SMD/DMX. This can be circumvented by renaming the default material using $renamematerial and using it for the alternate skin.   (tested in:  )
)Multiple Texture Groups
Using more than one $texturegroup is allowed but not recommended. The behavior of multiple texture groups is unintuitive at best.
 Bug:Instead of being represented as unique, texture groups are sectioned off into chunks of 32 skins. No more than 32 skins are used on any texture group beyond the first.  [todo tested in ?]
Bug:Instead of being represented as unique, texture groups are sectioned off into chunks of 32 skins. No more than 32 skins are used on any texture group beyond the first.  [todo tested in ?] Bug:Each material that is to be changed by a texture group needs to be present in the first texture group's first skin. As a result, all texture groups must have the same number of materials in their first skin in order for materials to not get swapped around.  [todo tested in ?]
Bug:Each material that is to be changed by a texture group needs to be present in the first texture group's first skin. As a result, all texture groups must have the same number of materials in their first skin in order for materials to not get swapped around.  [todo tested in ?]As a result of the above problems, despite what the syntax would imply, using multiple $texturegroup commands will not actually allow multiple states of a model's skins to be switched between, unlike $bodygroup.
If a model needs to have multiple texture states, they will have to be done by setting up skins in a fashion similar to this:
$texturegroup skinfamilies
{
	{ <state 1> <substate 1> }
	{ <state 1> <substate 2> }
	{ <state 2> <substate 1> }
	{ <state 2> <substate 2> }
	[...]
}
Replacing Material With Material of Same Name From Different Folder
To replace a material with a material using the same name from a different folder, add ".." to the replacement material, followed by the new folder name of the replacement material.
".." pops the directory your original material is in, allowing you to enter a new folder, similar to $popd.
Adding $cdmaterials lines for the replacement materials locations is not required in this case.
If you just want to use another material that does not have the same name, you can just use another $CDMaterials line instead.
Example from the  Left 4 Dead 2 rescue helicopter:
 Left 4 Dead 2 rescue helicopter:
$CDMaterials "models\c2m5_helicopter_extraction\"
$TextureGroup "skinfamilies"
{
	{ "helicopter_news_adj"                "helicopter_news2"                } //helicopter_news2 from models\c2m5_helicopter_extraction\
	{ "..\hybridPhysx\helicopter_news_adj" "..\hybridPhysx\helicopter_news2" } //helicopter_news2 from models/hybridPhysx
	{ "..\hybridPhysx\helicopter_army"     "..\hybridPhysx\helicopter_army2" } //Could also add second $cdmaterials line and just use "helicopter_army2"
}
Further Information
- Skin options can also be used to provide $bumpmap, $envmap, etc. options for the model in each VMT. For optimization, See also $lod and LOD Models.
- All alternative VTF textures should follow the same UV map layout.
- Even though studiomdl has a hardcoded limit of 32 unique materials, it technically supports up to 1024 total skins, so long as each skin is an arrangement of those 32 materials.
 Almost every team-colored model in the game has at least two skins. Typically, the default skin is RED, and the second skin is BLU. Almost every team-colored model in the game has at least two skins. Typically, the default skin is RED, and the second skin is BLU.
See also
- Multiple Skins for a Single Model
- $cdmaterials
- $renamematerial
- $bodygroup - Same concept as $texturegroup, but for submodels
External links
Any of these modifications to studiomdl will allow you to compile with more than 32 materials:



























