Skip to content

mozhaa/opengl-water

Repository files navigation

OpenGL Water Simulation

Screenshot

20-01-2025.14-23-51.mp4

Assignment PDF: assignment.pdf

Water Height Function

The water heights map is generated using sum of radial sine waves with random centers, so that amplitude * frequency for each wave is constant (large waves have high amlitude and low frequency, and small waves have low amplitude and high frequency).

Reflection + Refraction

  • The reflected ray is derived from law of reflection;
  • The refrected ray is calculated using Snell's Law;
  • The ratio between reflected and refracted light is calculated using Schlick's approximation.

Caustics

Caustics are drawn on the pool's bottom via rendering with additive blending. For each triangle of water mesh we calculate reflected ray, intersect it with the pool's bottom, and draw semi-transparent white pixel at the point of intersection.

The alpha channel of this pixel depends on the ratio of areas of two projections of our triangle:

  • projection onto the surface orthogonal to sunlight direction;
  • projection onto the pool's bottom.

So if some large triangle was projected onto small area on the pool's bottom, it will be brighter (article).

About

Computer Graphics final project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages