Based on Research From
GPU Gems, Chapter 1. Effective Water Simulation from Physical Models, NVIDIA: https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch01.html
Github Link
Water Proj: https://github.com/reforia/WaterProj
Result
Brief Introduction
This project is mainly trying to research and implement water shader based on GPU Gems Chapter 1 , the goal for the project is to create a believable, variant water shader that can provide dynamic visual looks, with large seamless scale water volume yet still have decent performance that can run on a modern GPU at realtime.
Materials and Material Functions Structure
Core Material
----MODULE BREAKDOWN----
Basic Mathematics / Algorithms / Terms
The biggest challenge is to implement the shader in Unreal, by manipulating the water surface vertex in real-time.
According to the book, the key to simulate realistic water waves is to blend multiple sine waves together, then manipulate them to give them a more natural look. (Gerstner Wave function for example)
Base Color
Firstly, base color is simply just a tint of distorted scene color (which creates a refraction effect, see "Refraction" below), then it is interpolated by a depth test, to mimic the feeling of depth.
Mathematically Generated Height
Since the wave function is using gerstner:
This function can be translated to unreal hlsl by:
Where float3 WavePos; float CigmaX; float CigmaY and float CigmaZ are all inputs from outside
Procedurally Generated Normal
The normal will be:
Which is the cross product of a vertex's Binormal and Tangent, in Unreal hlsl:
Here, DDX H(X,Y,T) is used to calculate the mix of all four curves:
Distance-Based Tessellation
Refraction
Refraction is using a distort of the sample uv of background scene color buffer:
Comments