Tips on rendering oceans in Unreal4

Discussion in 'Game Development (Technical)' started by DMATH, Apr 6, 2016.

Tags:
  1. DMATH

    DMATH New Member

    Joined:
    Jan 31, 2016
    Messages:
    44
    Likes Received:
    11
    Ocean rendering in UR4 lacks documentation and is difficult to set up, I resorted to using mesh planes manually placed on the shoreline with a shaderset to replicate shore waves while I have a huge mesh plane slightly underneath my level that is the ocean itself , while it's great for the type of project I'm doing (rts) it lacks that realistic perspective, anyone know anywhere I can get some sweet pointers on rendering realistic oceans? Doesn't have to be Unreal related.
     
  2. DMATH

    DMATH New Member

    Joined:
    Jan 31, 2016
    Messages:
    44
    Likes Received:
    11
    Never mind I figured it out, might post a tutorial on it someday
     
  3. GameDevil

    GameDevil New Member

    Joined:
    Apr 13, 2016
    Messages:
    24
    Likes Received:
    7
    I've just joined today and have only seen this now. I'd love to hear about how you're rendering oceans in UE4. At the same time, for others who may be interested in different methods, I have been thinking of a method but have not tried it in UE4 yet. Here's how I would go about it:

    First, I think it's worth mentioning that I go for realism as much as possible and had realism in mind when I thought of rendering an ocean this way. With that in mind, understand that this method does need a lot of draw calls, but you should be able to manage it if a realistic ocean is important enough to you.

    The first step would be to make an ocean in Blender, using the ocean modifier. Once it is how you like it, export it to a series of height maps. You'll also be exporting the foam data to go with it. You can easily find a tutorial on Youtube to accomplish this.

    Second, you'll need to set up a material in UE4. I won't get into any details about that since I haven't done that for this purpose yet, but again you can easily find a tutorial or just look at documentation and whip something up that you're comfortable with. In this material, you would import your height map sequence to animate your ocean, and import your foam data as well.

    Now here's the tricky part. I'm not 100% sure about how to accomplish this since I haven't gotten my hands dirty with it yet, but the idea is to paint an alpha map based on the character's movement. It doesn't need to be very large, just big enough to encompass the player and a small area around them. You would apply this alpha map as a mask in the material to alter the height maps. This would affect the water the player is touching by depressing it to whatever degree you set it to. Let me see if I can explain this better. Picture a white quad laying down flat under the player, and the player's position is painted in black on this square with a smooth falloff. This would essential be your alpha map that you use to alter the effect of the height maps on your ocean quad. If you wanted to do a trail effect, you would draw a sequence of alpha maps with gradually decreasing strength.

    I hope this makes sense to you. If you have any questions, just ask in a reply and I'll try to elaborate further.

    It should be noted that this method is not cheap on draw calls by any means. However, you can make a very realistic looking ocean and your player and other objects can affect it. The trick is figuring out how to paint the alpha map based on your character's location. If you had a lot of draw calls to spare, you could perhaps pre-draw several simple and unchanging alpha maps for whichever parts of the player's body you want affecting the water and just attach them as part of the actor.

    *** EDIT ***
    I was just thinking that it's probably simpler to draw 3 alpha maps, one for the torso at the point where it starts to go above the water, and one for each arm. You can just attach these. Now the challenge would be to update their transforms in order to alter the height maps in the right areas. Is this possible in UE4? I imagine it would be, but how easy would it be? To anyone who has enough experience to comment on this, I await your reply!
    *** /EDIT ***

    Anyway, this is just an idea I've been mulling over. It needs a lot of optimization at this stage. I hope this helps!
     
    #3 GameDevil, Apr 13, 2016
    Last edited: Apr 13, 2016
  4. DMATH

    DMATH New Member

    Joined:
    Jan 31, 2016
    Messages:
    44
    Likes Received:
    11
    Well the issue isn't the ocean itself rather the waves that form close to the shoreline, what I did was duplicate my ocean material, replace the water texture with a clear foamy substance, up the wave height and increase panning. Than I use an custom painted shoreline (static) when renderd from a distance.

    Next I used some curved meshes, placed them around the island with the curved end faceing away from the shoreline and the flat part faceing in, applied the foam material and boom! Perfect rts quality ocean shore.

    Tessellation node, sine node, cosine node, panning node, plane mesh and a few textures is all you need really to make a half decent ocean.
     
    #4 DMATH, Apr 14, 2016
    Last edited: Apr 14, 2016
  5. GameDevil

    GameDevil New Member

    Joined:
    Apr 13, 2016
    Messages:
    24
    Likes Received:
    7
    That sounds pretty cool. Can we see what it looks like now? If you could explain it in further detail, perhaps provide some screenshots of your setup, that would really be helpful.
     
  6. DMATH

    DMATH New Member

    Joined:
    Jan 31, 2016
    Messages:
    44
    Likes Received:
    11
    Right now I'm building lightmaps and it's hogging everything so these screenshots are an earlier version of the build, for reference I used


    https://forums.unrealengine.com/sho...ty-Project-WIP-Weather-amp-Ocean-Water-Shader

    The ocean texture is from their and the materials I tweaked also originated their until I discovered I don't need fancy water so I built from scratch (almost done custom ocean textures, keep in mind this project is an 4k rts.

    It's been 2 days since I started building lightmaps
     
  7. GameDevil

    GameDevil New Member

    Joined:
    Apr 13, 2016
    Messages:
    24
    Likes Received:
    7
    Okay, that's not bad. It's definitely better than what I've got for shores.

    I'd be very happy to know how to do this:


    I'm going to google RealFlow now. If it's an addon or something, or even a standalone program that allows export to height map...



    This one looks even better! http://cgterminal.com/2013/08/26/houdini-creating-continuous-waves-with-flip-tank-tutorial/
     
    DMATH likes this.
  8. DMATH

    DMATH New Member

    Joined:
    Jan 31, 2016
    Messages:
    44
    Likes Received:
    11
    Well good luck, in the end I didn't really need that fancy flow water anyway.
     
  9. GameDevil

    GameDevil New Member

    Joined:
    Apr 13, 2016
    Messages:
    24
    Likes Received:
    7
    I think I have it! Rather, I have a theory on how to make proper crashing waves. It's a bit long winded and I don't have anything to show you yet. It's a lot of work and I'm just not at that point in my project yet. I won't get around to it for months, so I'll just share with you and you can do it yourself.


    First, I wasn't far off with using a displacement map sequence to form the animated surface of the ocean and applying a mask to gradually reduce the height all the way to 0 at the edges. The idea is to keep the waves huge closer to the center, and almost non-existent by the shore. The waves near the shore are made up of a separate displacement map sequence. What I suggest is to set up collision points wherever you want your waves to start, and trigger them when the first ocean plane touches them. That way, the 2nd plane's waves would mesh into the first plane's waves, they would appear to be one and the same.

    As for the 2nd plane, you'll need a sequence of displacement maps that are drawn to look like a wave first gaining height, then dropping off slowly until it reaches the shore. The center should be tallest and it should curve out in the direction that the wave is travelling in. You can set it up as a decal since you'll be using triggers.

    Lastly, you can set up another animated decal on the beach for the wet sand effect and trigger it when the wave decal touches it.



    This is a lot of work to put together, but I think you can essentially get something that looks as true to life as you can get.
     
    DMATH likes this.
  10. DMATH

    DMATH New Member

    Joined:
    Jan 31, 2016
    Messages:
    44
    Likes Received:
    11
    Okay you got me excited
     
    GameDevil likes this.
  11. GameDevil

    GameDevil New Member

    Joined:
    Apr 13, 2016
    Messages:
    24
    Likes Received:
    7
    LOL IKR?

    I'm tempted to put my workflow aside to try this out. If you try it, let me know how it goes.
     
  12. DMATH

    DMATH New Member

    Joined:
    Jan 31, 2016
    Messages:
    44
    Likes Received:
    11
    When I get a chance i shall
     
  13. kaufenpreis

    kaufenpreis New Member

    Joined:
    Aug 1, 2014
    Messages:
    104
    Likes Received:
    4
    Never mind I figured it out, might post a tutorial on it someday
     
  14. GameDevil

    GameDevil New Member

    Joined:
    Apr 13, 2016
    Messages:
    24
    Likes Received:
    7
    Figured what out?
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer