Ok that makes sense, I was using the default damping on Z (5), now that I know it was for a boat I will try out some different values. I fixed the majority of the angular rotation issues, and the buoy no longer stops suddenly at a certain level like it did in the video.
The performance is getting a bit better, still fairly heavy on the CPU (22ms for the scene in the video, 45fps on a GTX 980 / i5 4670k), just the simulation runs at 120fps without the added CPU calculations, so it is just a tad bit concerningā¦ I intend to try reducing the large waves down to a single cluster of 8 and use those to calculate buoyancy, and use the other cluster for detail waves. The other thing I have been testing is only applying force when the test point is under water, and letting the built in gravity do the rest. I might leave for now and release an āearly adoptersā version with the system as is then update again once I get the performance to a reasonable level.
Actually I think I just realized what is causing the performance dropā¦ Will post an update later on if Iām right!
The problem I have currently is setting the buoyancy value to 1 causes the object to sink almost to the bottom, come back up and jump out of the water, then sink back down again. Once it finally settles, it still sinks down too far. Is it possibly the mass of the object is too high? Or should the test point volume be increased to compensate? Iām still trying to find the best solution, other objects work just fine at 1, but to keep the buoy on the surface I have to bump it up to a minimum of 4 currentlyā¦
So itās coming along, getting closer. Thanks again for all your help!
Hey , I see you did some progress with the buoyancy sweet.
Is it possible that you send me your current files? I have a buoyancy system which I made like a gazillion months ago that is just gathering dust in some dark corner of my hard drive, aching for some action lol.
My buoyancy system is basically a function that takes in a vector array (with the buoyancy point offsets, I also have an auto-generating system that generates points based on the mesh collision and some parameters but thatās another story!), damping variables, a mesh density variable (float) and a water density variable which basically calculates the buoyant force based on the difference in density and depth, the density variable can be super easily adjusted and fine-tuned for different kind of objects, I think it even works for helium balloons if you adjust the density and apply it when out of water
Now the thing that my buoyancy function is missing (other than a lot of polish, some rewriting and perhaps some wave-drag force) is a way to get the wave height from your at each specific array point, seems you already have that part working based on 's work so perhaps we can merge our work or something
Iām assuming you feed the parameters from the material instance to the wave height calculations in order to be able to sync the waves dynamically? thatās the part that I never got to finish xD
I made an attempt to get the height data from WaveWorks with no luck unfortunatelyā¦ my C++ skills failed me q_qā¦ didnāt want to try the render target approach as itās super slow.
Sorry for the delayed response, I just read now, but I will package up an āEarly Adopters ONLYā project and upload it here in the morning. It will basically be the current download + buoyancy, and some other small tweaks. For all those wondering when the other features will be added, I will release an actual version 2 as soon as possible (as soon as the performance gets better).
It would be if you (and any others) can help me test out some solutions to getting better performance. is the reason for the delay, I really hoped to have it ready a few days ago, but the CPU usage spiked fairly high.
It sounds like your system for buoyancy is very similar, so it will be great to possibly merge the two together. Anyways Iāll go into more detail tomorrow morning. I will post it in the thread here instead of adding a link to the page, as will be more of a beta test than a release.
Thanks for offering to help TK! I need some fresh eyes on , Iām probably doing something very simple very wrong.
āEarly Adopters ONLYā sounds good I will start adapting my code as soon as I have the project files.
Iām curious though, where is the CPU usage you are talking about coming from? I had tried 's gerstner waves and it runs fairly fast, unless you use many clusters of waves.
EDIT: For anyone reading now, the following 2 paragraphs outlining how the OceanManager works was not the performance problem whatsoever, runs amazingly fast even for multiple objects. I will leave it here for reference but wanted to make it clear is not a performance. Thanks!
The waves themselves work great, really high FPS without any issues since it is calculated on the GPU, but to add in buoyancy requires duplicating the Gerstner wave formula (& wave clusters) in code which is called by the BuoyancyMovementComponent. To get realistic buoyancy you need to have at least 4 test points around an object, each one has its own location on the water surface. To find out how much force (and whether the force is gravity or upwards buoyant force) we need to create a snapshot of the current wave height for each of the 4 points, which requires going through the entire formula 64 times per frame (2 wave sets, 8 waves per set, 4 test points).
is where the problem arises, all of those 64 calls to create a Gerstner wave are performed on the CPU which is much slower than GPU calculation. I am researching ideas on how to improve , I have a few ideas that might work, but need to be tested. The most obvious way to cut it down is to reduce the wave count down to one cluster calculated for buoyancy, but still use the second cluster as small surface waves to increase the realism, which could work. But more on that later.
For now I am off to create a new demo project containing all of , once again for early adopters only due to performance issuesā¦ Hopefully it wonāt take to long, just need to migrate it all out of my project. Will update again soon!
I opened an old project of mine from 4.4 and did some stress testing on gerstner wavesā¦
a54zmrC2J8o
Donāt pay attention to the fps from the video, itās all wrong because of fraps :rolleyes:ā¦ the actual fps difference was from about 130fps to about 85fps which is a big performance hit actually but keep in mind each crate from the video was simulating 64 test points (so about 1000 points total)! which is an exaggeration, normally you would need 4 points each.
An optimization that I can think of is to not run the buoyancy when the object is not near the water (by adding volume(s) roughly surrounding the parts) but thatās not going to help for objects that are actually in the water :
Another option could potentially be to run the calculations with CUDA but that means no AMD support etc.
At the end of the day I think you would indeed have to reduce the number of gerstner waves if you really need to simulate many buoyant objects but if we are talking about a single ship or boat for example then at least that should be perfectly fine
Wow thatās not bad at all, itās great to see it can be done!
So obviously I must have a bug in somewhere. I also allow the user to fully customize the waves using a blueprint that feeds values to the code OceanManager. I have a feeling the code is doing a re-init on the wave values before doing the calculationsā¦ I donāt know how else to explain performance hit.
Thank you for the video, it is reassuring to know that is possible to do at a good framerate. The migrating process completely broke my system BP, but almost finished putting it back together now, will upload asap!
Absolutely amazing man! Quick question I might had overlooked it or migrated it odd is the weater (rain) in the current download? I am just wondering. I am loveing what I am seeing and it works and looks amazing on 4.6.1, also would you have any issues if my team used it in our Fighting Game we are working on? We are a small indie company but Unreal and (Animation software and protoyping software which is a godsend atm) has been following us on my Twitter and the FanPage we have on FB since our site is under construction. I would give full credit and if I was able to add anything to it I would have no problem sharing. We are currently in early Alpha stages but we are working on having it release for PC/PS4/XboxOne. Once again freaking amazing job man. I am at a loss for words.
@ - I am going to PM you with the code in a zip, migrating to a new project is causing a ton of errorsā¦ Every time I get one fixed another pops upā¦ So it is going to take some more time to get it running (looks like I need to redo it again today, map errorsā¦)
@Keiyentai - The rain needs to be attached to the player itself so I didnāt hook it up properly, but have a look in the Sky\ParticleFX folder, there is a āP_Rain_Testā particle. It is basically one of the waterfalls from the Cave demo that has been enlarged to look more like rain. I will have a better example included soon, just have to get buoyancy working first. :eek:
You are more than welcome to use it in any project youād like (goes for anyone wanting to use it in their project!), and If you are able to improve it in any way that would be most welcome as well! Good luck with your game, and keep us updated!
PM sent! I think I may have found the source of the performance hit (fingers crossed)
By the way, have the shader changed in any significant way? can I use the currently uploaded shader with the code you sent me? from a quick look the parameters seem the same, just making sure
Also, have you already implemented a way to synchronize the manager parameters with the material instance?
Hey thanks for looking it over! Unfortunately I tried your code but it did not have a noticeable impact, and seems that I need it to remain a FVector for the angular rotation of the buoyant object, but I did all rather quickly so I may have missed converting a variable type. I have kept all of the changes and converted them to comments so I can give it another try later. But it did confirm for me there are no issues with the speed of the code, so thank you for that! Iām doing some profiling to see if I can figure out, comparing with the version I released before, Iām starting to think I may have overlooked something in the material/blueprints. Something is amiss here the FPS is way too lowā¦
The shader hasnāt had any breaking changes since it uses a MaterialParamterCollection which allows you to add and remove easily without much concern, so that shouldnāt be a problem. But the BP_OceanSystem is using the wrong Parameter sets, I moved them to code (in OceanManager.h) so I could easily access them from both BP/code. To fix up you need to do is add a variable of WaveParameter (no āsā on the end, that one is BP based and has been removed) for the global (median) settings and 2 WaveSetParameters for WaveSet1/WaveSet2, then a variable for holding the BP wrapper of the OceanManager code (regular BP using OceanManager as itās base class but otherwise empty, I called it OceanController), and finally pass the parameter variables to it in the BP. To pass them to the material as well I replaced the previous params with the new ones, split WaveSetParameters output nodes from the 2 wave sets and break the WaveSetParameter values for each wave, then plug each float into a āMake Colorā node to transfer them to each value in the MaterialParameterCollection.
Obviously that is not all that simple of a fix, and is really boring work splitting all connecting up those structs. Iāll get out asap for you guys, working on the 2nd attempt at migrating right now as Iām as profiling the project!
Ok, I have some good news and some incredibly news for you guys! First the incredibly news:
Performance is no longer an
I found the bug, fixed it and now get 120fps with multiple buoyant objects, as shown here:
oT8jJpSqYwc
The good news? Iām just finishing up that buoyancy sneak peek right now, and will upload shortly.
@ - Yes it is possible, and there is a nearly completed version of it in the folder of the download. It is called āOceanManagerā as well, and has everything needed to get it working. It canāt just be hooked up and used as is, it needs a bit more work, I may look into that in the future now that I have the code version working.
@InMind - Yes I found that article as well recently, it has a lot of good info in it! Now that buoyancy is working I will be exploring it further, especially the way they transition between the shore and open . They use a variant of Gerstner waves along with a Fast Fourier Transform (FFT) generator to add more dimension to the waves. I re-installed AC Black Flag a couple of weeks ago and I will be using it as a reference going forward, they did a really good job on the waves itās really impressive, I hope system will one day look the same. Thanks for mentioning it though, any other interesting articles you come across, be sure to send them my way!
Ok here is the āEarly Adoptersā version of the OceanDemo with buoyancy. I am currently working on a tutorial for how to create your own buoyant objects and will add it here soon. It is fairly easy though, check out one of the Buoyās blueprint Components section, all you need to do is add a BuoyancyMovementComponent and add a āTest Pointā to each corner of the object. 4 is pretty standard but a boat will need more (currently working on getting a small boat working).
Here is the Preview of version 2 - With Working Buoyancy <Link Removed - Now on >
** Link** - https://.com/UE4-/
*Note: I donāt mind any of you using in any project for UE4, and have no problem with any videos being created demoing itās functionality. Only thing I ask for videos is you link back to thread. Thanks!
Looking fantastic! Great work on the buoyancy - Iām tuning it a bit right now. Will contribute back for comments when done.
For those wondering about performance, Iām seeing 94.6 fps on a Core i7/4790k + GTX 970 @ 1342mhz, with the buoys and cylinders in the frame. About 96fps with just water in frame - so very little hit from the buoyancy model. Amazing!
Oh nice job ! looks like you beat me to it, I finished adding my buoyancy code to your yesterday and I put together a few objects of various shapes and densitiesā¦ here is a video showing it
Also added a pirate ship for good measure! Check it out
Fs2RxrdpwQo
Btw, did you figured out what was causing the performance hit? it all runs the same to me, the buoyancy barely has any impact on performance if you use few test points.
That looks man!!! really cool, is that for a game or just a fun project? I may ask you a couple of questions later, but also if you ever want to collaborate on project as well it would be !, or let me know in PM!
And yes - The Performance has been completely resolved, I now get 120+ FPS (Capped at 120) Even With all of the object shown in my video above!!!
It was totally unrelated to the itself, letās just say its fixed and leave it at that (ie Dumb Mistake)