-
Notifications
You must be signed in to change notification settings - Fork 36
Underwater Visuals
Underwater Visuals (Mochie/Underwater Visuals) is the companion shader to the Water Shader. It adds blur, caustics, and fog to the viewer's screen while they're under the water.
The effect is drawn over the whole screen whenever any part of the object is in view, so the prefab uses a large cube that covers the underwater area. Enable Falloff to only show the effect while the viewer is inside a box, such as the volume below the water's surface. The effect is hidden in mirrors, and doesn't render on mobile platforms like Quest.
The water surface writes a stencil value wherever it's drawn, and the caustics skip those pixels, so they light the geometry under the water but not the water's surface itself. Both materials must use the same Stencil Reference.
A ready-made Underwater prefab is in Assets/Mochie/Unity/Prefabs, alongside a Depth Light prefab, which this shader requires. The Underwater prefab already includes one.
- Render Queue: When the effect draws relative to other objects. It defaults to 3001 (Transparent+1), just after the water surface, which it needs for the stencil. Anything that draws after the effect isn't blurred or fogged.
- Stencil Reference: Must match the Stencil Reference of the water's material.
-
Falloff: Only shows the effect while the viewer is inside a box. The box follows the object's position and rotation, but not its scale. The effect switches on and off instantly as the viewer crosses the box's edges. While the object is selected, the box is drawn in the Scene view.
- Size: The width, height, and depth of the box in meters, along the object's local axes.
- Offset: Moves the box away from the object's position, in meters, along the object's local axes.
Blurs the view and applies the tint and hue settings below. The tint and hue settings only apply while Blur is enabled.
- Strength: How far the blur spreads. Higher values give a stronger blur.
- High Quality: Uses about three times as many samples and a slightly wider blur, which gives a smoother result at a higher cost.
-
Depth of Field: Keeps nearby objects sharp and blurs distant ones, based on their distance from the viewer.
- Radius: The distance from the viewer, in meters, at which the blur reaches full strength.
- Fade: How far before the Radius the blur starts, in meters. Objects closer than Radius minus Fade stay sharp.
- Screen Tint: A color multiplied over the whole view.
- Hue: Shifts every color around the color wheel. 0 and 1 are both the original colors. With Auto Hue Shift on, this becomes Shift Speed, which sets how fast the hue cycles.
-
Hue Mode: The method used to shift hue.
-
HSV: Standard hue shift. -
Oklab: A more subtle, less saturated hue shift that better preserves perceived brightness.
-
- Mono Tint: Forces all colors to the same hue (set by Hue), varying only in brightness and saturation.
- Auto Hue Shift: Continuously cycles the hue over time.
Projects moving light patterns onto everything around the viewer, like sunlight filtering down through the surface. They're added on top of the scene, fade out with distance, and don't appear on the sky.
-
Style: How the caustics are generated.
-
Voronoi: Procedural, generated in the shader. No texture needed. -
Texture: A caustics texture, layered twice for movement. -
Flipbook: An animated caustics texture array. Gives the most realistic motion.
-
- Caustics Texture (Texture): The caustics pattern.
- Caustics Flipbook (Flipbook): The animated caustics texture array.
- Color: The color of the caustics.
- Strength: How bright the caustics are.
- Range: The distance from the viewer, in meters, within which caustics are at full strength.
- Fade: The distance, in meters, over which caustics fade out beyond the Range.
- Power (Voronoi): How thin and sharp the caustic lines are. Higher values give thinner lines.
- Dispersion (Voronoi and Flipbook): Separates the red, green, and blue channels, giving the caustics rainbow-colored edges.
- Speed: How fast the caustics animate. In Flipbook mode, this is the flipbook's playback speed.
- Scale: How large the caustic pattern is. Higher values give smaller patterns.
- Rotation: Rotates the caustics projection in 3D space. This changes the angle they're projected at, like the angle of the sun.
- Rotate With Light: Rotates the caustics projection to align with the directional light vector in the scene. If no directional light is present, falls back to the manual rotation setting.
-
Distortion (Voronoi and Texture): Warps the caustics so they wobble naturally.
- Distortion Texture: The normal map that warps the caustics.
- Distortion Strength: How far the caustics are warped.
- Distortion Scale: The size of the warping pattern. Higher values give a smaller pattern.
- Distortion Speed: How fast the warping pattern moves on each axis.
Fills the view with colored fog that thickens with distance from the viewer. It covers everything behind it, including the sky.
- Color: The color of the fog (HDR).
- Opacity: How opaque the fog gets at full thickness. At 1, anything past the Radius is completely hidden.
- Radius: The distance from the viewer, in meters, at which the fog reaches full thickness.
- Fade: How far before the Radius the fog starts, in meters. Objects closer than Radius minus Fade are clear of fog.
Mochie's Shaders β’ Created by Mochie β’ GitHub β’ Found an issue? Submit a report