Difference between revisions of "$texturegroup"

From Valve Developer Community
Jump to: navigation, search
m (whoops, poor wording.)
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
 
|fr=$texturegroup:fr
 
|fr=$texturegroup:fr
 
}}
 
}}
Creates a set of replacement materials used on a model. It is used to add alternative "skin" options for the model.
+
The <code>[[$texturegroup]]</code> [[QC command]] allows a model to have multiple [[Skin|skins]] consisting of one or more materials.
  
* If no <code>$texturegroup</code> is specified, the model's VMT must be the name of the texture which was [[UV map]]ped onto the reference .SMD.
+
Alternate skins are typically included in props to give the level designer more variety, but may serve a gameplay purpose depending on the specific use.
  
* The <code>$texturegroup</code> command should follow after the [[$body]] in the .qc.
+
== Syntax ==
 +
 
 +
[[$texturegroup]] <name>
 +
{
 +
{ "<default material>" } //Skin 0 (default)
 +
{ "<new material>"    } //Skin 1
 +
  [...]
 +
}
 +
 
 +
; name
 +
: The name of the texturegroup. {{bug|A name is required by [[studiomdl]], but it goes entirely unused. <code>skinfamilies</code> is often used instead.}}
 +
; default material
 +
: The name of a [[Material System|Material]] ([[VMT]]) on a reference mesh.
 +
; new material
 +
: The name of a [[Material System|Material]] ([[VMT]]) that will replace the material above it.
  
== Basic syntax ==
 
  
  [[$texturegroup]] "<name>"
+
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>
 
  {
 
  {
    { "<skin_0>" }
+
{ "<default material 1>" "<default material 2>" [...] } //Skin 0 (default)
    { "<skin_1>" }
+
{ "<new material 1>"     "<new material 2>"    [...] } //Skin 1
 +
[...]
 
  }
 
  }
  
Where
+
[[Studiomdl|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.
* '''<name>''' is the name of the texturegroup. Even though a name string is required for [[studiomdl]] to compile it is not stored within the binary.
+
{{warning|Increasing the limit beyond 32 will usually cause the engine to crash at random with "Memory could not be read" errors.}}
* '''<skin_0>''' is the name of the default [[Material System|Material]] ([[VMT]]) file.
+
{{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 <code>[[$basetexture]]</code> to the path of the new texture.}}
* '''<skin_1>''' is the name of the alternative [[Material System|Material]] ([[VMT]]) file.
+
{{bug|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> will.}}
* Allows up to a maximum of 32 alternate material sets. Limit hard coded by [[studiomdl]].
+
 
{{note|More alternative material sets ''can'' be added with a hacked studiomdl. However, the engine will randomly crash with "Memory could not be read" errors.}}
+
== Examples ==
{{tip|If all you want to do is have a different texture on each skin, simply clone the ''skin_0.vmt'', rename it ''skin_1.vmt'' and change the [[$basetexture]] reference to the ''new_colormap.vtf''. Make sure the ''skin_1.vmt'' and ''new_colormap.vtf'' files are placed in the appropriate subfolder of the <code>game_dir/materials/models/</code> directory.}}
+
$texturegroup rockcliff_cluster01
{{bug|You must add spaces between the {} and the "". Adding a new skin with {"skin0"} will not work, but { "skin0" } will.}}
+
{
 +
{ 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        }
 +
}
  
== Example ==
+
[[$cdmaterials]] models\player\hvyweapon
  $texturegroup "rockcliff_cluster01"
+
  $texturegroup skinfamilies
 
  {
 
  {
  { "rockcliff02a" }
+
  { heavy_head_red        eyeball_r      eyeball_l      hvyweapon_red              hvyweapon_red_sheen              }
  { "rockcliff02b" }
+
  { heavy_head_blue      eyeball_r      eyeball_l      hvyweapon_blue              hvyweapon_blue_sheen              }
  { "rockcliff02c" }
+
 +
{ 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      }
 
  }
 
  }
  
== Advanced syntax ==
+
== Multiple texture groups ==
For models with multiple materials, <code>$texturegroup</code> can also be used to specify their replacements by specifying multiple materials per line.
+
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|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.}}
 +
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 <code>[[$bodygroup]]</code>.
  
  $texturegroup "YourTextureGroupNameHere"
+
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
 
  {
 
  {
  { "<skin_0_material1>" "<skin_0_material2>" }
+
  { <state 1> <substate 1> }
  { "<skin_1_material1>" "<skin_1_material2>" }
+
  { <state 1> <substate 2> }
 +
{ <state 2> <substate 1> }
 +
{ <state 2> <substate 2> }
 +
[...]
 
  }
 
  }
  
 
== Further information ==
 
== Further information ==
* Skin options can also be used to provide <code>$bumpmap</code>, <code>$surfaceprop</code>, etc. options for the model in each [[VMT]]. For optimization, see also [[$lod]] and [[LOD Models]].
+
* Skin options can also be used to provide <code>[[$bumpmap]]</code>, <code>[[$surfaceprop]]</code>, etc. options for the model in each [[VMT]]. For optimization, see also <code>[[$lod]]</code> 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.
* One of the skins in the list '''''must''''' be the texture name which was in the SMD. Without this the skins will  only use the texture name from the SMD, and not ones from your list.
+
* 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.
 +
* {{tf2}} 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 ==
 
== See also ==
 
* [[Multiple Skins for a Single Model]]
 
* [[Multiple Skins for a Single Model]]
 +
* [[$cdmaterials]]
 +
* [[$renamematerial]]
  
 
[[Category:QC Commands|texturegroup]]__NOTOC__
 
[[Category:QC Commands|texturegroup]]__NOTOC__

Latest revision as of 06:50, 18 November 2019

Français

The $texturegroup QC command allows a model to have multiple skins consisting of one or more materials.

Alternate skins are typically included in props to give the level designer more variety, but may serve a gameplay purpose depending on the specific use.

Syntax

$texturegroup <name>
{
	{ "<default material>" } //Skin 0 (default)
	{ "<new material>"     } //Skin 1
 	[...]
}
name
The name of the texturegroup.
Bug: A name is required by studiomdl, but it goes entirely unused. skinfamilies is 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. Warning: Increasing the limit beyond 32 will usually cause the engine to crash at random with "Memory could not be read" errors.

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.
Bug: You must add whitespace between the braces {} and the material name. {skin_0} will not work, but { 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       }
}

Multiple texture groups

Using more than one $texturegroup 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: 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.

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> }
	[...]
}

Further information

  • Skin options can also be used to provide $bumpmap, $surfaceprop, 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.
  • <Team Fortress 2> 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