description |
---|
What is Garment Support and how does it work? |
This page will teach you how garmentSupport works – the system that Cyberpunk2077 uses to tuck pants into boots and shirts under jackets. It contains theory, which you don't need to understand to use the system.
Credit goes to psiberx (discord post with initial explanation of the algorithm), island dancer for providing screenshots and know-how, and Auska for making morphtarget/garmentSupport import able in Wolvenkit.
If you want to create garment support, check garment-support-from-scratch.md
If you want to use garment support in an existing mod, you only need to use #component-prefixes
If your garment support is shrinking too far, check the section for #painting-garment-support-in-blender
If you have other problems, see #troubleshooting-garment-support at the end of the page.
The engine morphs garments to avoid clipping — for example, if you equip a pair of boots and V's jeans no longer cover the shoes, but get tucked under.
Garment Support in action
This process is accomplished via 'parameters' on the mesh:
These will show up as shape keys in your Blender export
GarmentSupport only works on actual garment items that have been equipped using the game's transaction system. As of October 2024, that's not the case for NPCs.
You'll have to go refitting!
Garment support will be applied based on garmentScore. For this, the prefix of the component name will be considered (components are named in your .app or .ent file's component array).
A high garment score means that the item is "on top", squishing anything worn "below". (See #the-algorithm for details.)
The prefixes are as follows:
h0_ t0_ s0_ l0_ | Any component with a 0 in its prefix will be treated like a body mesh (no deform/squishing of any meshes with x0_ prefixes across .ent files) |
h1_ | Head inner (mask, sunglasses) |
h2_ | Head outer (helmet, bandana) |
t1_ | Torso inner (shirts) |
t2_ | Torso outer (jackets, coats...) |
s1_ | Shoes |
l1_ | legs (pants that aren't leggins) |
Often, you can salvage things by deleting the parameters in WolvenKit
{% hint style="info" %} TL;DR: High garment score means "on top", items below will get squished. {% endhint %}
{% hint style="warning" %}
Components with the same prefix in the same .ent file will not squish each other, e.g. l1_stockings
and l1_pants will not deform each other, but they will deform s1_socks
{% endhint %}
The game calculates the garment score by checking the prefix of component names, where the one with the lowest prefix is the innermost:
s0 = 0 // no prefix will also be 0
l0 = 10
a0 = 20
t0 = 30
h0 = 40
s1 = 50
l1 = 60
t1 = 70
i1 = 80
hh = 90
h1 = 100
h2 = 110
t2 = 120
After considering the component name, the game will consider the tags in the .ent's visualTagSchema
:
PlayerBodyPart = -2000
Tight = -1000
Normal = 0
Large = +1000
XLarge = +2000
An example for t0_000_pma_base__full
(the default body component, torso+legs):
+30 prefix: t0_
-2000 visualTag: PlayerBodyPart
—————————————————————————
-1970
based on experimental research by revenantFun
- Make sure that you have the parameters
_GarmentSupportWeight
,_GarmentSupportCap
andCol
, and that all of them are in the formatFace Corner > Byte Color
_GarmentSupportWeight
: Vertex paint it red (RGB 1, 0, 0)_GarmentSupportCap
: Vertex paint it black (RGB 0, 0, 0) if it isn'tCol
: Vertex paint it black (RGB 0, 0, 0) if it isn't- You're done!
In a given mesh, garment support is handled by two color attributes: _GarmentSupportWeight and
_GarmentSupportCap
. In Blender, these are found in the Data
panel under Color Attributes
, together with the third attribute, Col
.
{% hint style="warning" %}
For exporting, all three of these must be in the format Face Corner > Byte Color
{% endhint %}
Here's how it looks like:
Always make sure all three are Face Corner > Byte Color format before exporting. You can convert back and forth between formats with the down arrow button on the right.
If you are editing vanilla items, you may find parameters of the type Vertex -> Byte Color
with their names in ALL CAPS, such as _GARMENTSUPPORTWEIGHT
and _GARMENTSUPPORTCAP
. Delete them by selecting them and clicking the minus icon:
Repeat for every submesh in your mesh, until they all match the required format.
{% hint style="danger" %} It's crucial to repeat this process for every submesh in your garment, or your attributes will not get written correctly on export. {% endhint %}
If all you're doing is trying to preserve existing garment support before doing some light editing or refits on vanilla garments, you can stop right here!
If you're making a brand new item and making your garment support from scratch, however, you'll need to keep reading to find out how these parameters should look.
Garment support color attributes are edited in Vertex Paint
mode in the viewport:
This attribute affects how the mesh behaves when layered with other garments:
Colour | RGB value | Explanation |
---|---|---|
Black | 0, 0, 0 | heavy deform, lots of squishing (default behaviour) |
Red | 1, 0, 0 | light deform, no squishing |
{% hint style="info" %} Simple base game clothing will have a flat red layer. If you have a flat black layer, you may want to paint it red, as this will deform more than you might want. {% endhint %}
Two examples of correctly-formatted vanilla garment weights. If in doubt, just paint it red.
_GarmentSupportCap
determines stopping points for the deformation effects of garment support. Like _GarmentSupportWeight
, it is painted only with red and black.
Colour | RGB value | Explanation |
---|---|---|
Black | 0, 0, 0 | no garment cap |
Red | 1, 0, 0 | limited GS influence on the meshes below (more red = less squishing). The garment itself will serve as a delimiter. |
With vanilla items, you will see red GarmentSupportCap on areas that will either
- directly intersect with the body
&#xNAN;(the ends of sleeves and legs, the bottom of a shirt, the opening of a turtleneck...) - sit right above something that shouldn't be deformed
&#xNAN;(the player body, or a tight-fitting shirt, or the lapels of an open jacket)
The cap provides a shrinking limit, so without GarmentSupportCap, every part of your mesh will apply shrinking/tucking on the meshes layered "below".
Often, this is completely okay and your _GarmentSupportCap
layer can be flat black. Otherwise, you need to paint red those parts which either cut straight through the body or butt right up against other items.
The inside layer of this jacket is red because it will sit right next to either the body or to a tight-fitting shirt beneath. The ends of the sleeves are red where they will intersect with the arms. If it looks like a pair of Louboutins, you've painted it inside-out.
If this step is skipped, you can have unexpected clipping, but nothing will break. If your mesh seems like it's being too aggressive when you layer it over other things, and leaving holes in whatever you're trying to layer under it, try painting more of the inside faces red.
The simplest way to add functioning garment support to your custom item is to have a flat red _GarmentSupportWeight
attribute, a flat black _GarmentSupportCap
attribute, and a flat black Col
attribute. Your mesh will export and, assuming you have the proper shapekeys, will morph in (more or less) the way you'd expect! The next page will outline this process step-by-step.
{% hint style="info" %} Every submesh of your garment must have these three attributes in order for garment support to function correctly - even submeshes that contain non-deformable things like accessories, buckles, chains, belts, etc. {% endhint %}
Check #painting-garment-support-in-blender — paint it red, baby!
It's not doing that to spite you. Most likely, you have a non-unique component ID, and the game can't tell the two items apart. Here's how to resolve that:
The CRUID editor is available in Wolvenkit 8.14+ - you can go grab the Nightly, too
Make sure that your mesh has the Import Garment Support property checked (this should be default by now).
If that doesn't work, you still have the option to re-create garment-support-from-scratch.md in Blender
If you're fed up with this shit and just want your item to stop cosplaying as exploding pixel cloud, you can use #option-2-guaranteed-to-work-delete-garmentsupport-from-the-mesh.
{% hint style="danger" %} This wil prevent your garment from shrinking under other, "larger" garments, and practically guarantee that it clips. {% endhint %}