Coder Social home page Coder Social logo

snakiex / unitywater Goto Github PK

View Code? Open in Web Editor NEW

This project forked from garrettgunnell/water

0.0 0.0 0.0 4.67 MB

Sum of sines and fft fluid simulation with a physically based water shader

License: MIT License

C# 71.76% GLSL 25.02% ShaderLab 3.22%

unitywater's Introduction

Water Rendering

by Garrett Gunnell

This repo contains the code associated with my videos on the same subject.

Features

  • Sum Of Sines Fluid Simulation (from GPU Gems)
    • Sine Wave
    • Exponential Sine Wave
    • Gerstner Wave
  • FBM Fluid Simulation
    • Euler Wave (idk that's what I'm calling it)
  • Analytical Normals For Both
  • Basic Atmosphere Shader
    • Distance Fog w/ Height Attenuation
    • Sun
    • Simple Skybox Animation
  • Basic "PBR" Water Shader
    • Blinn Phong
    • Fresnel Reflectance
    • Optional Cubemap Reflections
  • Fast Fourier Transform Fluid Simulation (Tessendorf)
    • Dual JONSWAP (4 layered frequency bands)
  • An Actual PBR Water Shader
    • Microfacet BRDF
      • Beckmann Distribution
    • Approximate subsurface scattering

These shaders aren't optimized (there is a lot of trash left around for demo purposes) or intended to be used as a production ready asset. Please use as a reference for your own shaders.

What's Missing?

  • Buoyancy
  • Wakes and other water interactions

Will do someday!

Examples

Sum Of Sines

This method is really cheap and is ideal for small bodies of water like ponds or maybe lakes, it is not ideal for large bodies of water like oceans because it tiles very quickly.

example1

Fast Fourier Transform

This method is the big daddy of the simple sum of sines and uses oceanographic spectrums to generate a frequency domain ocean height map which we then convert to the time domain with the inverse fast fourier transform, effectively summing millions of waves instead of just a few like the simple sum of sines. This is obviously overkill for small bodies of water, but necessary for large bodies to have a realistic water surface with basically no tiling.

example2

References

https://developer.nvidia.com/gpugems/gpugems/part-i-natural-effects/chapter-1-effective-water-simulation-physical-models

https://iquilezles.org/articles/fbm/

https://www.shadertoy.com/view/MdXyzX

http://filmicworlds.com/blog/everything-has-fresnel/

https://boksajak.github.io/files/CrashCourseBRDF.pdf

https://people.computing.clemson.edu/~jtessen/reports/papers_files/coursenotes2004.pdf

https://www.keithlantz.net/2011/11/ocean-simulation-part-two-using-the-fast-fourier-transform/

https://gpuopen.com/gdc-presentations/2019/gdc-2019-agtd6-interactive-water-simulation-in-atlas.pdf

https://wikiwaves.org/Ocean-Wave_Spectra

https://github.com/iamyoukou/fftWater

https://www.slideshare.net/Codemotion/an-introduction-to-realistic-ocean-rendering-through-fft-fabio-suriano-codemotion-rome-2017

unitywater's People

Contributors

garrettgunnell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.