Static Prop Combine

From Valve Developer Community
Jump to: navigation, search
English (en)Русский (ru)Translate (Translate)

Static Prop Combine, or informally speaking "autocombine", is a feature in Counter-Strike: Global Offensive Counter-Strike: Global Offensive's VBSP. It allows VBSP to merge together multiple static props into a single static prop, either automatically or with user-defined rules. This has the effect of both reducing the overall number of static props in the map, while also reducing the number of performance-eating draw calls. To enable it, run VBSP with -staticpropcombine.

Tip.pngTip:In Source Source, there is one draw call per model per material. By combining models sharing the same materials, less draw calls are performed, which greatly helps optimization. Valve has stated that Nuke runs 40% faster after they implemented static prop combine.
Note.pngNote:Due to the fickle nature of VBSP's prop combination feature, it may be better to use TeamSpen's Hammer Addons TeamSpen's Hammer Addons. Alternatively, static prop models can be combined manually.
Tip.pngTip:Hammer++ Hammer++ can merge models together using it's built-in Propper++ tool.

Operation

Static prop combine performs the following operations:

Identify props to be combined.
It either does this according to the rules specified in spcombinerules.txt or automatically based off of model use.
Note.pngNote:-staticpropcombine_considervis is a useful command which makes it take into account visclusters when combining.
Scan the QC source for each model it's combining, and extract certain info.
This includes the names and locations of reference and physics meshes, the model's upaxis, the model's scale, and whether it's concave or not.
It locates the QC by reading the qc_path keyvalue from the model, which is always considered relative to the game's content directory - even if it's an absolute path!
Note.pngNote:There are many restrictions relating to this step, see Usage for details.
Use that info, plus a stub QC, to generate its own QC.
$contentrootrelative, $appendsource, and $addconvexsrc are all new commands designed specifically for static prop combine, the latter two being ways to "add" geometry to a model with an arbitrary offset, rotation, and scale.
Call studiomdl to compile this generated QC into a combined model.
Combined models will always contain _autocombine_ in their name.
BSPZIP all combined models into the BSP's pack.
Tip.pngTip:Running with -keepsources will stop static prop combine from deleting its generated QCs and unpacked model files.

Usage

VBSP Options

See VBSP.

Hammer Options

Props that differ in the below keyvalues will NOT be combined, unless manually overriden with the appropriate VBSP option:

  • Render in Fast Reflections (-combineignore_fastreflection)
  • Ignore Normals (-combineignore_normals)
  • Disable Shadows (-combineignore_noshadows)
  • Disable Vertex lighting (-combineignore_novertexlighting)
  • Disable Flashlight (-combineignore_noflashlight)
  • Disable Self-Shadowing (-combineignore_noselfshadowing)
  • Disable ShadowDepth (-combineignore_disableshadowdepth)

In addition, you can manually disable static prop combine for individual props with the Disable Prop Combine keyvalue.

Prop Setup

In order to use a prop with static prop combine, you MUST have the source files for the prop!

Note.pngNote:To use Valve props, you must recompile them under a different name - otherwise, the version of the prop that is packed in the VPK would overwrite your version.

The QC for the prop must be compiled from the game's content folder. For Counter-Strike: Global Offensive Counter-Strike: Global Offensive, this should be SteamApps/common/content/csgo/.

Tip.pngTip:In reality, the location where it searches for content will always be ../../content/[-game name], relative to the bin folder. This can be useful to modders to know.


There are quite a few restrictions that are put in place. These include:

Rules Setup

Rules for static prop combine are defined in scripts/hammer/spcombinerules/spcombinerules.txt. It is a standard KeyValues-formatted text file. Each entry follows this format:

	"example_combined" //name of the combine group, used for the final model name in the level
	{
		// this is a stub qc that will be used to generate combined models
		"qc_template_path"	"scripts/hammer/spcombinerules/qc_templates/example.qc"
		
		// max models per cluster using these peers
		"cluster_limit" 8
		
		// don't cluster models greater than this far apart
		"distance_limit" 12

		// these are models that can combine with each other
		"peers"
		{
			"models/examples/example_A.mdl" ""
			"models/examples/example_B.mdl" ""
			"models/examples/example_C.mdl" ""
		}
	}

If you don't want to bother with creating rules, you can run -staticpropcombine_autocombine. However, this can cause issues if you do not have the source files for the models VBSP tries to combine.

Icon-Bug.pngBug:The paths in the "peers" list MUST be written with forward slashes!  [todo tested in?]

Stub QCs

Stub QCs are QCs or QCIs which contain a base template for the QCs which static prop combine generates. Generally, they should only include:

Tip.pngTip:

Stub QC Example

$cdmaterials models\props\de_venice\venice_window_3

$staticprop
$surfaceprop "Plaster"

$texturegroup venice_window_3 {
	{ "venice_window_3" }
	{ "venice_window_3_lit" }
}

See also