This article's documentation is for anything that uses the Source engine. Click here for more information.

StudioMDL (Source): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Specified/Corrected CS:GO's level of support for FBX)
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified)
 
(45 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{otherlang2|ru=Studiomdl:ru|es=Studiomdl:es}}
{{LanguageBar}}
:''For a guide to studiomdl's usage, see [[Compiling a model]].''
{{src topicon}}
{{tabs|StudioMDL|goldsrc=1|source=1}}


{{for|a guide to studiomdl's usage|[[Compiling a model]]}}
{{toc-right}}
{{toc-right}}
{{sm|4}} is the [[command-line]] tool used to compile [[model]]s from intermediate formats exported from modeling packages to the binary .mdl format that is read by the Source engine.


'''Studiomdl''' is the [[command-line]] tool used to compile [[model]]s from intermediate formats exported from modeling packages to the binary .mdl format that is read by the Source engine.
It can be found at {{file|<nowiki>common\<gamename>\<gamefolder>\bin\studiomdl</nowiki>|exe}}.


It can be found at <code>"common\<gamename>\<gamefolder>\bin\studiomdl.exe"</code>.
{{tip|The name "studio" is a throwback to the development of {{hl|2}}, during which Valve used [[3D Studio Max]] to create their models.}}
 
{{bug|hidetested=1|Attempting to use Studiomdl or a shortcut of it pinned to the taskbar in Windows 8 will result in an invalid target path, even when {{mono|-game}} and an associated path are specified. Using a shortcut on the desktop, however, still works. This is an issue on Microsoft's end, unfortunately.}}
{{tip|The name "studio" is a throwback to the development of [[Half-Life 1]], during which Valve used [[3D Studio Max]] to create their models.}}
{{Bug|hidetested=1|64-bit version of StudioMDL from the {{tf2branch|1}} is currently broken.}}
{{bug| Attempting to use Studiomdl or a shortcut of it pinned to the taskbar in Windows 8 will result in an invalid target path even when -game and an associated path is specified. However using a shortcut on the desktop still works. This is an issue on Microsoft's end unfortunately.}}
{{codenote|Source code for an older version is available in the [https://github.com/Source-SDK-Archives/source-sdk-2006-ep1/tree/master/utils/studiomdl 2006 SDK].}}


== Parameters ==
== Parameters ==
 
The only parameter required is a [[QC|QC file]]. Any others must come ''before'' it.
The only parameter required is a [[Qc|QC file]]. Any others must come ''before'' it.


  studiomdl [options] <path\QC>
  studiomdl [options] <path\QC>


=== General ===
=== General ===
 
;{{mono|-game <gamedir>}}
;<code>-game <gamedir></code>
:Override the VProject game path.
:Override the VProject game path.
;<code>-quiet</code>
;{{mono|-quiet}}
:Suppresses <i>some</i> console output, such as spewing the searchpaths.   
:Suppresses ''some'' console output, such as spewing the searchpaths.   
;<code>-x360</code>
;{{mono|-x360}}
:Enable Xbox 360 output, overriding the [[Gameinfo.txt]]
:Enable Xbox 360 output, overriding the {{ent|Gameinfo.txt}}.
;<code>-nox360</code>
;{{mono|-nox360}}
:Disable Xbox 360 output, overriding the [[Gameinfo.txt]]
:Disable Xbox 360 output, overriding the {{mono|Gameinfo.txt}}. Implied by default in non-{{l4d}}-based branches of Source.
;<code>-nowarnings</code>
;{{mono|-nowarnings}}
:Disable warnings.
:Disable warnings.
;<code>-maxwarnings <[[int]]></code>
;{{mono|-maxwarnings <[[int]]>}}
:Print no more than the specified number of warnings.
:Print no more than the specified number of warnings.


=== Animation ===
=== Animation ===
 
; {{mono|-definebones}}
; <code>-definebones</code>
: See {{ent|$definebone}}.
: See [[$definebone]].
; {{mono|-printbones}}
; <code>-printbones</code>
: Writes extra bone info to the console.
: Writes extra bone info to the console.
; <code>-printgraph</code>
; {{mono|-printgraph}}
: {{Todo|Appears to dump xnode data for each node?}}
: {{Todo|Appears to dump xnode data for each node?}}
; <code>-overridedefinebones</code>
; {{mono|-overridedefinebones}}
: Equivalent to specifying [[$unlockdefinebones]] in QC.
: Equivalent to specifying {{ent|$unlockdefinebones}} in QC.
; <code>-checklengths</code>
; {{mono|-checklengths}}
: Prints engine-ready keyframe data for each animation.
: Prints engine-ready keyframe data for each animation.


=== Performance ===
=== Performance ===
 
; {{mono|-fastbuild}}
; <code>-fastbuild</code>
: Skip processing {{mono|.sw.vtx}} (DX6/DX7), {{mono|.dx80.vtx}}, and {{mono|.360.vtx}} variants (use {{mono|.dx90.vtx}} only). This speeds up compiling.
: Skip processing DX7, DX8, X360, and software VTX variants (use .dx90.vtx only). This speeds up compiling.
: {{important|In games before {{l4d}}, if the {{mono|.dx80.vtx}} is absent for a [[static prop]], [[VRAD]] will fail to generate lighting for that prop!}}
; <code>-preview</code>
; {{mono|-preview}}
: Skip splitting quads into tris. This changes the rendering flags for the model, most likely resulting in slower performance or buggier rendering in-engine.
: Skip splitting quads into tris and building tristrips. This changes the rendering flags for the model, most likely resulting in slower performance or buggier rendering in-engine.
; <code>-fullcollide</code>
; {{mono|-fullcollide}} {{src06|only}}
: Don't truncate really big [[collision mesh]]es (Ep1 only; OB uses [[$maxconvexpieces]]).
: Don't truncate really big [[collision mesh]]es  
; <code>-striplods</code>
:{{note|{{src07|since}} use {{ent|$maxconvexpieces}}, as -fullcollide does nothing.}}
: Ignore all [[$lod]] commands.
; {{mono|-striplods}}
;<code>-minlod <lod></code>
: Ignore all {{ent|$lod}} commands.
:Throw away data from LODs above the given one (see [[$minlod]]).
;{{mono|-minlod <lod>}}
;<code>-mdlreport <path\model.mdl></code>
:Throw away data from LODs above the given one (see {{ent|$minlod}}).
;{{mono|-mdlreport <path\model.mdl>}}
;{{mono|-perf <path\model.mdl>}}
:Report performance info for an already-compiled model. A QC file is not needed when using this command.
:Report performance info for an already-compiled model. A QC file is not needed when using this command.
;<code>-perf <path\model.mdl></code>
;{{mono|-mdlreportspreadsheet}}
:Same as '''-mdlreport'''.
:Report performance info, per-LOD, as a comma-delimited spreadsheet. It will appear in the form:
;<code>-mdlreportspreadsheet</code>
:Report performance info, per LOD, as a comma-delimited spreadsheet. It will appear in the form:
:<source>Path to VTX, VTX file extension, LOD number (1 is the root lod), tri count, number of batches rendered, number of materials used </source>
:<source>Path to VTX, VTX file extension, LOD number (1 is the root lod), tri count, number of batches rendered, number of materials used </source>
:'''Must be used with -mdlreport or -perf!''' {{Note|It doesn't actually <i>write</i> a spreadsheet to disk.}}
:'''Must be used with -mdlreport or -perf!'''
:{{Note|It doesn't actually ''write'' a spreadsheet to disk; use {{code|>}} to {{w|Redirection_(computing)#Basic|pipe output}} to a CSV file.}}


=== Debug ===
=== Debug ===
 
;{{mono|-d}}
;<code>-d</code>
:Dumps various [[glview]] files (10 per LOD per VTX file),
:Dumps various [[glview]] files (10 per LOD per VTX file),
;<code>-h</code>
;{{mono|-h}}
:Dump [[hitbox]]es to console.
:Dump [[hitbox]]es to console.
;<code>-n</code>
;{{mono|-n}}
:Tag bad normals.
:Tag bad normals.
;<code>-dumpmaterials</code>
;{{mono|-dumpmaterials}}
:Dump names of used materials to the console.
:Dump names of used materials to the console.
;<code>-i</code>
;{{mono|-i}}
:Ignore warnings.
:Ignore warnings.
;<code>-t</code>
;{{mono|-t <[[material]]>}}
:Replaces all materials with the default pink check pattern
:Replaces all materials with the specified material.
;<code>-parsecompletion</code>
;{{mono|-parsecompletion}}
:Prints an easily parseable message indicating whether the compile was successful or a failure.
:Prints an easily parseable message indicating whether the compile was successful or a failure.
;<code>-collapsereport</code>
;{{mono|-collapsereport}}
:Prints info on which bones are being retained and which bones are being collapsed.
:Prints info on which bones are being retained and which bones are being collapsed.


=== Other ===
=== Other ===
 
;{{mono|-nop4}}
;<code>-nop4</code>
:Disables Valve's Perforce integration. Unless you actually have Perforce set up for your game/mod (a highly unlikely scenario), you should use this.
:Disables Valve's Perforce integration. Unless you actually have Perforce set up for your game/mod (a highly unlikely scenario), you should use this.
;<code>-verify</code>
;{{mono|-verify}}
:Compile the model, but don't actually write the results to disk.
:Compile the model, but don't actually write the results to disk.
;<code>-a <normal_blend_angle></code>
;{{mono|-a <normal_blend_angle>}}
:Auto-smooth faces equal to or below specified angle. Will override normal data for all meshes.
:Auto-smooth faces equal to or below specified angle in degrees. By default, Studiomdl blends normals that are 2 degrees or less apart. Will override normal data for all meshes.
;<code>-f</code>
;{{mono|-f}} {{src07|removed}}
:Flip all triangles.
:Flip all triangles.
:{{bug|Does not work in Orangebox and later builds of Studiomdl. You can achieve the same behavior with [[$body]], however.}}
:{{bug|hidetested=1|Does not work in Orange Box and later builds of Studiomdl. You can achieve the same behavior with {{ent|$body}}, however.}}
;<code>-vsi <path\[QC|MDL]></code>
;<tt>-vsi <path\[QC|MDL]></tt>
:Generates a [[VSI]] file from a [[QC]] or [[MDL]].
:Generates a [[VSI]] file from a [[QC]] or [[MDL]].
;<code>-stripmodel <path\model.mdl></code>
;{{mono|-stripmodel <path\model.mdl>}}
:Strips down a model, removing its LOD info.
:Strips down a model, removing its LOD info.
;<code>-stripvhv <path\sp_hdr_x.vhv></code>
;{{mono|-stripvhv <path\sp_hdr_x.vhv>}}
:Strips down hardware verts ([[VHV]]) of their LOD info.
:Strips down hardware verts ([[VHV]]) of their LOD info.
;<code>-makefile</code>
;{{mono|-makefile}}
:Generates a simple makefile for later compiling. It also parses the QC for any errors, and runs in <code>-quiet</code> mode.
:Generates a simple makefile for later compiling. It also parses the QC for any errors, and runs in {{mono|-quiet}} mode.
;<code>-basedir <path></code>
;{{mono|-basedir <path>}}
:Runs studiomdl in the context of the provided path.
:Runs studiomdl in the context of the provided path.
;<code>-tempcontent <path></code>
;{{mono|-tempcontent <path>}}
:Adds the provided path as a content search path.
:Adds the provided path as a content search path.


=== Nonfunctional ===
=== Nonfunctional ===
 
;{{mono|-r}}
;<code>-r</code>
:In {{goldsrc}}, tagged reversed normals in compile output console; example: triangle reversed (0.748195 0.949818 0.839380)
:"Tag reversed".  
;{{mono|-ihvtest}}
;<code>-ihvtest</code>
:Probably meant to test the model collision for any physics errors. Skips whatever argument is provided after it.
:Probably meant to test the model collision for any physics errors. Skips whatever argument is provided after it.


== Input Files ==
== Input Files ==
StudioMDL supports a range of input formats. These include [[Studiomdl Data|SMD]], [[DMX model|DMX]], and [[OBJ]] for reference meshes and [[VTA]] files for vertex and flex animation. {{csgo}} [[Counter-Strike: Global Offensive]] also supports [[FBX]], but with limited functionality. [[Flex_animation|Flexes]] are not directly supported, nor are FBX sequences, however an SMD/DMX sequence can be used on an FBX model.
StudioMDL supports a range of input formats. These include [[SMD]], [[DMX]], [[OBJ]], and [[VRM]] for reference meshes, [[SMD]] and [[DMX]] for skeletal animation, and [[VTA]] and [[DMX]] files for vertex and flex animation. {{csgo|2}} also supports [[FBX]], but with limited functionality. [[Flex_animation|Flexes]] are not directly supported, nor are FBX sequences, however an SMD/DMX sequence can be used on an FBX model.
 
{{note|While FBX does technically support flex animations, an SMD file is required to generate the VTA file, making the use of an FBX file for flexes redundant.}}


{{note|While FBX does technically seem to support flex animations, an SMD file is required to generate the VTA file, making the use of an FBX file for flexes redundant.}}
{| class="wikitable"
|-
! Format !! File Extensions !! Mesh !! Skeletal animation !! Vertex/flex animation
|-
| [[SMD]]
| SMD<br>SMA {{src06|since}}<br>PHYS {{src06|since}}
| Yes || Yes || Yes
|-
| [[DMX]]
| DMX {{src07|since}}<br>XML {{src07|since}}<br>MPP {{csgobranch|since}}{{confirm}}
| Yes || Yes || Yes
|-
| [[OBJ]]
| OBJ || Yes || No || No
|-
| [[FBX]]
| FBX {{csgobranch|since}}|| Yes || {{only|[[NekoMDL]]}} || {{only|[[NekoMDL]]}}
|-
| [[VRM]]
| VRM || Yes || Yes || No
|-
| [[VTA]]
| VTA || No || No || Yes
|}


== Output files ==
== Output files ==
 
;{{mono|mymodel.[[MDL (Source)|mdl]]}}
;<code>mymodel.mdl</code>
:[[Skeleton]], animations, bounding/hit boxes, surface materials, [[LOD]] indices, [[contents flags|contents]] and [[MDL flags]], etc.
:[[Skeleton]], animations, bounding/hit boxes, surface materials, [[LOD]] index...
;{{mono|mymodel.sw.[[vtx]]}}
;<code>mymodel.sw.vtx</code>
;{{mono|mymodel.360.[[vtx]]}}
;<code>mymodel.360.vtx</code>
;{{mono|mymodel.dx80.[[vtx]]}}
;<code>mymodel.dx80.vtx</code>
;{{mono|mymodel.dx90.[[vtx]]}}
;<code>mymodel.dx90.vtx</code>
:Vertex data optimized for DirectX 6/7, Xbox 360, DirectX 8, and DirectX 9 respectively. {{Note|{{mono|.360.vtx}} files are just byteswapped {{mono|.dx90.vtx}} files.}}
:Vertex data optimised for software rendering, XBox 360, DirectX 7, 8 and 9 respectively. {{Note|.360.vtx files are just byteswapped .dx90.vtx files.}}
;{{mono|mymodel.[[vvd]]}}
;<code>mymodel.vvd</code>
:Remaining hardware-agnostic vertex data, including the [[UV map]]
:Remaining hardware-agnostic vertex data, including the [[UV map]]
;<code>mymodel.phy</code>
;{{mono|mymodel.[[phy]]}}
:Collision mesh data
:Collision mesh data. Omitted if no [[$collisionmodel]] is defined.
;{{mono|mymodel.[[ani]]}}
: Animations, if {{ent|$animblocksize}} is used.


== See also ==
== See also ==
 
* [[Compiling a model#Common errors|Common Studiomdl errors]]
* [[Compiling a model#Common_errors|Common Studiomdl errors]]
* [[Crowbar]], a popular graphical frontend for studiomdl which also supports model decompiling and other advanced features.
* [[Crowbar]], a popular graphical interface for studiomdl which also supports model decompiling and other advanced features.
* [[Studiocompiler]], a graphical frontend for studiomdl
* [[Studiocompiler]], a graphical interface for studiomdl
* [[GUIStudioMDL]], another graphical frontend
* [[GUIStudioMDL]], another graphical interface
* [[Source Model Compiler]], a web based model compiler and QC generator.
* [[Source Model Compiler]], a web based model compiler and QC generator.
* [[NekoMDL]], a modified fork of StudioMDL with additional features and increased limits
* [https://gamebanana.com/tuts/12511 Fixing the 5% Weight Bone Link Cull], for SFM
* [https://gamebanana.com/tuts/12511 Fixing the 5% Weight Bone Link Cull], for SFM
 
{{gldsrc sdktools}}
{{SDKTools}}
{{SDKTools}}


[[Category:Modeling]]
[[Category:Modeling]]

Latest revision as of 07:12, 20 May 2025

English (en)Español (es)Русский (ru)Translate (Translate)

For a guide to studiomdl's usage, see Compiling a model.

StudioMDL StudioMDL is the command-line tool used to compile models from intermediate formats exported from modeling packages to the binary .mdl format that is read by the Source engine.

It can be found at 🖿common\<gamename>\<gamefolder>\bin\studiomdl.exe.

Tip.pngTip:The name "studio" is a throwback to the development of Half-Life Half-Life, during which Valve used 3D Studio Max to create their models.
Icon-Bug.pngBug:Attempting to use Studiomdl or a shortcut of it pinned to the taskbar in Windows 8 will result in an invalid target path, even when -game and an associated path are specified. Using a shortcut on the desktop, however, still works. This is an issue on Microsoft's end, unfortunately.
Icon-Bug.pngBug:64-bit version of StudioMDL from the Team Fortress 2 branch is currently broken.
Cpp.pngCode:Source code for an older version is available in the 2006 SDK.

Parameters

The only parameter required is a QC file. Any others must come before it.

studiomdl [options] <path\QC>

General

-game <gamedir>
Override the VProject game path.
-quiet
Suppresses some console output, such as spewing the searchpaths.
-x360
Enable Xbox 360 output, overriding the Gameinfo.txt.
-nox360
Disable Xbox 360 output, overriding the Gameinfo.txt. Implied by default in non-Left 4 Dead-based branches of Source.
-nowarnings
Disable warnings.
-maxwarnings <int>
Print no more than the specified number of warnings.

Animation

-definebones
See $definebone.
-printbones
Writes extra bone info to the console.
-printgraph
Todo: Appears to dump xnode data for each node?
-overridedefinebones
Equivalent to specifying $unlockdefinebones in QC.
-checklengths
Prints engine-ready keyframe data for each animation.

Performance

-fastbuild
Skip processing .sw.vtx (DX6/DX7), .dx80.vtx, and .360.vtx variants (use .dx90.vtx only). This speeds up compiling.
Icon-Important.pngImportant:In games before Left 4 Dead, if the .dx80.vtx is absent for a static prop, VRAD will fail to generate lighting for that prop!
-preview
Skip splitting quads into tris and building tristrips. This changes the rendering flags for the model, most likely resulting in slower performance or buggier rendering in-engine.
-fullcollide (only in Source 2006)
Don't truncate really big collision meshes
Note.pngNote:(in all games since Source 2007) use $maxconvexpieces, as -fullcollide does nothing.
-striplods
Ignore all $lod commands.
-minlod <lod>
Throw away data from LODs above the given one (see $minlod).
-mdlreport <path\model.mdl>
-perf <path\model.mdl>
Report performance info for an already-compiled model. A QC file is not needed when using this command.
-mdlreportspreadsheet
Report performance info, per-LOD, as a comma-delimited spreadsheet. It will appear in the form:
Path to VTX, VTX file extension, LOD number (1 is the root lod), tri count, number of batches rendered, number of materials used
Must be used with -mdlreport or -perf!
Note.pngNote:It doesn't actually write a spreadsheet to disk; use > to Wikipedia icon pipe output to a CSV file.

Debug

-d
Dumps various glview files (10 per LOD per VTX file),
-h
Dump hitboxes to console.
-n
Tag bad normals.
-dumpmaterials
Dump names of used materials to the console.
-i
Ignore warnings.
-t <material>
Replaces all materials with the specified material.
-parsecompletion
Prints an easily parseable message indicating whether the compile was successful or a failure.
-collapsereport
Prints info on which bones are being retained and which bones are being collapsed.

Other

-nop4
Disables Valve's Perforce integration. Unless you actually have Perforce set up for your game/mod (a highly unlikely scenario), you should use this.
-verify
Compile the model, but don't actually write the results to disk.
-a <normal_blend_angle>
Auto-smooth faces equal to or below specified angle in degrees. By default, Studiomdl blends normals that are 2 degrees or less apart. Will override normal data for all meshes.
-f (removed since Source 2007)
Flip all triangles.
Icon-Bug.pngBug:Does not work in Orange Box and later builds of Studiomdl. You can achieve the same behavior with $body, however.
-vsi <path\[QC|MDL]>
Generates a VSI file from a QC or MDL.
-stripmodel <path\model.mdl>
Strips down a model, removing its LOD info.
-stripvhv <path\sp_hdr_x.vhv>
Strips down hardware verts (VHV) of their LOD info.
-makefile
Generates a simple makefile for later compiling. It also parses the QC for any errors, and runs in -quiet mode.
-basedir <path>
Runs studiomdl in the context of the provided path.
-tempcontent <path>
Adds the provided path as a content search path.

Nonfunctional

-r
In GoldSrc, tagged reversed normals in compile output console; example: triangle reversed (0.748195 0.949818 0.839380)
-ihvtest
Probably meant to test the model collision for any physics errors. Skips whatever argument is provided after it.

Input Files

StudioMDL supports a range of input formats. These include SMD, DMX, OBJ, and VRM for reference meshes, SMD and DMX for skeletal animation, and VTA and DMX files for vertex and flex animation. Counter-Strike: Global Offensive Counter-Strike: Global Offensive also supports FBX, but with limited functionality. Flexes are not directly supported, nor are FBX sequences, however an SMD/DMX sequence can be used on an FBX model.

Note.pngNote:While FBX does technically support flex animations, an SMD file is required to generate the VTA file, making the use of an FBX file for flexes redundant.
Format File Extensions Mesh Skeletal animation Vertex/flex animation
SMD SMD
SMA (in all games since Source 2006)
PHYS (in all games since Source 2006)
Yes Yes Yes
DMX DMX (in all games since Source 2007)
XML (in all games since Source 2007)
MPP (in all games since CS:GO engine branch)[confirm]
Yes Yes Yes
OBJ OBJ Yes No No
FBX FBX (in all games since CS:GO engine branch) Yes (only in NekoMDL) (only in NekoMDL)
VRM VRM Yes Yes No
VTA VTA No No Yes

Output files

mymodel.mdl
Skeleton, animations, bounding/hit boxes, surface materials, LOD indices, contents and MDL flags, etc.
mymodel.sw.vtx
mymodel.360.vtx
mymodel.dx80.vtx
mymodel.dx90.vtx
Vertex data optimized for DirectX 6/7, Xbox 360, DirectX 8, and DirectX 9 respectively.
Note.pngNote:.360.vtx files are just byteswapped .dx90.vtx files.
mymodel.vvd
Remaining hardware-agnostic vertex data, including the UV map
mymodel.phy
Collision mesh data. Omitted if no $collisionmodel is defined.
mymodel.ani
Animations, if $animblocksize is used.

See also