-
Notifications
You must be signed in to change notification settings - Fork 36
Water Shader
The Water Shader (Mochie/Water) is a water shader for worlds: oceans, lakes, rivers, pools, and stylized liquids like lava. For the view below the surface, see Underwater Visuals.
| Variant | Description |
|---|---|
Mochie/Water |
The standard water shader. |
Mochie/Water (Tessellated) |
Adds distance-based GPU tessellation and the Tessellation section. |
Ready-made water prefabs (such as Clean and Lava) are in Assets/Mochie/Unity/Prefabs, alongside a Depth Light prefab, which is required for depth effects (Caustics, Depth Fog, Edge Fade, depth-based foam, and screen space reflections). The tessellated prefabs require Water (Tessellated).
-
Base Color: A texture multiplied over the water's color, with optional Stochastic sampling (uses the UVs to generate pseudo-random sampling positions that hide tiling artifacts; 3 samples per texture). With a texture set, it also has:
- Tiling, Offset, and Scrolling: Scale, shift, and animate the texture.
- Distortion Strength: How much the normal maps warp the base color, so it ripples with the surface.
-
Opacity (Premultiplied and Grabpass): How visible the water is, with a mask that limits it further (with tiling, offset, and scrolling).
- In Grabpass mode, lower values fade the whole water effect out, including refraction, reflections, foam, and depth effects, until only the scene behind it remains.
- In Premultiplied mode, it blends between the plain Surface Tint and the fully lit surface (lighting, reflections, highlights, and foam). How much of the scene shows through is set by the Surface Tint's alpha.
- Shadow Strength (Opaque): How strongly realtime shadows darken the surface.
- Decal Base Color: A texture drawn over the surface using its alpha, like floating leaves or debris. The color tints it.
- Decal Normal Map: A normal map for the decal. With a Decal Base Color set, it only shows where the decal's alpha is; otherwise it's layered over the whole surface. The value sets its strength.
- Tiling, Offset, and Scrolling (with a decal texture): Shared by both decal textures.
- Surface Tint: The main water color. In Grabpass mode it tints the view through the water. In Opaque and Premultiplied modes it's the surface color, and in Premultiplied mode its alpha sets how much the water hides what's behind it.
- Glancing Tint: The color the water shifts toward when viewed at shallow, glancing angles. When looking straight down, the Surface Tint is used as is.
- Backface Tint: Replaces the Surface Tint on the underside of the surface, seen from below.
- Horizon Tint: The color the water shifts toward near the horizon.
- Horizon Tint Distance: How close to the horizon the viewing angle must be before Horizon Tint appears. Higher values limit the tint to angles nearer the horizon.
- Horizon Tint Strength: How strongly Horizon Tint replaces the Surface Tint.
Grabpass and non-grabpass modes keep separate tint values, so switching the Transparency Mode doesn't overwrite them.
Normal maps shape the small waves and ripples on the surface, which drive the refraction, reflections, and highlights.
-
Mode:
Texture(two scrolling normal maps) orFlipbook(an animated texture array). - Refraction Strength: How strongly the normals distort the view through the water.
- Horizon Adjustment: Adjusts the strength of the effect at sharper viewing angles to avoid artifacts. The normals flatten out toward the horizon, which hides noisy reflections in the distance.
- Horizon Adjustment Distance: How close to the horizon the viewing angle must be before Horizon Adjustment flattens the normals. Higher values limit the flattening to angles nearer the horizon.
- Invert: Flips the direction of all normals, in case your textures look lit from the wrong side.
- Normal Map: The first normal map, with optional Stochastic sampling.
- Strength: How pronounced the ripples are.
- Scale: How many times the texture repeats. Higher values give smaller ripples.
- Scrolling: How fast the texture moves on each axis, which animates the ripples.
- Rotation: Rotates the texture, in degrees.
A second normal map, enabled with its toggle, blended with the first. Scrolling the two in different directions gives natural-looking, non-repeating motion. It has the same settings as Primary.
- Flipbook: An animated normal map texture array. Convert GIFs with Tools > Mochie > Convert to Flipbook Asset.
- Scale: How many times the flipbook repeats.
- Strength: How pronounced the ripples are.
- Speed: How fast the flipbook plays.
- Roughness: How rough or smooth the surface looks. Rougher water has blurrier reflections and broader highlights. The value multiplies the map.
- Metallic: How metallic the surface looks. Usually left at 0 for water, but useful for liquids like mercury. The value multiplies the map.
- Decal Mode: Uses the alpha and UVs of the decal base color for blending and sampling the roughness and metallic maps, so they only apply to the decal.
-
Reflections: Where reflections come from.
-
Off: No reflections. -
Environment: The world's reflection probes. -
Cubemap: A cubemap you provide. -
Mirror: Real VRChat mirror reflections. Requires a VRChat mirror component with this shader selected in its custom shader field. The mesh must face forward on its local Z axis (like Unity's default quad). It costs as much as any other VRChat mirror, so use it very sparingly.
-
-
Cubemap: The reflection cubemap, with a color tint.
- Rotation: Rotates the cubemap on each axis, in degrees.
- Normal Swizzle (Mirror): Determines the axis of offset when applying the normal maps to mirror based reflections. If reflections look broken or incorrect, try each of these options to see which matches the orientation of your surface.
- Tint: A color multiplied over the reflections.
- Strength: Brightness of the reflections.
-
Screenspace Reflections (Environment and Cubemap modes, in Grabpass mode with Depth Effects on): Adds sharp reflections of whatever is visible on screen, on top of the probe or cubemap reflections. The value sets their strength.
- Edge Fade: The distance from the edge of the screen at which screenspace reflections will fade out. This helps mask edges where there is no screen information.
- Depth: The distance from the surface at which objects will appear in screenspace reflections. Larger values will lose precision for closer objects.
- Enable SSR in VR: Whether SSR is also used for VR players.
- Apply to Backfaces: Shows reflections on the underside of the surface too, when viewed from below.
-
Specular Highlights: The source of the bright highlights on the waves.
-
Off: No highlights. -
Directional Light: Highlights from the scene's realtime directional light, using its direction and color. -
Manual: Highlights from a fixed, white light direction you set, so the water sparkles even in baked worlds.
-
- Tint: The color of the highlights.
- Strength: Brightness of the highlights.
- Light Direction (Manual): The direction the highlight light comes from (XYZ).
Enabled with the Emission checkbox. Emission adds color after all lighting calculations, so the water appears to glow, like lava.
-
Global Illumination: Whether the emission lights up the surrounding scene when lighting is baked or calculated in realtime (
Realtime,Baked, orNone). - Emission Map: The glow texture, with optional Stochastic sampling.
- Tint: The HDR color multiplied over the emission map.
- Tiling, Offset, and Scrolling: Scale, shift, and animate the emission map.
- Distortion Strength: How much the normal maps warp the emission.
- Apply Flow Mapping: Moves the emission along the flow map, so glowing patterns follow the water's current.
-
Audio Link: Multiplies the emission by the level of a VRChat AudioLink Band (
Bass,Low Mids,Upper Mids, orHighs), so it pulses with the music. Strength sets how much the band controls the emission: at 1 the emission fully follows the music, and at 0 it's unaffected.
Makes the normal maps, foam, and optionally emission flow in different directions across the surface, like a river bending around rocks.
-
Flow Map: A texture whose red and green channels set the direction of the flow at each point. Mid-gray (0.5) means no movement. Includes a UV set selector (
UV0βUV3). - Blend Noise (Separate Texture source): Each normal map (and some other textures) is sampled twice with different UVs. This texture determines the pattern for blending between the two samples, which hides the moment the flow resets.
- Flow Map Scale: How many times the flow map repeats.
- Blend Noise Scale: How many times the blend noise repeats.
- Speed: How fast the textures flow.
- Strength: How far the textures are pushed along the flow. Too high can cause visible stretching.
-
Blend Noise Source: Where the blend noise comes from:
Flowmap Alpha(the flow map's alpha channel) orSeparate Texture. - Visualize: Displays the flow map on the surface, to check its direction and placement.
Moves the mesh's vertices to create real waves in the geometry, not just the lighting. The mesh needs enough vertices for smooth waves.
-
Mode:
Off,Noise Texture,Gerstner Waves,Voronoi, orFlipbook.
Waves driven by a scrolling noise texture.
- Noise Texture: The texture that shapes the waves. Brighter areas rise and darker areas fall.
- Precision: How blurred the noise is sampled. Higher values give smoother, rounder waves.
- Scale: How many times the noise repeats. Higher values give smaller waves.
- Scrolling: How fast the noise moves on each axis.
- Strength: How far vertices move on each axis (XYZ). Usually only Y is used, for up-and-down waves.
- Strength Multiplier: Multiplies all three Strength values.
- Remap: Remaps the noise to the range vertices move in, from -1 (full downward) to 1 (full upward).
Physically based ocean waves with sharp crests and wide troughs. Up to three waves are combined. Coming in the v1.78 update: a fourth wave.
For best results ensure your base mesh is a plane of approximately 10m x 10m (before scaling in the scene). Also don't be afraid to use extremely large or small values, these settings vary significantly depending on the scale you're working at.
- Strength: Multiplies the strength of all waves.
- Scale: Multiplies the scale (wavelength) of all waves.
- Speed: Multiplies the speed of all waves.
- Recalculate Normals: Recalculates the mesh's normals from the waves, so lighting and reflections follow their shape.
- Mask: Limits where waves appear, with strength and channel selection, tiling, and offset. Useful for calming the water near a shore.
Every wave has the same settings. A wave with a Strength of 0 is skipped.
- Strength: How steep and tall the wave is. Higher values give sharper crests.
- Scale: The wavelength. Higher values give longer, larger waves.
- Speed: How fast the wave travels.
- Direction: The direction the wave travels, in degrees.
Coming in the v1.78 update: Wave 4, and a tab for each wave with a toggle in its header. All four waves are on by default, and a wave that's toggled off is skipped.
Bubbling, cell-shaped waves, good for boiling liquids or lava.
- Speed: How fast the cells animate.
- Scale: The size of the cells. Higher values give smaller cells.
- Scrolling: How fast the pattern moves on each axis.
- Strength: How far vertices move on each axis (XYZ).
- Strength Multiplier: Multiplies all three Strength values.
Waves driven by an animated height texture array.
- Vertex Offset Flipbook: The animated texture array.
- Scale: How many times the flipbook repeats. This is the same setting as the Scale of the Normal Maps flipbook, so the two stay aligned.
- Strength: How far vertices move.
- Speed: How fast the flipbook plays.
Noise Texture, Voronoi, and Flipbook modes. Limits where the offset applies, with strength and channel selection.
When a vertex offset mode is on. Light shining through the thin tops of waves, which gives crests a glowing, translucent color. It shifts the Surface Tint toward its color on the crests.
- Tint: The color of the light through the crests.
- Strength: How strongly the crests take on the tint.
- Brightness: Multiplies the tint's brightness.
- Threshold: How high on a wave the glow starts. Higher values limit it to the very tops.
Coming in the v1.78 update: a toggle in its tab header, on by default. It tints the Depth Fog color instead of the Surface Tint, so it only shows when Depth Fog is on.
Grabpass mode with Depth Effects on. Projects moving light patterns onto the geometry under the water, like sunlight focused through ripples. Caustics are only visible when looking down through the surface, not from below it.
-
Mode: How the caustics are generated.
-
Off: No caustics. -
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.
- Shadow Texture (Texture): A second pattern that subtly darkens the ground under the caustics, for extra contrast. The value sets how strong the darkening is.
- Caustics Flipbook (Flipbook): The animated caustics texture array.
-
Blending (Flipbook): How the caustics combine with the ground:
Addbrightens,Overlayalso darkens the gaps between the lines for more contrast. - Color: The color of the caustics. It's also tinted by the Surface Tint.
- Strength: Brightness of the caustics.
- 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.
- Scale: How large the caustic pattern is. Higher values give smaller patterns.
- Depth Fade: Determines how strongly caustics will fade out at greater depths. Higher values make them fade out closer to the surface.
- 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 with a normal map, 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.
Adds white water, along shorelines and on wave crests.
-
Mode: Where edge foam appears.
-
Depth: Where the water meets geometry, like a shoreline or around rocks. Requires Depth Effects. -
Mask: Where a Foam Map is white, with its own UV Set, tiling, and offset. -
Vertex Color: Where a selected Channel of the mesh's vertex colors is bright, so foam can be painted onto the mesh.
-
- Roughness: How rough the foam should be when calculating reflections and specular highlights.
- Edge Power (Depth): Intensity of the edge foam gradient. Higher values give a thinner band of foam along the edges.
- Edge Strength (Depth): How visible the foam is on the edges.
- Strength (Mask and Vertex Color): How visible the foam is.
- Crest Strength: How visible foam is on the crests of Gerstner waves.
- Crest Threshold: How high or low a Gerstner wave must be to have crest foam.
-
Foam Texture: The foam's pattern, with an HDR color and optional Stochastic sampling. Its alpha and brightness control where foam shows.
- Scale: How many times the foam texture repeats.
- Scrolling: How fast the foam moves on each axis.
- Distortion Strength: How much the normal maps warp the foam.
- Create Normals: Automatically generates normals for the foam based on the grayscale value of the foam texture, so it looks bumpy. The value sets their strength.
-
Noise Texture: A texture that breaks up the foam into irregular patches.
- Scale and Scrolling: Size and movement of the noise.
- Edge Noise: How strongly the noise texture should affect edge foam (or Mask and Vertex Color foam).
- Crest Noise: How strongly the noise texture should affect crest foam.
Grabpass mode with Depth Effects on. Makes the water murkier the deeper you look into it, hiding the bottom in deep areas. Like caustics, it only shows when looking down through the surface.
- Color: The color of the fog. Its alpha sets how opaque the fog gets in deep water. It's also tinted by the Surface Tint.
- Brightness: Multiplies the fog color's brightness.
- Power: How quickly the fog thickens with depth. Higher values make even shallow water murky.
Grabpass mode with Depth Effects on. Fades the water out where it meets geometry, so the shoreline blends in softly instead of cutting a hard line.
- Power: How quickly the water fades in away from the edge. Higher values give a narrower fade.
- Offset: Pushes the fade further out from the edge, widening the band where the water is fully clear. Edge foam is pushed out by the same amount, so it stays visible past the faded edge.
Procedural rain ripples on the surface.
- Mask: Limits where ripples appear (green channel), with tiling and offset.
- Strength: How strongly the ripples distort the surface.
- Speed: How fast ripples play out.
- Scale: How many ripples fit across the surface. Higher values give smaller, denser ripples.
- Ripple Density: How many rings each ripple has. Higher values give wider ripples made of more rings.
- Ripple Size: How far each ripple spreads before it fades out.
Only appears when LTCGI is installed in your project. LTCGI lets video players and other screens reflect realistically on the water.
- Strength: Brightness of LTCGI's reflections on the water.
- Roughness Multiplier: Multiplies the surface roughness used for LTCGI reflections. Higher values give blurrier reflections.
- Tint: The color multiplied over LTCGI's reflections.
Only appears when AreaLit is installed in your project. Reflections must be enabled. AreaLit adds realistic reflections of rectangular area lights, like screens and light panels.
- Mask: Limits where AreaLit reflections appear, with tiling and offset.
- Strength: Brightness of AreaLit's reflections.
- Roughness Multiplier: Multiplies the surface roughness used for AreaLit reflections. Higher values give blurrier reflections.
- Opaque Lights: AreaLit's opaque lights option.
- Mesh: The light mesh data texture generated by AreaLit. The label shows the maximum number of lights it supports.
- Texture 0, Texture 1, Texture 2 (intended for indirect light), and Texture 3+ (intended for static lights): The textures shown on the area lights. These need mip maps and trilinear filtering; the inspector offers a one-click fix.
The AreaLit package files must be inside a folder named AreaLit (case sensitive) directly in the Assets folder (Assets/AreaLit).
Subdivides the mesh on the GPU near the viewer, so waves stay smooth up close without needing a dense mesh everywhere.
- Vertex Offset Mask: Fades the vertex offset out over the same distance range as the tessellation, so distant, less-subdivided water stays flat instead of looking jagged.
- Min Factor: How much the mesh is subdivided at and beyond the Max Distance.
- Max Factor: How much the mesh is subdivided within the Min Distance. Higher values give smoother waves but cost more.
- Min Distance: The distance, in meters, within which tessellation is at its Max Factor.
- Max Distance: The distance, in meters, beyond which tessellation drops to its Min Factor.
Tessellation is known to cause issues on some hardware, and it can be extremely expensive if you turn the settings up too far. Expect some experimentation, since the factors need to be set based on the base triangle count of the mesh. Use Unity's Wireframe scene view for easy visualization.
Support for VRChat Light Volumes, which provide higher quality, more localized baked lighting than Unity's light probes. Enabled by default. Water that isn't lightmapped is only darkened by baked lighting through light volumes; without them it's lit at full brightness.
- Strength: How strongly light volumes light the water. At 0 they have no effect.
- Additive Volumes: Enables additive light volumes, which add extra light on top of lightmapped water. The value sets their brightness. See the Light Volumes documentation for more info.
- Specular Highlights: Specular highlights derived from VRC Light Volumes. The value sets their brightness.
- Bias: Offsets the sampling position of the light volume along the surface normal to help avoid light leaking.
-
Bakery Mode: Support for the third-party lightmapper Bakery's directional lightmap modes:
None,SH,RNM, orMonoSH. Match this to the directional mode used in your Bakery bake. See the Bakery documentation for details. - Bakery Specular Highlights: Adds specular highlights from the directional information in Bakery lightmaps. The value sets their brightness. Requires one of the Bakery modes.
- Lightmap UV Distortion: How much the normal maps warp the lightmap, so baked lighting ripples with the surface.
- Lightmap Strength: How much the lightmap darkens the water. At 0 the water ignores the lightmap. The lightmap is softened on water, so only its darker areas have an effect.
- Lightmap Saturation: The color intensity of the lightmap on the water. Lower values give more neutral lighting.
- Depth Fog Contribution: How much of the depth fog color is added to the water's emission when baking lightmaps, so the fog color lights up the surrounding scene.
- Bicubic Lightmap Sampling: Samples lightmaps using bicubic filtering to hide aliasing on shadows. Provides a smooth gradient on otherwise low resolution shadows.
- Ignore Realtime GI: When enabled this material will ignore Enlighten realtime GI.
- Render Queue Offset: Offsets the render queue by this value, to change when the water draws relative to other objects. The resulting Render Queue is shown below it.
- Stencil Reference: The stencil value the water writes wherever its surface is drawn. Underwater Visuals uses it to keep its caustics off the water's surface, so both materials must use the same value.
-
Transparency Mode: How the water handles transparency.
-
Opaque: The water is solid. Cheapest, and good for stylized water or lava. -
Premultiplied: Alpha-blended transparency without refraction. -
Grabpass: The water refracts and tints the scene behind it. Required for depth effects.
-
-
Culling Mode: Which sides of the mesh are drawn. Set it to
Offto see the underside of the water from below. - ZWrite: Whether the water writes to the depth buffer. It's set automatically when you change the Transparency Mode (on for Opaque, off otherwise), but can be overridden afterward.
- Depth Effects (Grabpass): Enables depth-based effects: Caustics, Depth Fog, Edge Fade, depth-based foam, and SSR. Requires a Depth Light prefab in the scene.
-
Texture Coordinate Space: How textures are mapped.
-
UV: Uses the regular UVs baked into the mesh. -
World: Uses the world space coordinates of the mesh as UVs, so textures stay seamless across separate water meshes. The Swizzle sets which two axes are used;XZis usual for water.
-
- Texture Coordinate Scale: Multiplies the coordinates of all textures, so higher values tile them more often. UV and World modes keep separate values.
Mochie's Shaders β’ Created by Mochie β’ GitHub β’ Found an issue? Submit a report