Announcement

Collapse
No announcement yet.

[Community Project] WIP Weather & Ocean Water Shader

Collapse
This topic is closed.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Community Project] WIP Weather & Ocean Water Shader

    Welcome to the community created Ocean Simulation, Weather (WIP), and Dynamic TOD system!

    The point of this project is twofold. First, it aims to provide a realistic ocean water simulation that is both highly customizable, and being as physically accurate as possible. The second aspect is in regards to the weather and time-of-day setup.

    The reason the Weather/TOD is in the same project is due to how much of the ocean itself is driven by the weather around it, to allow integration of real life ocean simulation, both parts are necessary for effects such as wind, rain, and storms. The Beaufort Scale will be implemented to allow custom control of the sea state and weather in one place.


    This project is currently being maintained by:
    - @DotCam
    - @Zoc
    - NilsonLima
    ​​​​​​​- EvoPulseGaming
    - @TK-Master


    List of Contributors

    - Handkor - Initial Shader + Code for Buoyancy
    - Nadrugal - Additions to the SkyDome
    - Komodoman - Fish flocking AI and a variety of fish
    and more to be added shortly, currently rewriting this post.

    Want your name on this list? Feel free to make improvements to the OceanDemo project, and either PM me or Post in the thread below with your addition! Even if you don't think you can help yet, that's no problem! Any suggestions can be left by posting below as well.

    Thanks!

    ----------------------------------------------------------------------------------------------------------------------------------------------------------

    To download (or fork) the project, use the GitHub link below.

    GitHub Link - https://github.com/UE4-OceanProject/OceanProject

    ----------------------------------------------------------------------------------------------------------------------------------------------------------

    This system uses techniques from many tutorials, however it would not have been possible without the help of the following users (Especially Handkor, he deserves a lot of credit for this!):
    Handkor, JBaldwin, berna , ufna, Ehamloptiran, KhenaB, gregdumb and many others. Click on their names to see the corresponding threads!

    For those wanting more info on how the waves are created mathematically, THIS ARTICLE goes over everything. Specifically have a look at the section on "Gerstner Waves" for the actual equations that produce the waves.

    ----------------------------------------------------------------------------------------------------------------------------------------------------------


    Newest Features

    TK-Master added in a bunch of new features during my absence, these are available for the 4.8 & 4.9 versions on GitHub.

    Screens:

    SSR

    (Click for original size)

    Foam

    (Click for original size)

    Shore

    (Click for original size)

    New features:

    -Screen Space Reflections (SSR)
    -Planar Reflection support
    -Infinite Ocean System
    -Distance Blended Normals
    -Configurable Sets of Panning Normals (Small, Medium, Far)
    -Heightmap-based Seafoam & Foam Wave Caps (Thanks Tin Le!)
    -Cubmap-based Reflections (optional)
    -Exposed many parameters to BP_Ocean. - You can now easily switch between shader versions, change textures, normals, foam, cubemap, heightmap etc.
    -Underwater Distortion Effect
    -Underwater Caustics

    -Fixed buoyant destructible physics (too "jumpy")
    -Fixed a few other problems caused by 4.8 engine core changes

    Current known issues:
    SSR shader version uses 14 samplers (might not work in linux/mac.. please let me know)

    New Skydome Features

    I'm releasing the latest code changes for the new Skydome I'm working on in stages. I want to make sure this first part's accuracy is rock solid before adding additional parts, as they will be dependent on sun/moon positions during the day & year. So this is the first of a series of upcoming skydome changes.

    This update is the high accuracy sun & moon positioning, based on the input latitude, longitude, UTC offset, and local time. The calculations for this are very complex, and boring, so I'm only going to go over the values shown in the Debug HUD.

    First, what you will see when you open the project, and how to set it all up for your desired location:

    When you open the project, you will be in a demo level named dcSkyTestMap, which is a copy of the Island Map level with the skydome added. (if you don't want to use the new skydome, the Island Map still has the old one). These 2 arrows will show you the direction of the Sun/Moon (yellow/gray) and will update themselves appropriately, and the compass is set to North == +X axis (has not been rotated, default world placement).
    Click image for larger version  Name:	Arrows.JPG Views:	1 Size:	41.1 KB ID:	1108144

    To change the date & time, select the BP_Sky reference in the World Outliner, and expand the small arrow beside Local Time in the Default section. Here you will also find the controls for Latitude, Longitude, UTC Offset Hours, whether to allow Daylight Savings time (calculated automatically if enabled), and a Time Scale Multiplier which allows you to speed up (or slow down) time. By default this is set to 10 which means 10 seconds of game time goes by every 1 second in real world time.
    Click image for larger version  Name:	DebugTime.JPG Views:	1 Size:	71.1 KB ID:	1108145

    The values are automatically clamped in code to the maximum number of seconds in a minute (59), max hours in a day (23), max days in the current month (28 to 31), etc. I had clamped the sliders to not exceed these values, but for some reason it won't allow you to change the value with it turned on, so just be aware that values greater than min/max do not have any effect.

    Finally we have the Debug HUD, this will look very confusing to most people, but is as simple as I could make it while still providing the necessary information. Here's what it looks like, the values are broken down below:
    Click image for larger version  Name:	DebugHud.JPG Views:	1 Size:	140.1 KB ID:	1108146

    The best way to verify this data is to use this website and enter in the date/time, latitude & longitude info into these boxes (or use the map, but make sure the lat/long are correct):
    Click image for larger version  Name:	Position Website.JPG Views:	1 Size:	31.5 KB ID:	1108147

    With that entered, all of the other fields will populate themselves with data. The values in game vs the values on the website will vary slightly (0.1 to 2 degrees average) and are not meant to be exact, calculating the exact position is not feasible (or necessary) for a game / simulation. Using approximations allows high accuracy, without performance concerns.

    Now, what these values mean:

    SUN
    - Time Correction Factor (TCF): The number of minutes to add/subtract to account for the variation in Solar Time within a gives time zone.
    - Equation of Time (EOT): An equation that corrects for the eccentricity of the earth's orbit and axial tilt for the given date/time.
    - Hour Angle (HRA): Converts Solar Time to the number of degrees the sun has moved. 0 == sun's highest point, so the value will be negative in the east (morning) and positive in the west (evening)
    - Declination: The earth's axial tilt for the given date/time vs the sun. This varies from -23.4397 (northern hemisphere winter) to +23.4397 (northern hemisphere summer).
    - Altitude Angle: The vertical angle of the sun in the sky measured from the horizontal, 0 = sunrise, 90 = highest point of the sun that day (time varies) **NOTE: For this value to work in UE4 coordinates we need to subtract 180 from the result, this is why the value differs in the actual rotator' pitch value.
    - Azimuth Angle: The horizontal compass direction of the sun. At solar noon this angle will be exactly due south (-180) (local time varies)
    - Current Rotator Value: The current rotation of the Sun's Directional Light.

    References used for solar positioning:
    http://www.pveducation.org/pvcdrom/p.../suns-position
    http://www.stjarnhimlen.se/comp/tutorial.html#5
    http://www.powerfromthesun.net/Book/...chapter03.html


    MOON
    - Approximations L/M/F: These are approximations for the location of the moon in it's orbit around the earth, including the inclination of the orbit, orbital eccentricity, arg of perigee, and longitude of ascending node
    - Ecliptic Longitude: The longitude location of the moon on the celestial sphere.
    - Ecliptic Latitude: The latitude location of the moon on the celestial sphere.
    - Mean Distance (km): The distance of the moon from earth, in kilometers.
    - Declination: Similar to the solar declination, this is the angle of the earth's axial tilt, but also takes the inclination of the moon's orbit into account.
    - Right Ascension: Angular position of the moon measured eastward along the celestial equator. Both right ascension and lunar declination are found by converting from ecliptic to rectangular coordinates (x/y/z), rotating to account for earth's axial tilt, then converting back into spherical coordinates.
    - Sidereal Time: A time scale (measured in degrees) based on the rate of earth's rotation relative to fixed stars, rather than the sun. This is a constant value that varies only by location (not time), which differs from the actual definition of Sidereal Time, we only use it as a reference.
    - Hour Angle (HRA): Similar to the sun HRA, however is measured against sidereal time instead of solar time. The number of degrees the moon has moved from time 0 (0 to 360 degrees).
    - Altitude Angle: Same as the sun, vertical height of the moon. Value is found by converting Ecliptic (celestial sphere) coordinates to geocentric (observer to sky) coordinates.
    - Azimuth Angle: Same as the sun, horizontal compass direction of the moon. Value is found by converting Ecliptic (celestial sphere) coordinates to geocentric (observer to sky) coordinates.
    - Current Rotator Value: The current rotation of the Moon' Directional Light.

    References used for lunar positioning:
    http://aa.quae.nl/en/reken/hemelpositie.html
    http://www.braeunig.us/space/plntpos.htm
    http://www.stjarnhimlen.se/comp/tutorial.html#7


    There is an excellent video explaining the basics of how we calculate the time of day, calendar systems, and the earth's rotation in the following video (which came out the day after I posted this). Highly recommend watching it to get a good idea how this works:
    https://www.youtube.com/watch?v=IJhgZBn-LHg


    All of the above calculations are implemented in the plugin to ensure there are no performance issues. The blueprint BP_Sky is based off the TimeManager class (in the plugin) and uses it's functions to calculate the sun/moon/moon phases in the base class. This makes the blueprint much easier to read, and reduces it's complexity considerably. These functions could be used by any actor, such as a custom skydome system, by either adding the actor as a child, or inheriting from the actor and calling the Calculate xxx functions.

    Please try it out, let me know how it works for you, and whether you have any problems. I have been testing the system out and so far it seems to be working great, but feedback would be much appreciated!


    Version 4.12.2 has now been released.

    You can download the new release (and all other versions) from GitHub here
    Last edited by DotCam; 05-13-2018, 03:00 PM.

  • replied
    @NilsonLima: Thread locked for now. I will unlock when DotCam returns or there is a request to unlock this thread.

    All users please use this thread for now: https://forums.unrealengine.com/comm...n-water-shader

    Leave a comment:


  • replied
    qdelpeche Is it possible to lock this thread until we get some news about DotCam. (in this case unlock by his request or he can do it since he is a moderator aswel)

    Everyone, I will continue this project in the following thread: https://forums.unrealengine.com/comm...n-water-shader and any other details and even a new GitHub repository if possible. All credits for this work will still be the same, will still be FREE and will be receiving community contributions as always!

    Leave a comment:


  • replied
    Originally posted by CrashA51 View Post
    30'th post ranting about entitlement
    I have a SERIOUS **** problem with you gunning us down HARD, and as soon as you heard you might get a blueprint version of the ocean, you suddenly became okay with everything.
    ALSO, do not blame US, or anyone who put up the DCMA request for having an issue with someone selling FREE content.
    He could have EASILY submitted his changes to this project and YOU WOULD HAVE EXACTLY WHAT YOU WANT.

    And to finalize this, and end this once and for all:

    A: We have copies of DotCam's original work, you can't protect stolen content, so quit with the epic policy stuff.
    B: DotCam and I have already discussed blueprint version of the ocean months ago, and its NOT GOING TO HAPPEN
    (I'll send screen shots if you really need proof)
    C:Stop complaining, and help give back to the community and fix stuff and submit changes. If Johnathon had done this originally, instead of claiming it as his own work, we wouldn't be talking about this

    D: There seems to be a history of people making copies of this project and making fixes and not giving back to this community. I promise, that if everyone had just taken their fixes and submitted them back here, this project would not have stalled the way it has.

    E: DotCam is MIA.. since the last 3 or 4 months now.. with no word when/if he will/can come back. Its time for the community to step in.

    The technical reason for the ocean not being in blueprints, is because a correctly done ocean will be shader based. If you can't work with it in c++, I don't expect HLSL to suit you any better. We were in the middle of making major changes right up until DotCam left. He has roughly 584 changes that he never committed. My work is dependent on those changes.and I cannot continue without them.

    Without DotCam, the only chance this project has, is when NilsonLima releases his work. He is your best bet for a blueprint version, and that is purely up to him, because no one else is working on this project actively anymore.

    What we need is a refresh, which means, a new thread, started by NilsonLima, with his version. Consider it a fork of this project.

    I will repeat this one last time, but really clear: This thread/project is effectively dead. No one is submitting fixes, no one is working on it. Only NilsonLima is planning a release of any kind. Follow him, follow his new thread. Everyone on the planet knows where it started, credit had been given and defended many times to DotCam and Theokoles ect. But at 169 pages now, and only "maintenance" updates, we need to move on.

    I ask that NilsonLima create a new thread, and that @moderators lock this thread until/if/when DotCam comes back.
    Last edited by EvoPulseGaming; 08-22-2018, 05:39 PM.

    Leave a comment:


  • replied
    Originally posted by ZENVIEW View Post
    Hi people, I have only a short question about the waves ... I have spent some hours playing with the settings but unfortunately I have not received a satisfactory result.

    I would like to create a lake with very calm water almost completely without waves - Similar to here:
    https://www.youtube.com/watch?v=5SybOastSyo

    The ocean comes with rather rough water and high waves, so it is difficult for me to see what settings are needed to "disable" the waves.

    Does anyone have a tip and can briefly explain which settings are responsible for the waves to simulate a calm sea? That would be great. Thanks in advance!!!
    At the BP_Ocean instance, you need to check at the properties down in the section called Ocean Manager. There you will find the parameters needed to do the change you want. Global Wave Speed and Global Wave Amplitude are the ones to give the approximate result you want. Notice that, this is a ocean shader and there isn't likely to behave differently in concept... having a calm water is just a side-effect on how the formulas work at the math.

    Leave a comment:


  • replied
    Hi people, I have only a short question about the waves ... I have spent some hours playing with the settings but unfortunately I have not received a satisfactory result.

    I would like to create a lake with very calm water almost completely without waves - Similar to here:
    https://www.youtube.com/watch?v=5SybOastSyo

    The ocean comes with rather rough water and high waves, so it is difficult for me to see what settings are needed to "disable" the waves.

    Does anyone have a tip and can briefly explain which settings are responsible for the waves to simulate a calm sea? That would be great. Thanks in advance!!!

    Leave a comment:


  • replied
    Originally posted by Masakralny View Post
    There's no way to turn off infinity Ocean generation ? Aaaand why ?!
    Because I don't see check box in BP Ocean options menu , maybe some modification in code or something ? i want to cover some square kilometers ,not infinite world
    In game PUBG there is a bug where you can fall through the ground and see the landscape from the bottom. I've noticed that the whole map is covered by the water without any gaps. So since the landscape is always higher than the water there is no problem in using infinite ocean system.

    Leave a comment:


  • replied
    how long does this project take to open dam

    Leave a comment:


  • replied
    Originally posted by Masakralny View Post
    There's no way to turn off infinity Ocean generation ? Aaaand why ?!
    Because I don't see check box in BP Ocean options menu , maybe some modification in code or something ? i want to cover some square kilometers ,not infinite world
    The Infinity Ocean System is an illusion... it is based of a plane with high density triangle count in the middle and lower density near edges, which we scale its size according to the camera position, and this is to improve performance when the tessellation is in use, which if it is turned off, then it will not matter.

    The project is free and made also on user contributions, so you can modify it as you wish in order to fulfill your needs

    Leave a comment:


  • replied
    There's no way to turn off infinity Ocean generation ? Aaaand why ?!
    Because I don't see check box in BP Ocean options menu , maybe some modification in code or something ? i want to cover some square kilometers ,not infinite world
    Last edited by Masakralny; 08-13-2018, 06:17 PM.

    Leave a comment:


  • replied
    Originally posted by NilsonLima View Post

    Finally I figured it out

    I have tried to make a project from scratch and the surprise is that i got exactly no underwater effect but only the wet lens effect as you did... and then I remembered that the only difference between those two effects was that one is the whole screen while the other need a special depth pass... which I confirmed opening the material to be a custom stencil.

    So to fix you need to go to the project settings and set Custom-Depth Stencil Pass to: Enabled with Stencil

    It could also be avoided if we both have copied the Config.ini file and overwritten the new project.

    Cheers!
    Thanks so much. I have been scouring this forum for 2 hours to get underwater working. I though their must be a problem with the z-index of all my actors being out of sync but no.....a simple project setting. Thanks so much!!!

    Leave a comment:


  • replied
    Originally posted by Masakralny View Post
    Can I align this gorgeous Plugin to Sphree surface somehow without code modification or if I must change something then where ?
    Currently the Infinite Ocean System only works with a plane, so short answer is no. If you want to simulate a planet surface seen from above you will need to use a different material to show the oceans when approaching from space and only shift to the current ocean plugin when it is near enough for the details you want to show.

    Leave a comment:


  • replied
    Originally posted by Masakralny View Post
    Can I align this gorgeous Plugin to Sphree surface somehow without code modification or if I must change something then where ?
    Good question though. For space-travelling games.

    Leave a comment:


  • replied
    Can I align this gorgeous Plugin to Sphree surface somehow without code modification or if I must change something then where ?

    Leave a comment:


  • replied
    Originally posted by Freddiieehh View Post
    I updated my engine to 4.20 quite a while ago, but recieves this error:

    "The following modules are missing or built with a different engine version: OceanPlugin. Would you like to rebuild them now?"

    How do I move around this?
    Rebuild would be the next step when engine release changes, but sometimes engine's APIs change and it might require changes in the source code for a rebuild to succeed. We still didn't update the repository at GitHub with the 4.20 because we are in the process of heavy changes in the plugin.

    You can just rebuild or open the .sln file and build from Visual Studio and then open the project again in the UE Editor.

    Leave a comment:

Working...
X