1. 1
Samaritan
Join Date
May 2014
Posts
113

## Dynamic physical ocean

I wanted my objects to float. This water is updating object using a heightmap lookup.

https://wiki.unrealengine.com/Render_Target_Lookup

Updates: You can still follow the wiki but I've updated my project to used a mathematical approach.

2. 0
Patron
Join Date
May 2014
Posts
36
Looks pretty good, I'd be interested to see the code/blueprints (whatever you used) on how you did this, I've been looking for something slightly similar but without the ocean e.g: imagine a floating object say a flying car that when flying over uneven terrain will wobble / move with the terrains height map due to the way the air pressure underneath it is working.

3. 0
Samaritan
Join Date
May 2014
Posts
113
I will be putting up a tutorial soon.

4. 0
Patron
Join Date
Apr 2014
Posts
43
This is really cool. I liked watching the boxes float up from resting on the floor when the wave come.

Looking forward to seeing your tutorial for this!

5. 0
Luminary

Join Date
Mar 2014
Posts
1,749
Looks great!

6. 0
Legend

Join Date
Mar 2014
Posts
2,677
Really cool!

7. 0
Samaritan
Join Date
Apr 2014
Posts
120
Really nice. Well done!

8. 0
Samaritan
Join Date
May 2014
Posts
113

9. 0
Veteran

Join Date
Mar 2014
Posts
307
Looks cool, I like your ocean and physics!

I'm using the same approach for ships physics, but with reading from Texture2D, not RenderTarget2D.

Btw, how do you simulate buoyancy? Are you using crossed tension dots, or splitting mesh into volumes?

10. 0
Samaritan
Join Date
May 2014
Posts
113
Nothing sophisticated, I use a very inaccurate approximation by placing points around the hull of the ship. I then apply buoyancy at each point by dividing the mass/displacement evenly across all points. Right now it give decent non-realistic results. I plan on improving the calculation in the future.

I have not heard of crossed tension dots, what is it?

11. 0
Veteran

Join Date
Mar 2014
Posts
307
Originally Posted by Handkor
Nothing sophisticated, I use a very inaccurate approximation by placing points around the hull of the ship. I then apply buoyancy at each point by dividing the mass/displacement evenly across all points. Right now it give decent non-realistic results. I plan on improving the calculation in the future.

I have not heard of crossed tension dots, what is it?
I mean the same approach - dots around the object. It's common way, but not the best results, because it doesn't count real archimedes force influence. I've used volumetric approach on Unity, and I think I should find time to move the trick to UE4

12. 0
Promoter
Join Date
Mar 2014
Posts
156
THIS IS SO COOL!!!!!!!!!! This is exactly the sort of thing I was looking for! you did some really great work on this, I would really love to use this in my game since I am planning to make a island with a ocean that looks realistic, I tried to do in Cryengine 3 SDK but the engine was a bit too complicated for me. I will do my best to follow the wiki.

13. 0
Patron
Join Date
Apr 2014
Posts
30
This is awesome!

14. 0
Infiltrator
Join Date
Mar 2014
Posts
19
Looks great!!!!

15. 0
Unreal Engine Support
Join Date
Apr 2014
Posts
635
Amazing work Handkor!! Can't wait to give the tutorial a shot.

16. 0
Patron
Join Date
Mar 2014
Posts
46
Amazing work. Looking forward for tutorial

17. 0
Champion

Join Date
Mar 2014
Posts
565
Very good work, thank you for going to the trouble of creating such an in-depth tutorial.

Is there any way to make it so the height map can be affected by actors? Like moving through the water creates ripples, etc.

I did something similar to this in UDK using a material which read it's normals from a fluid surface actor.

18. 0
Unreal Engine Support
Join Date
Apr 2014
Posts
145
Great job! I'm looking forward to the tutorial.

19. 0
Samaritan
Join Date
May 2014
Posts
113
Originally Posted by CharlestonS
Very good work, thank you for going to the trouble of creating such an in-depth tutorial.

Is there any way to make it so the height map can be affected by actors? Like moving through the water creates ripples, etc.

I did something similar to this in UDK using a material which read it's normals from a fluid surface actor.
Yes, create another render target and have your actors render concentric circles or ripples on it at their location. Blend this target over the wave generator and send that to the render target that is read by the code. That is is you want the ripples to also affect height for other actors. If their are esthetic only then blend those ripples to the bumpmap and have them shown in the displacement map only.

20. 0
Samaritan
Join Date
May 2014
Posts
113

21. 0
Samaritan
Join Date
Mar 2014
Posts
92
Very nice!!! Congratulations!!!

22. 0
Veteran
Join Date
Apr 2014
Posts
425
Very nice, now you just need a little splish splash!

23. 0
Patron
Join Date
Apr 2014
Posts
30
amazing work!!

24. 0
Samaritan
Join Date
May 2014
Posts
113
Started playing around with adding wakes to the boat and as much as I wanted to stick to a mostly blueprint approach, drawing to a Render Target with a canvas is working pretty well so far.

Anybody know how to draw a material to a canvas, it would help me skip a step?

25. 0
Luminary

Join Date
Mar 2014
Posts
1,749
Canvas has a DrawMaterialTile function, that could serve your needs.

Your overall approach is quite expensive though as you're reading from waves in the texture to drive your gameplay - before getting too involved with what you're currently doing, I would consider changing the technique so that you're writing from the gameplay code to the texture instead

26. 0
Samaritan
Join Date
May 2014
Posts
113
I know this is all expensive, I'm mostly using it for rapid prototyping. The wave calculations can be changed to a mathematical approach at some point and bypass the RenderTarget read part of the project. The wakes so far are only one way where the actors draw to a texture that is then used by material

I'm actually doing this to build the rest of the game until we get nVidia's WaveWorks or UE4 has a built in water/ocean system.

Although when I was working in XNA, which just wraps DirectX 9, the render target read was not that expensive and you could get to it's buffer directly like you can with a texture.

27. 0
Samaritan
Join Date
May 2014
Posts
113

28. 0
Mythic

Join Date
Apr 2014
Posts
2,225
Originally Posted by Handkor
Awesome! Thank you for making a tutorial on this, great work!

29. 0
Patron
Join Date
Aug 2014
Posts
32
I always like some good fluid dynamics.

I've been meaning to make a fluid simulator one day.

Good work.

30. 0
Former Staff
Join Date
Mar 2014
Posts
2,135
Wow, the tutorial video is so useful. Thank you so much for showing the community how you achieved this. Handkor, would you mind if we made a page for your video on the Epic Wiki?

31. 0
Samaritan
Join Date
May 2014
Posts
113
I don't mind. I had already attached the video to my other wiki entry as this is a disconnected part 2. This technique works for anything you can get a height value from.

32. 0
Unreal Engine Marketplace
Join Date
Mar 2014
Posts
1,913
Hi Handkor,

33. 0
Samaritan
Join Date
May 2014
Posts
90
Originally Posted by Handkor
I don't mind. I had already attached the video to my other wiki entry as this is a disconnected part 2. This technique works for anything you can get a height value from.
is your ocean material in first tutorial can wave? mine is like freezed.(i put it into teselated(waterplane)plane)

34. 0
Samaritan
Join Date
May 2014
Posts
113
Originally Posted by ihavenick
is your ocean material in first tutorial can wave? mine is like freezed.(i put it into teselated(waterplane)plane)
Did you attach a panner to your UV for the textures and are each texture using a different speed.

35. 0
Patron
Join Date
Jun 2014
Posts
39
Hello,

Thanks for sharing the material, it looks great

Only problems I have with all my water shaders are shores...

http://puu.sh/aMuXQ/c507fe7789.jpg

Do you have any idea how I could smooth correctly transitions between water and landscape without having to use transluency and depthfade? (because it removes specular lighting...)

36. 0
Samaritan
Join Date
May 2014
Posts
113
No I haven't tackled shores yet.

37. 0
Samaritan
Join Date
May 2014
Posts
90
Originally Posted by Handkor
Did you attach a panner to your UV for the textures and are each texture using a different speed.
Opps i forgot the speed input.So sorry.But there is no big waves.Where we will set big waves ?

38. 0
Patron
Join Date
Jun 2014
Posts
39
Originally Posted by ihavenick
Opps i forgot the speed input.So sorry.But there is no big waves.Where we will set big waves ?
There is one or two parameters included in his material you can tweak to obtain big wave
Also make sure the plane is big enough, and not only a heavy-scaled little plane shape.

Originally Posted by Handkor
No I haven't tackled shores yet.
I just found a hacky way to do what I wanted actually...

I create 2 different materials and place 2 big planes.
On the first plane, I apply a "far" material which is opaque and masked. If the distance from the camera is < 5000 for instance, the opacity mask is 0.

On the second plane, I apply a "near" material which is translucent and create my shores and tweak a bit the reflection so it doesn't look that bad..
I then fade it so the transition from the near to the end material doesn't look bad.

That way I have great reflections on the far of my ocean and nice transition between water and landscape seen from near.

39. 0
Champion
Join Date
May 2014
Posts
620
Thanks alot for that 30min video tutorial. Amazing !

40. 0
Patron
Join Date
Apr 2014
Posts
44
It seems that the OceanManager class is not included in tutorial? So basically I have to modify HeghtMapReader, I mean add those new functions?

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•