Main Forum

Back to Main Forum...

unity (1 reply)

jackwilliam
8 years ago
jackwilliam 8 years ago

i got bored and started to poke around on unity's webiste and wondered, if design it, drive it: speedboats is made in unity is it hard to add an asset to the game or no? because looking at some of the things people posed it absolutely amazing.
i know that waves have been a big area on this game that would eat up tons and tons of time to get done correctly, but would something like this work where you could change the wave height, direction, and length along wiht being able to control the foam (which i thought would look good with the spray) or would that be too much of a strain on the system and would demolish your framerate while playing?
just curious, keep up the awesome updates!
<a href="https://www.assetstore.unity3d.com/en/#!/content/50834" rel="nofollow">https://www.assetstore.unity3d.com/en/#!/content/50834</a>

Todd Wasson
8 years ago
Todd Wasson 8 years ago

It depends on the asset. A pool of water somewhere with waves is easy enough, but when it's got to interact with the boat with physics at the level that we've got here, it's a different story and would require a lot of rewriting and time. There are guys out there that spend years doing nothing but convincing water and ocean effects.

What you'll find at the Unity Asset Store mainly are systems where the water can influence the boat, but the opposite doesn't occur. The boats don't actually make any waves, they just bounce over the ones that are already there. If you check out some of the GTA 5 videos with boats you might see what what I mean. Keep an eye on the waves around the boat. The boat might as well not be there as far as the waves are concerned. Most games do particles that look like wakes (similar to the foam behind the boat in DIDI), but they aren't really waves. It's just an illusion. There's no bow wave either. If you turned around and drove over your wake for instance it wouldn't affect the boat at all. If you started on a dead calm lake and drove around in circles, it would remain dead calm. So it's kind of a trick most games use.

I wrote something a few months back with real waves as an experiment:

<a href="https://www.youtube.com/watch?v=XBID4a_xo8Y" rel="nofollow">https://www.youtube.com/watch?v=XBID4a_xo8Y</a>

This worked similarly to other systems and was physics based, so the water itself can be pertubed by an object moving through it and waves will eminate from it. I don't have a video of that up though, but it did more or less work. The main problem with this type of approach is scale. Waves are essentially done with a height map, so for example a lake is cut up into a checkerboard pattern of cells, and every one of them is free to move up and down independently of each other. The computations for one cell aren't expensive, but if you had a grid divided up into 1 foot by 1 foot cells covering even 1 mile by 1 mile, you've got almost 28,000,000 cells to compute every frame. That's a lot of computation, far more than the boat itself has.

It doesn't have to be that many necessarily, it could be a smaller area around the boat that's high resolution that then fades off to lower resolution (maybe all the way to 0) far away, but that's a complicated thing to do and would take some serious time that at this point would be better spent on other things.

The boat physics would become more expensive too because the simplifications I currently make by having a flat water surface would go bye bye.

What the really wicked looking water systems are doing is running everything in a compute shader (like I do for the water spray particle system) which is stunningly fast at simple, large scale parallel problems like water waves and particles. The trouble there is if you have to send any of that wave data back and forth between the CPU and GPU (so the boat knows where the waves are, and the waves know where boat is so waves/boat can influence each other instead of just having the waves toss the boat around), there's an enormous time lag. Just trying to read back a single value can take 10 milliseconds which immediately locks you to no more than 100 frames per second. So instantly the graphics performance is reduced to 1/2 or 1/4 or so. I discovered that while writing the water spray particle system.

If I do waves, I want the boat to be able to create its own waves so it would have an actual wake and climb over its bow wave as it planes, not do it the way GTA 5 and all the other boat games do it. I've got a few ideas, it may be within the realm of possibility, but they all require serious development time.

Anyway, for this simulator and the custom physics it's not as simple as buying a nice water asset on the Unity store. If it was I would have done it before it was released.