Sound and Physics

Overview

In CryENGINE, the environment is very interactive. Things move, collide, and break. When two materials touch each other, the collision can generate a sound.

The interaction between two materials is described in a file called MaterialEffects.xml (located in the \Game\Libs\MaterialEffects folder). Opening this file with a spreadsheet software will show a matrix, with surface types in its first column and row.

In this file, the engine looks up actions to be taken on interaction. Each entry in the table contains text pointing to a description of the effect to be taken. The effects are described in the FXLibs subfolder. The example below shows how the description is composed for collisions.

Example of a Crate Colliding with a Roof

The storage\local\goods.civil_box_a archetype entity has a surface type of mat_wood_hollow assigned. The surface type of the roof is mat_metal_sheet.

Where these surface types meet, the cell in the spreadsheet contains the collisions:metal_sheet_wood_hollow text.

This text indicates that the effect is called metal_sheet_wood_hollow and that it is situated in the FXLibs\collisions.xml file. There, the sound event to be played is described.

Special Cases

Special Table Entries

In some cases, the material of an object is not enough to describe its sound probabilities. For instance, a barrel is made out of sheet metal, but sounds very different from a sheet metal roof when it is dropped on the ground.

Therefore, the first column of the table described above may contain special names used by archetype classes. The following image shows names for the barrel object class, used to describe its different interaction sounds.

Destructibles also have a special mapping:

  • Breakage:Breakage: When an object of said surfacetype breaks; can be a partial destruction.
  • Breakage:Destroy: When an object of said surface type is completely destroyed.
  • Breakage:Joint_Break: When the joint of an object breaks.
  • Breakage:Freeze_Vapor: Points to the sound made when frozen things vanish upon destruction.
  • Breakage:Freeze_Shatter: Points to the sound made when frozen things shatter.

Bullet Impacts

A separate file called FXLibs\bulletimpact.xml is used to reference bullet effects. Note that a delay can be put in the effect so that the player can hear the sound of the bullet impact even while shooting.

Also, note that the bullet hitting a special object, such as a barrel, will create a sound according to the object's assigned material (for example, sheet metal).

Bypassing the Table for Vegetation Objects

Entries in the FXLibs\vegetation.xml file bypass the table in the MaterialEffects.xml file and result in sound events based on the name of the vegetation.

Physics Sound Events

Physics events can send parameter information to the sound event. The engine sends the speed and mass of the collision, which gets passed to the sound event.

In the example above, speed causes the collision to change the pitch, while the mass determines the volume and sound definition being used.

Take a look at the distance parameter. Small collisions shouldn't be heard from as far away as larger collisions should. There is a coded distance multiplier that reduces the radius from which a smaller collision can be heard.

The mass of the object defines the distance multiplier. With a smaller mass, the distance multiplier reduces the sound's roll-off radius to a fraction of the base distance parameter. The distance multiplier can be deactivated, per effect, as shown.

Console Variables

  • mfx_Debug: Turns on MaterialEffects debug messages (1=Collisions, 2=Breakage, 3=Both).
  • mfx_Enable: Enables MaterialEffects.
  • mfx_EnableFGEffects: Enables Flow Graph based MaterialEffects (Default: On).
  • mfx_ReloadFGEffects: Reloads MaterialEffect's Flow Graphs.
  • mfx_Reload: Reloads the MFX Spreadsheet.