• Stars
    star
    360
  • Rank 117,619 (Top 3 %)
  • Language
    C#
  • License
    MIT License
  • Created over 1 year ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

AcerolaFX

A suite of GShade shaders for Final Fantasy XIV
HLSL
896
star
2

Post-Processing

My Unity post processing pipeline and shaders
ShaderLab
573
star
3

Grass

An exploration of various grass rendering techniques
C#
256
star
4

Pixel-Sorting

A "real time" pixel sorter for Unity
C#
190
star
5

Shell-Texturing

Volumetric rendering of fur
C#
175
star
6

CS2-Smoke-Grenades

My recreation of CS2's responsive smoke grenades in Unity
C#
165
star
7

Inktober-Ink-Shader

An ink drawing post processing shader
ShaderLab
70
star
8

Disney-PBR

An implementation of Disney's principled BRDF
C#
52
star
9

CRT-Shader

A recreation of Loop Hero's CRT shader
C#
45
star
10

Minecraft-Shaders

Shaders for Minecraft
GLSL
40
star
11

obs-scripts

OBS scripts I have made to help my stream and others
Python
31
star
12

Cellular-Automata

Unity project demonstrating concepts introduced in my video on Cellular Automata
C#
28
star
13

The-Dating-Game

My submission for Ludwig's 2021 10 day game jam
C#
26
star
14

Elden-Ring-Stars

A recreation of Elden Ring's star particles
C#
20
star
15

Gooch-Shading

An implementation of Gooch Shading
ShaderLab
17
star
16

Image-Effects

Post processing in Unity
C#
7
star
17

World-Generator

Terrain generator for environment inspiration
GLSL
6
star
18

Chaikin-Curves

Code for my animation used for my video on Chaikin Curves
JavaScript
5
star
19

GarrettGunnell

4
star
20

Compute-Particles

GPU driven particle system demonstration
C#
3
star
21

Graphics-Reference-Sheet

Graphics programming related notes
3
star
22

Ray-Marcher

That thing literally everyone makes
C#
3
star
23

Watchy-Firmware

My firmware for the Watchy, an open source E-ink watch
C
3
star
24

Linear-Congruential-Generator

Basic python LCG
Python
3
star
25

DirectX11-Base-Framework

A basic DX11 framework that renders a textured quad
C++
2
star
26

Fluid-Simulation

Shallow water equations modeled in Unity
C#
2
star
27

Pixel-Sorter

Python
1
star
28

Data-Structures-Handbook

A collection of data structures I've learned.
1
star
29

Compute-Ray-Tracer

GPU Ray Tracing
C#
1
star
30

Marching-Cubes

Marching Cubes is an algorithm for triangulating procedural meshes
C#
1
star
31

cs160-zombulator

Zombie outbreak simulator for cs160.
JavaScript
1
star
32

Portfolio

My portfolio website
Svelte
1
star
33

Random-Shaders

Miscellaneous shaders
ShaderLab
1
star
34

Ray-Tracer

My implementation of a ray tracer following Jamis Buck's 'The Ray Tracer Challenge'
C++
1
star