Sunday, September 28, 2008

Sound Occlusion Per Material

hi, i did small update to sound occlusion which defines sound occlusion properties via script file.
so now i can define reverb and direct occlusion for each material.
the script is very simple: (for short only 2 materials)
none =
"0.5", -- directOcclusion
"0.5" -- reverbOcclusion

stone =
"1.0", -- directOcclusion
"1.0" -- reverbOcclusion

none - is the default occlusion properties if material not defined/found/exist
the rest is direct and reverb occlusion values per material (using material name)
when creating the sound geometry the occlusion properties will set based on material and his values from the script.

Monday, September 15, 2008

Caching Data

hi, this time i added new script file that will contain all the data that needed to be cached before the game start.
the engine designed to load data on demand so when i'm checking things i don't need to wait until all map data will be loaded, so if for example you are not shooting at all, then the sounds and effects for the shooting wont be loaded (it will be loaded and cached when you shot at the first time)
this is very nice and good when you are testing things but when you want to play the game this is very annoying as the game will freeze a little when you do some actions (firing/jumping etc)
the script is very simple, it contains data to be loaded and cached per category: sounds/effects/animations.
example for sounds category:
SoundShaders =
this we cached only the "pickup_weapon" sound shader before the game start.
for now i'm using only one cache file, but it will be extended to support few cache files - one for each map so every map will have its own data that needed to be cached before playing it.

Friday, September 12, 2008

Sound Geometry And Occlusion

hi, i added sound occlusion effect which takes scene geometry into consideration when trying to play sound with his properties.
i created new class called CSoundGeometry which contains the geometry the sound need to consider when we are playing it.
all sound geometry classes separated by material properties so i can give different sound occlusion and reverberation properties based on the material.
for example: stone will occlude more sound then glass.
for now i didn't setup the properties table for each material, so every material will block the sound in 100% (so no reverberation for now).
i added debug rendering for the sounds so i know when sound is occlude and how much by rendering red to green color circle interpolated from the min to max distance property of the sound, so if the sound have 10 to 100 (min, max distance) and it is occluded it is shown in red, if not it is shown in green, if it is 50% occluded it is shown a circle radius of 45 and with 50% color between red and green.
note that only one room has sound in it so only when the door is opened we can hear it, you can also hear the steps sound and gear when you are moving.
the door also have few sounds for few states: open/opened/closes/locked
here is screenshots and short movie that shows sound occlusion in action.

sounds shown in green spheres, occluded sounds in red

min/max distances of sounds shown in green circles, occluded sounds in red
the door is opened at 50% so the top sound is occluded 50% meaning 50% between red to green


Light Leaks

hi, small update about something i saw while working on sound occlusion.
i created small level containing 2 rooms with a door separating them, while playing with this level i saw some lights leaks near the door and at the sides of one of the rooms room (the one without a light) it appears that some of the light from the lighten room leaked into the dark room - very strange, because i'm using vsm for shadowing the scene and i'm using some thresholds to solve the light bleeding problem i thought to give a second check to this threshold.
so what i did is increasing the light bleeding threshold and everything look good now :)
here is few screenshots showing the problem before and after solving it:

close door - leaks on sides and near door

open door - leaks on sides

close door - no leaks

open door - no leaks

Sunday, September 7, 2008

Ambience Sounds

hi, this week i added ambience sounds, so i could place sounds in the scene which will be played based on their properties defined in the map file.
unlike other sounds, those sounds usually played automatically (some ambient creepy sounds), or by triggering some triggers/events (like opening a door, or using an elevator)
here is an example of sound entity defined in the map:
"origin" "753.48 2078.26 66.7"
"classname" "speaker"
"angle" "315.181274"
"s_shader" "sound/ambience/music.ogg"
"s_looping" "1"
"s_shakes" "0.000000"
"name" "speaker_2"
"s_volume" "-6.000000"
"s_mindistance" "512.000000"
"s_maxdistance" "1200.000000"
"s_occlusion" "0"
"s_waitfortrigger" "0"
"soundgroup" ""
"wait" "0.000000"
"random" "0.000000"
"s_global" "0"

ok, so what are all those properties do? here is a quick info:
origin - the position in 3d space of the sound (if ambient this will be ignored)
classname - internal use, basically its the type of the entity
angle - control the spread of the sound
s_shader - sound shader or sound media file (.wav, .ogg, .mp3)
s_looping - need to loop or not (repeat the sound over and over)
s_shakes - shake factor controlling how strong the view will be shake when playing the sound (also based on the loudness of the sound)
name - name of the sound/speaker entity
s_volume - volume of sound (in decibels)
s_mindistance, s_maxdistance - minimum and maximum audible distance for the sound
s_occlusion - is this sound need to take care of geometry occlusion or not
s_waitfortrigger - sound will be played only when the right trigger will be triggered
soundgroup - the group the sound belongs to, useful for setting volume for few sounds, for example, all music sounds added to group "music" so if we want to mute the music in the game we just mute the group called "musics" and its done.
wait - delay between playing the sound again
random - random factor added to wait when needing to play the sound again
s_global - is this sound need to be heard every where (makes the sound ambient - used for music), if its ambient the sound will ignore his 3d properties.
so as you can see it is very easy to define ambient sounds in the scene, those sounds adding alot to the game play and make the game more realistic.
for now, geometry occlusion is not supported maybe i will add it next time.