🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to place ocean sound?

Started by
6 comments, last by Acosix 2 years, 3 months ago

Hi,

I have been learning how to implement different kinds of sounds in an open world game. One that I am struggling is the ocean sound, which usually has an irregular coastline and requires some accuracy. I tried to find tutorials about it but only came up with nothing.

I do have some ideas but I am not sure if there are better ways to do it.

One is the volumetric script mentioned in the wwise official site. It uses a movable emitter that follows the edge of the volume as the player moves. If the player moves into the volume, the emitter will stick with the player. This is very useful for lakes but not ideal for surrounding ocean beach. Also, inverted points of the shape would cause panning problems.

Another is Zones. This is pretty safe. It uses boxes to play the 2D sound. If the player enter the zone, then play it, otherwise stop it. That's all. The problem is that it does not provide attenuation arround the edge of the waterbody. I should probably place some spline-controlled audio or multi-direction audio, to cover the transition between lands and seas.

Do you guys know any better solutions?

Thanks in advance!

Advertisement

You could use the approach that I developed in this paper to determine the audio level and directionality for area/volume sources, particularly the “Monte Carlo Projection” one (section 4.2) which works well for mesh-based audio sources like the water you describe (see video for the paper). To make the implementation simple, you could even ignore all of the HRTF and spherical harmonic stuff and just do the basics needed for area sources, namely just calculating the level of the sound and direction to the closest point on the source.

This boils down to:
1. Generate N random uniformly-distributed points on the surface of the source mesh, where N depends on the solid angle of the source with respect to the listener, and is usually in the range 1 to 500. The random sequence should be the same every time for stability. This sampling can be done in terms of surface area (i.e. by generating random points on the mesh), or in terms of solid angle (i.e. by generating rays from a conical distribution that encloses the source's bounding sphere). The best sampling approach depends on the shape of the source and position of listener relative to the source. Long/thin sources should probably use area sampling, while bigger sources (i.e. ocean) can probably use solid angle sampling. In the case of solid angle sampling, you need to intersect the rays generated at the listener position with the source's mesh to find the intersection points/distance.
2. Use either equation 14 or 15 along to calculate the sound energy for each point. Then sum up the contributions from each of the N points (Eq. 14/15) and divide by N to get the energy for the source. The direction for the source used for panning/spatialization could just be the vector to the closest point, assuming no spherical harmonics are used. An important step missing from the paper is to use a sqrt() on the final energy to convert from energy to pressure amplitude, so that you get the correct 1/r distance attenuation.

@Aressera Wow your paper is awesome! Thanks for providing such a professional approach to the problem and it will definitely help me a lot! It might take me a little bit longer to understand it.

I wonder if today's AAA titles would use methods with this level of complexity to achieve the audio demands? Our game is an MMORPG and the sound design is not required to meet the high requirements those VR games need. But advanced approaches like yours are more convincing to me.

@glenn_zhang I recently made something similar. I used a sort of zone method you mentioned, but using smaller zones 32x32m and not only considering the one the player is in, but all of them within a given range, so I can attenuate. This does not only work with ocean, but with forest, mountains, villages…etc.

The setup process can be automated if the environment is not changing, so I pre-generate zone sounds depending on the water level and placed or generated objects. If you have day-night cycle with dynamic weather conditions you have to consider more options ?

@bmarci Your method is also great! With auto-generate tools like ProInstance tools for UE, we can also line the boxes up to the surface. How do you attenuate them? Is it that your player calculates the number of the boxes within a range?

And after a few more discussion with my friend, I know how some modern games deal with the problem. I have heard that in Ghost of Tsushima, they use multi-position mode to simulate the water. It is said that they place massive number of emitters into the water manually. This is a less buggy method and it supports realistic attenuation in all irregular situations. But this need tons of work, and the points must be carefully placed and cannot be too many or too few.

Another common solution a Chinese Top game company uses is movable point I mentioned above. This requires the designer to take other functions into concern together. Like occlussion, ray tracing, etc. But it is more advanced and automated.

glenn_zhang said:
How do you attenuate them? Is it that your player calculates the number of the boxes within a range?

Not really, I use the boxes to “generate” emitters. Let's say I have 5-10 ocean wave samples, and I can set it up to emit one sound in every 4-10sec, and from then on it'll have a 3d position, so it'll attenuate as the player leaves the area, and as a bonus it gives nice ambient effects in forests, wind-blow and birds sound up from random directions.

I also have stacking behaviour of these boxes, so they can suppress each other, thus I only have to add box in the house, so when you enter the outside ambience is “silenced”.

Not perfect but I can live with it.

You could make the sound based on a location. Instead of where the player is.

This topic is closed to new replies.

Advertisement