Sound Shader Creation

The concept of "channels", as used in Quake3, is completely gone. There is no more SND_IDLE, SND_ACTION etc. These have been replaced by sound shaders. A sound shader defines the wavefiles, and the way they are played. Both .wav files and .ogg files can be used with the new Quake4 engine.

Sound shaders are just like the material shaders. They are located in the base\sound directory and have the extension .sndshd, you can create any number of sound shader files, they are all collected and loaded together at run time.

The sound shader is the root of all things audio with the new Quake4 engine. After you create a new sound, it is always a good idea to go ahead and create the shader immediately after. This way, things stay organized and you know which sounds are available to be used in game and which are not. It is also a good idea to regularly go through past shaders and clean them of unused or invalid sounds, this eliminates error messages and just keeps a tighter ship.

Here are a few examples of shaders:

ambient_machinery11 
{
        minDistance     40
        maxDistance     600
        volume          0

        looping
        
        sound/Ambience/industrial/machinery11.wav
}

This particular shader is an ambient sound, which is created as a continuous loop. It begins the sound at full volume with a minimum distance of “40” and fades to silence over “600” units. The volume is set to the default setting of “0”, so it will play at whatever volume you have designed the sound for. Volume is measured in dB…so if you have a highly compressed sound, it probably isn’t a good idea to go over “0” in many instances, as you’ll get clipping/distortion. The “looping” entry has been inputted, thus making the sound loop to the beginning once it completes its playback cycle.

Here are some other examples:

gladiator_breathe 
{
        description     "gladiator huffin and puffin"
                
        minDistance     400
        maxDistance     1200
        volume          0

        sound/Strogg/gladiator/breath01.wav
        sound/Strogg/gladiator/breath02.wav
        sound/Strogg/gladiator/breath03.wav
        sound/Strogg/gladiator/breath04.wav
}

sound player_steps_solid_metal 
{
        description     "player footstep sound when walking on solid metal materials"

        minDistance     400
        maxDistance     1200
        volumeDb        0
        frequentlyUsed
        no_dups

        sound/marine/player/steps/concrete_01
        sound/marine/player/steps/concrete_02
}

Notice that these have a selection of different sounds, the shader system will pull a random sound from this list whenever it fires one off. You will also notice that the minimum and maximum distance on these particular sounds are somewhat larger, which allows the player to hear the sound more distinctly from further away from the origin of the sound.

Here are all of the options:

description [string] - a string that decribes what the sound is used for and/or how it is used. For dialog, it is normally the phrase that is spoken. It is purely for development purposes and is not required by the sound engine.

minDistance [float] – sets the minimum distance from where the sound emanates in world units. It’s a good idea to set this to about 40 – 120 when use on a world object or creature.

maxDistance [float] – sets the maximum distance from where the sound emanates. Beyond this distance the sound cannot be heard.

volumeDb [float] – sets the volume for the sound within the world in decibels. 0 is the default volume, -60 is complete silence.

leadinVolume [float] - volume of the leadin sound on a 0 (silence) to 1 (full volume) scale.

unclamped - by default, each channel's volume is clamped to 1.0 after all the attenuation calculations. Setting this flag means this clamp is not applied. Unclamped can be applied to all channels by setting the cvar s_clipVolumes to 0.

looping – sets the shader to loop.

playOnce - don't restart the sound if it is already playing on this channel.

global – this forces the sound to ignore the min/maxDistance settings and play it globally. Mainly used for music and Multiplayer announcements.

private - only hear the sound on the player that plays the sound.

antiPrivate - the player that plays this sound cannot hear it.

no_occlusion – sets the shader to not occlude, meaning that you will hear them through walls and such. Very useful for creepy kind of stuff, music beds, and doors opening and closing.

omnidirectional - by default, sounds navigate through the portal tree to work out their distance from the listener. Sounds with this flag do a simple distance check and play at the same volume in all speakers.

no_dups – this is a setting that doesn’t allow the shader system to repeat two random sounds back to back. It creates a bit more of a realistic sonic experience. Footsteps are a good example of the use for this.

no_flicker - this allows a light to play a sound that does not affect its intensity.

frequentlyused – this is a performance setting that forces the sound to always be decompressed. It uses more memory, but ups performance significantly. Use this sparingly and only on sounds that are truly “frequently used”. An example would be a player’s gun sounds or footsteps. Something that is short in duration.

noRandomStart – this is for looping sounds. By default, the game will choose a random point in a loopable sound to start from. This shader parm forces the sound to play from the beginning of the sound. This is useful for sequence sounds (accel, move, decel, stop sounds – like elevators) or music.

voForPlayer - this sound is dialog directed at the player, so make it artificially louder and everything else quieter.

center - artificially enhances the volume of this sound by biasing towards the center speaker.

causeRumble - a sound with this flag causes a rumble on force feedback devices.

soundClass [int 0 to 4] – this groups certain sounds together for volume purposes. For example, all the music files are on “soundClass 3”, so if someone needs to globally change the volume for everything music-wise within a script, they would simply fade anything on “soundClass 3”. Nothing else would change.

Frequencyshift [float] [float] - allows frequency attenuation of sounds. Normal ranges would be 0.75 to 1.25.

shakes [float] - this defines how much the screen shakes when this sound can be heard.

no_shakes - a flag for the tools to suppress generation of shake data. Generally speaking, this is for music.

shakeData [int] [string] - the intensity of the sound in ascii form. z is loud, a is complete silence. Each letter represents 1/30th second.

altSound [sound] - this is the 'broken' sound for a light. If a light with a sound is broken, it will stop the original sound and play this one if it exists.

minSamples [int] - this overrides the s_maxSoundsPerShader cvar. For example, the limit is set to one for low memory machines, but it is still desirable to have more than one footstep sound.

Sounds ShaderCreation (last edited 2005-12-08 16:32:00 by JohnScott)