advanced

#27 Water & Waves

Procedural ocean with layered sine waves

Simulate water by layering sine waves at different frequencies and directions to build a height field. Compute the surface normal from the height gradient for lighting. Strong specular highlights from pow(max(dot(reflect, viewDir), 0.0), shininess) sell the wet look. A Fresnel term makes edges more reflective, just like real water.

Key Concepts

Try this shader live in the Shader Sandbox editor with real-time preview.
Open in Sandbox

Source Code


    
← Previous Julia Set Next → Fire & Smoke

All Tutorials