Skip to content

Glass Shader

MochiesCode edited this page Sep 30, 2026 · 2 revisions

The Glass Shader (Mochie/Glass) is a refractive shader for world surfaces like windows, display cases, bottles, and frosted glass, with optional rain. Screen space reflections require the Depth Light prefab in Assets/Mochie/Unity/Prefabs, or any directional light with shadows enabled.

πŸ“Œ Variants

Variant Description
Mochie/Glass Single-pass refractive glass.
Mochie/Glass (Two Pass) Renders back faces before front faces, so the back of a closed object (bottles, orbs) shows through the front. Doesn't include Mesh Refraction, screen space reflections, the emission Parallax Offset, or the Culling Mode setting.

Surface

  • Workflow: How the metallic, roughness, and occlusion maps are provided.
    • Metallic: Each is its own texture.
    • Packed Metallic: All three are packed into the channels of one texture, which improves performance and file size.
  • Transparency: How the glass handles transparency.
    • Grabpass: The glass refracts, blurs, and tints the scene behind it. Not supported on mobile platforms like Quest; the material switches to Premultiplied automatically when your build target is Android.
    • Premultiplied: The glass's reflections, highlights, base color, and emission are added on top of the scene, without refraction, blur, or tinting. Cheaper than Grabpass.
    • Opaque: No transparency. Only the base color, reflections, highlights, and emission are visible.
  • Grabpass Tint (Grabpass): A color multiplied over the view through the glass. Darker colors make the glass darker, like tinted windows.
  • Specularity Tint: A color multiplied over reflections and specular highlights.
  • Base Color Tint: A color multiplied over the Base Color texture. It's black by default, which hides the base color entirely; set it to a brighter color to see the texture.

Textures

  • Base Color: An unshaded color layer on the glass, such as dirt, stickers, or painted details. It's added on top of the view through the glass, so it can brighten the glass but not darken it (use Grabpass Tint for that). The texture's alpha controls where it appears. Includes tiling and offset.
    • Lit: Multiplies the base color by the scene's realtime lighting, so it darkens in shadow. Doesn't support baked lightmaps.
  • Normal Map: Adds surface detail that bends reflections, highlights, and the view through the glass. The value sets its strength. Includes tiling and offset.
  • Metallic (Metallic): How metallic the glass looks. Higher values make reflections and highlights stronger at every angle, like mirrored or coated glass. The value multiplies the map. Includes tiling and offset.
  • Roughness (Metallic): How rough or smooth the surface looks. Rougher glass has blurrier reflections and broader highlights, and blurs the view through it (see Blur Strength). The value multiplies the map. Includes tiling and offset.
  • Occlusion (Metallic): Extra shading that simulates contact shadows in crevices and corners. It darkens everything, including the view through the glass. The value sets its strength. Includes tiling and offset.
  • Pack Textures (Metallic): Packs the separate maps into one texture (occlusion in red, roughness in green, metallic in blue) and switches to the Packed Metallic workflow with matching channel settings.
  • Packed Map (Packed Metallic): The texture holding roughness, metallic, and occlusion in its channels. Includes tiling and offset.

Packed Settings (Packed Metallic)

  • Metallic Channel, Roughness Channel, and Occlusion Channel: Which channel of the Packed Map holds each value.
  • Metallic Strength: Multiplies the packed metallic value.
  • Roughness Strength: Multiplies the packed roughness value.
  • Occlusion Strength: How strongly the packed occlusion darkens the glass.

Refraction (Grabpass)

  • Blur Quality: How many samples the blur uses: Low (16), Medium (22), High (43), or Ultra (71). Higher quality blurs look smoother but cost more.
  • Blur Strength: How strongly the view through the glass is blurred, for a frosted look. The blur is scaled by the roughness, so perfectly smooth glass (0 roughness) is never blurred.
  • Normal Refraction: How strongly the normal map and rain bend the view through the glass.
  • Mesh Refraction (Glass only): Bends the view through the glass based on the shape of the mesh itself, like a lens or a bottle. The value is the IOR (index of refraction): 1 doesn't bend at all, and higher values bend more. The effect is strongest near the edges of the object, where the surface faces away from the viewer. Don't use it on flat surfaces.

Specularity

  • Environment Reflections: Reflections of the world's reflection probes, with support for box projection and blending between probes. The value sets their strength.
  • Screen Space Reflections (Glass only, Grabpass mode): Reflections of whatever is visible on screen, on top of the probe reflections. They only appear on smooth glass (roughness below about 0.3). The value (up to 1) sets how strongly they replace the probe reflections.
    • 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.
  • Specular Highlights: GGX specular highlights from realtime lights. The value sets their brightness.
  • Specular Antialiasing: Increases the roughness where the mesh's surface curves sharply, to hide sparkly artifacts from specular lighting. The value sets its strength. Since roughness also drives the blur, this can blur the view through those areas.

Emission

Enabled with the Emission checkbox. Emission adds color after all lighting calculations, so the glass appears to glow.

  • Global Illumination: Whether the emission lights up the surrounding scene when lighting is baked or calculated in realtime (Realtime, Baked, or None).
  • Color: The emission map and its HDR color, with tiling and offset.
  • Strength: Multiplies the brightness of the emission.
  • Parallax Offset (Glass only): Pushes the emission back behind the surface, so it appears to be inside or behind the glass, like a neon sign behind a frosted window. Deeper emission is bent more by the normal map and rain, and blurred more by rough glass.
  • Blur Quality and Blur Strength (Premultiplied and Opaque, with a Parallax Offset): The same settings as in Refraction, shown here because Refraction is hidden in these modes. They blur the offset emission; the blur increases with the Parallax Offset and the roughness.

Rain

Adds animated rain to the surface's normals, which also bends the view through the glass.

  • Mode:
    • Off: No rain.
    • Droplets: Dotted droplets and streaks of rain, best used on vertical surfaces like windows. Droplets also clear the roughness where they land, so they cut clear spots into frosted glass.
    • Ripples: Rippling circles like you'd see on horizontal surfaces where water pools.
    • Automatic: Renders both, and blends between them based on the angle of the surface: droplets on vertical surfaces and ripples on horizontal ones.

Droplets

  • Mask (Droplets mode): Limits where rain appears, with tiling and offset. Black areas stay dry. The dropdown selects which channel of the mask is used.
  • Strength: How strongly the droplets distort the surface's normals.
  • Speed: How fast the droplet animation plays.
  • X Scale and Y Scale: How many times the droplet pattern repeats horizontally and vertically. Higher values give smaller droplets.
  • Dynamic Droplets: Adds larger droplets that bead up and fade over time. The value sets how many appear.

Ripples

  • Mask (Ripples mode): Limits where rain appears, with the same settings as the droplets mask.
  • Strength: How strongly the ripples distort the surface's normals.
  • Speed: How fast ripples play out.
  • Scale: How large the ripple pattern is. Higher values give smaller, denser ripples.
  • Density: How many rings each ripple has. Higher values give wider ripples made of more rings.
  • Size: How far each ripple spreads before it fades out.

Both (Automatic mode)

  • Mask: Limits where rain appears, with the same settings as the droplets mask.
  • Angle Threshold: The surface angle where ripples switch to droplets. Surfaces flatter than this get ripples.
  • Threshold Blend: How gradually ripples blend into droplets around the threshold angle.

Lightmap Settings

  • Bakery Mode: Support for the third-party lightmapper Bakery's directional lightmap modes: None, SH, RNM, or MonoSH. 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.
  • Apply Lightmaps to: What the lightmap (and other baked lighting, like light volumes) darkens.
    • Final Color: Applies lightmaps to the final color output. This is much more visible, but can result in very unrealistic visuals if the grabpass is darkened or lightened too much.
    • Specularity: Applies lightmaps only to specularity. This is more realistic, but often far less discernible.
  • Lightmap UV Distortion: How much the normal map and rain warp the lightmap, so baked lighting follows the surface detail.
  • Lightmap Strength (Grabpass and Premultiplied): How much the lightmap darkens the glass. At 0 the lightmap is ignored. The lightmap is softened on transparent glass, so only its darker areas have an effect.
  • Lightmap Saturation (Grabpass and Premultiplied): The color intensity of the lightmap on the glass. Lower values give more neutral lighting.
  • 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.

Light Volumes

Support for VRChat Light Volumes, which provide higher quality, more localized baked lighting than Unity's light probes. Enabled by default. Transparent glass that isn't lightmapped is only darkened by baked lighting through light volumes, not light probes.

  • Strength: How strongly light volumes light the glass. In Opaque mode, lower values blend back toward regular light probe lighting. At 0 they have no effect.
  • Additive Volumes: Enables additive light volumes, which add extra light on top of lightmapped glass. 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.

LTCGI

Only appears when LTCGI is installed in your project. LTCGI lets video players and other screens reflect realistically on the glass.

  • Strength: Brightness of LTCGI's reflections. At 0 they're turned off.
  • Roughness Multiplier: Multiplies the surface roughness used for LTCGI reflections. Higher values give blurrier reflections.
  • Tint: The color multiplied over LTCGI's reflections.

AreaLit

Only appears when AreaLit is installed in your project. AreaLit adds realistic reflections of rectangular area lights, like screens and light panels. With Lit enabled on the Base Color, the area lights also light the base color.

  • Mask: Limits where AreaLit appears, with tiling and offset. Black areas get no AreaLit lighting or reflections.
  • Strength: Brightness of AreaLit's lighting and reflections. At 0 it's turned off.
  • 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).

Render Settings

  • Sampling Mode: How the base color, normal, and PBR maps are sampled.
    • Default: Samples textures normally.
    • Stochastic: Uses the UVs to generate pseudo-random sampling positions that hide tiling artifacts. 3 samples per texture.
  • Texture Coordinate Space: How textures and rain 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 meshes. The Swizzle sets which two axes are used.
  • Texture Coordinate Scale: Multiplies the coordinates of all textures, so higher values tile them more often.
  • Render Queue Offset: Offsets the render queue by this value, to change when the glass draws relative to other objects. The resulting Render Queue is shown above it. Grabpass and Premultiplied glass starts from the Transparent queue (3000), and Opaque glass from the Geometry queue (2000).
  • Culling Mode (Glass only): Which sides of the mesh are drawn: Off draws both sides, Front hides front faces, and Back hides back faces (the default).

πŸ”’ = Patrons only


Avatar Shaders

Uber
Uber X πŸ”’
Uber X (Outline) πŸ”’
Taken πŸ”’
Avatar Props πŸ”’

Environment Shaders

Standard
Water
Water (Tessellated) πŸ”’
Underwater Visuals
Glass
Splat Mapping πŸ”’
LED Screen

Special Effects Shaders

Particles
Particles X πŸ”’
Screen FX
Screen FX X πŸ”’
Corruption πŸ”’

Links

Clone this wiki locally