Skip to content

Performance ​

Contact uses GPU time and memory only on meshes that are touched. Measure your own scene with the Softbody Debugger and the Unity Profiler.

Where the cost goes ​

CostContentWhen
GPU timeOne contact updateFor each touched mesh, every frame unless the limits below skip it
CPU timeThe component's LateUpdate: finding colliders, inertia, update requestsEvery frame for each enabled component (small)
MemoryOne set of contact textures. The size follows Contact Map ResolutionFor each touched mesh, from the first touch until it has fully recovered
MemoryThe contact map texture in Mesh DataAlways, while the Mesh Data is in memory

Jiggle (inertia) is separate. Whether or not the mesh is touched, each component costs a small CPU calculation, and the vertex stage of the Softbody shader does some work.

Life cycle ​

  1. Sleeping. No collider is near the pressable surface. There is no texture set and no GPU work. With Find Colliders Automatically on, while the mesh is on screen and larger than Min Screen Size, one overlap check per frame still looks for colliders.
  2. First touch. The mesh gets a texture set from the pool and updates that same frame. The update rate limit and the update interval for small meshes (Full Rate Screen Size) do not apply, and it goes first in the Update Budget order. If the pool has no ready set, it starts a few frames late.
  3. Pressed. It updates once per frame. If a limit below applies, it updates less often. Updates do not stop while it stays pressed and nothing moves.
  4. Recovering. After the hand leaves, updates continue while the dent returns according to Recovery Rate. With Memory Time, they continue until the mark disappears (about 10 times Memory Fade Time).
  5. Recovered. If nothing is within reach, the texture set is emptied and returned to the pool, and the mesh sleeps again. A mesh off screen does not wait for an update turn; it counts as recovered once time has passed.

What makes it cheaper ​

SettingWhereEffect
Enable Contact offSoftbody component, ContactRemoves all contact cost (GPU work, memory, collider search) for characters nobody touches, such as a crowd, and keeps jiggle. Can be changed during Play.
Contact Map ResolutionSoftbody Authoring Data, 6. Contact MapSets the size of every update and texture set, and applies after you press Rebake Contact Map. 512 for a human-sized character, 1024 only when seen up close, 256 for small props.
Pressable SlotsSoftbody Authoring Data, 6. Contact MapLeaving out slots that do not dent (face, hair) gives the map's cells to the rest, so a lower resolution can look just as sharp.
Min Screen SizeSoftbody component, Contact > PerformanceStops the dent calculation when the mesh appears smaller than this value on screen or is in no camera. At the default 0.15 with a 90° horizontal field of view, a human-sized character stops at about 12 m. During Play the Scene view counts as a camera.
Limit Contact Update Rate and Contact Updates Per SecondProject Settings > Softbody, PerformanceLimits the updates per second of each touched mesh. 30 per second at 120 fps is a quarter of the GPU time, and at 60 fps half.
Update BudgetProject Settings > Softbody, Quality > AdvancedLimits the number of meshes updated in one frame (default 4). The rest update in turn (Project Settings).
Full Rate Screen SizeProject Settings > Softbody, Quality > AdvancedUpdates meshes that look small on screen only once every few frames. The default 0 is off.
Collider ChannelSoftbody component, Contact > CollidersChoosing only the layers that hold hands and props reduces the collider candidates (Colliders).
Softbody Ignore componentAny GameObjectAttach it to things that overlap the mesh but must not press it. Colliders on that object and its children are skipped.
Tessellation off, or a large Edge LengthMaterialTessellation also splits pressable triangles while they are not pressed, so drawing costs more. Use Softbody/Lit for meshes that are not seen up close.
Contact Detail Basic (default)Softbody component, ContactLeaves out bulge, skin drag, Edge Smoothing and Flex paint, so it costs less GPU time than Full. Set Full only on meshes seen up close.

Project Settings > Softbody with Limit Contact Update Rate on

Disabling the component or the GameObject returns the texture set to the pool and stops jiggle and updates. Until you enable it again there is neither CPU cost nor GPU contact cost; the material stays at the disabled values, which leaves a small amount of work in the vertex stage of the Softbody shader. The returned set is freed after Release Delay (default 10 seconds), and the contact map in Mesh Data stays in memory.

Graphics APIs ​

APIFirst compile of the contact shadersNotes
Direct3D 12A few secondsRecommended for the Editor.
VulkanA few seconds
Direct3D 11About 15 minutes (on a fast PC)The compiled result stays in the project's Library folder, so you do not wait again until you delete Library.
MetalNot checkedContact Detail Full runs as Basic.

On APIs other than these four (OpenGL, OpenGL ES, WebGL) and on devices without compute shaders, contact is off and only jiggle runs. The Console then shows the warning Contact is OFF for every Softbody component: ... with the reason.

Measuring with the Debugger and Profiler ​

Each line is described in Project Settings. The GPU lines are the sum over all touched meshes.

The Softbody Debugger while a cushion is pressed

In the Time section of the Debugger, look at GPU Total (ms) first. If it is high, look in the Counters section at Surface Field GPU Updates, the number of meshes updated, and Dent Tiles 16x16 (GPU), the number of cell groups that solve the dent. Then look at the GPU lines that add up to GPU Total.

  • GPU Contact grows with the number of colliders and shape field pieces, and with Contact Groups 8x8 (GPU), which is fixed per mesh.
  • GPU Dent grows with the pressed area.
  • GPU Tiles and GPU Compose are nearly constant per mesh. GPU Lump is 0 on meshes without lumps (all static meshes included).
  • GPU Drag and GPU Pressure run only with Contact Detail Full. With Basic, or with Drag Friction at 0, the GPU Drag and Drag lines are 0.

If Surface Fields Running is high with nothing visibly touching, a mesh is recovering or something on a Collider Channel layer is gathering as a collider. Find the mesh in the State column of the Instances list.

In the Unity Profiler they appear under these names.

  • CPU module (Scripts): Softbody Tick is the whole LateUpdate of each component. Inside it are Softbody Surface Field (preparing the contact update: colliders, bones, requests) and Softbody Upload (passing inertia data and material values).
  • GPU module: Softbody Contact, Softbody Tiles, Softbody Dent, Softbody Compose, Softbody Lump, and with Full Softbody Drag and Softbody Pressure. These are the same spans as the GPU lines of the Debugger.
  • The GPU updates of all meshes are submitted once per frame in the SoftbodyFlush step at the start of PostLateUpdate.

While the Debugger is open or the Profiler is recording, a small extra task reads the contact state a few frames late to fill the (GPU) lines.

Memory ​

The size of one texture set follows Contact Map Resolution and whether the mesh has lumps. The Memory column of the Instances list in the Debugger shows each mesh, Surface Field Textures (MB) all touched meshes, and Surface Field Pool Idle (MB) the spare sets in the pool and the sets being prepared. On Vulkan some contact textures use a larger format, so the same mesh needs more memory. Memory grows with the number of meshes touched at the same time, not with the number of meshes placed.

The baked shape of a shape field is uploaded to the GPU once for each mesh that shape field presses. One hand baked with 0.2 cm cells is about 1 MB. It is released when the pressed mesh returns its texture set to the pool.

The contact map texture in Mesh Data is stored in the Mesh Data and stays loaded while a scene or prefab that uses the Mesh Data is in memory. Disabling the component does not unload it.

Disabling and enabling a component, spawning it or loading a scene does no heavy work in that frame. Textures are created at Create Budget per frame, and the pool keeps Texture Pool spare sets for each kind used by enabled components, so the first touch does not wait. What a disabled component used stays for Release Delay, so enabling it again recreates nothing, and after that it is released a little each frame. With Texture Pool at 0 no spares are kept (the first touch starts a few frames late); raise it if several meshes are touched at once. The three values are in Project Settings.