Search Unity

Seamless water waves simulation on a planetary sphere

Discussion in 'Assets and Asset Store' started by kulesz, Aug 23, 2021.

  1. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    140
    Hi,

    I've created a simple implementation of water shader based on classic Gerstner Waves - but modified to match the surface of a sphere. Unlike the most of the "flat" water surface implementations, this one wraps perfrectly around a planet or any spherical mesh.

    Inspired by paper Real-Time Rendering of Procedurally Generated Planets (by Florian Michelic).

    This is just a prototype project, not suitable for instant use in production, but I hope somebody will find it useful.
    Source: https://github.com/kulesz/PlanetaryWater

     
    Setzor likes this.
  2. benjmitch

    benjmitch

    Joined:
    Nov 27, 2019
    Posts:
    17
    That looks great, thanks for sharing.

    I've been working with a spherical water surface myself - my efforts look childish alongside this. Mostly that's because I'm a beginner, but I'm also finding it a challenge to support both over-water and under-water viewpoints seamlessly, and implementing at least approximately-correct-looking shadowing of above-water objects as the light source moves across the sky, past the horizon, and finally shines from below. I /think/ all of that is being made rather more difficult because of the spherical geometry, not just that I'm doing it all wrong.

    Questions: Is there support for a view from under-water, here? Has shadowing been given any attention?

    I am going to have to come back to the water rendering later, when I do I look forward to trying this out.
     
  3. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    140
    Hi,
    No, underwater view was not developed, as it was not part of the scope.
    Shadows are simple, taken from base URP shaders.
     
  4. UsualSpace

    UsualSpace

    Joined:
    May 20, 2022
    Posts:
    1
    Hello. I have also implemented a spherical ocean shader based on this very paper, however I am experiencing issues with normal calculation. I followed along with the paper and also checked out your code but it seems the normals do not take the sharpness/crest of the wave into account. It acts as if the wave is smooth and does not condense anywhere. Maybe I did something wrong but would you know why that is? I am not using unity so I could not try out your shader.
     
  5. Setzor

    Setzor

    Joined:
    Mar 10, 2014
    Posts:
    10
    @kulesz is there a way to modify the vertex shader so that based on depth of an intersecting (layer filterable) object it will lessen the amount of affect the waves have. for instance doing shorelines of an island.

    i imagine it could be done with some sort of depth test, but i'm not well versed enough in shader language to even try.
     
    dimzki likes this.