Skip to content

softcat477/Water-Surface-Shader

Repository files navigation

Water Surface Shader / Buoyancy

in Unity's URP pipeline! Make sure to enable depth texture and opaque texture!

Water Surface Shader

  • Show Depth/Screen Position/Underwater Depth/.../Final: Toggle each to show individual features that make up this feature. Toggle Show Final to show the complete shader.

  • Underwater Depth Scale: controls how deep you want to see objects beneath the water surface.
  • Underwater Near/Far Color: The colour tinted to underwater objects. Use alpha channels to control the level of objects' original colour. Near colour is tinted to objects that are close to the water surface, and the Far Color is the counterpart.
  • Underwater Color Weight: The weight to mix between Underwater Color and the colour controlled by the Fresnel effect.

  • Near/Far Color: The colours that tint near and far fields. Fresnel Bias/Scale: The bias and scale of the Fresnel effect. Just don't touch it (?)

The underwater refraction is controlled by the x and z components of normal vectors.

  • Refraction Normal Weight: Controls the degree of refraction affected by normal vectors.
  • Reflection Normal Vector Scale: Show fine/coarse reflection pattern.
  • Reflection Normal Vector Offset Scale: How smooth/rough the reflection be.
  • Reflection Color Step Threshold: Control the area of the reflection pattern.
  • Spot Light World Position: The world position of a spotlight. For now, it only supports one spotlight.

Ripple only shows up near objects.

  • Ripple Flow Texture: Control the flow of ripples.
  • Ripple Frequency/Octave: How dense you want the ripple to be.
  • Ripple Width: Control the width of ripples:
  • Ripple Range: Control the area of ripples.
  • Ripple Wiggle Speed: Control the distortion speed of ripples.

  • Wave: Wave motion is controlled by three Trochoid waves: Wave A/B/C
  • Steepness controls the amplitude of each wave. The sum of the steepness of three waves should not be greater than 1.0, or you'll get funny artifacts.

Buoyancy

  1. Attach the Buoyancy.cs script.
  2. Create buoyancy effectors ad child game objects.
  3. Add effectors to the Anchors variable.
  4. Assign the water surface to the Water Surface variable.
  5. Change Volume Per Distance to adjust the buoyance force. The larger, the stronger the buoyance force is.
  6. Change Drag to adjust the drag force. A larger value means fewer floating and wobbling movements.

About

Unlit water surface shader in Unity's URP pipeline

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published