ADXTutorials

Random 3D Positioning

Creating believable soundscapes in games often requires a large number of 3D sound sources. These sound sources can use complex attenuation and/or angle curves to make an ambience sound as natural as possible. To add even more realism and liveliness to a scene, it is also possible to randomize the 3D positions of the sounds, which will be demonstrated in this blog.

Pan Randomization

For sounds that do not need accurate positioning or distance attenuation and can stay in 2D, randomizing the panoramic position is the simplest option:

  • Select a Cue and, in the Inspector, ensure that the Pan Type property is set to Pan [5.1]
  • Then, in the Pan [5.1] section, simply increase the Pan3D Angle Random property from 1 to 360°
  • From now on, each time the Cue is played it will be randomly positioned around the listener
  • If needed, attenuation can be simulated by randomizing the Volume of the Cue

Screenshot 01Pan random properties

3D Position Randomization

Randomizing the 3D position can be very useful for sources that are spread in a distinct area while not being clearly localized e.g., birds in a forest, insects in a field, vegetation rustle due to the wind, isolated screams in a crowd etc..

When using position randomization on a 3D Cue, the Min and Max attenuation distances, as well as the attenuation angle, will be taken into account. Playback positions will be distributed inside a shape centered on the original sound source position, which will be used to determine the attenuation.

Screenshot 02 3DPOS_RandomPosition

To activate random 3D positioning:

  • Select a Cue and navigate to the Inspector’s 3D Positioning section
  • Set the Min and Max Distance of 3D Positioning Attenuation properties
  • Select a shape under the Random Sound Source Shape property (see below for more details)
  • Based on that shape, set the extent of the randomization (see properties such as [Rectangle] Random width or [Sphere] Random radius…)

Screenshot 03 3d shape properties

Available shapes for random positioning are: None (no randomization), Rectangle, Cuboid, Circle, Cylinder, Sphere, Free, and List.

For Rectangles, Cuboids, and Cylinders, the random widths (left to right, front to back, and top to bottom) are centered on the shape. For example, if a 10-meter width is specified for the [Rectangle] Random width – Left and Right, the position will be randomized in the range of -5 to +5 meters. For Circles, Cylinders, and Spheres, the random radius is based on the center of the shape as well.

The Free and List shapes are aimed to be used programmatically. The Free shape makes it possible for a programmer to specify a custom randomization function via a callback mechanism (CRIATOMEX3DSOURCE_RANDOM_POSITION_CALCULATION_TYPE_CALLBACK). In the case of the List shape, the position will be randomly selected from a list of coordinates provided by the programmer.

Screenshot 04 pos3d_random_types

For a realistic effect, a shape smaller than the area in which the 3D sound source is located should be used. Selecting the right shape will also improve the realism of the implementation. For instance, a spherical shape will work well for birds in trees, while a cuboid will be more appropriate for a crowd in a stadium stand.

Check our demo project and try it for yourself!