-
Notifications
You must be signed in to change notification settings - Fork 36
Splat Mapping Shader
The Splat Mapping Shader (Mochie/Splat Mapping) is a terrain and surface blending shader for worlds. It blends up to four PBR layers across a single mesh using vertex colors or a mask texture, with height-based blending, parallax occlusion mapping, rain, and puddles. Screen space reflections require the Depth Light prefab in Assets/Mochie/Unity/Prefabs, or any directional light with shadows enabled.
At the top of the inspector. The red, green, and blue values of the blending source control how much of Layers 1, 2, and 3 show, in that order, each drawn on top of the layers before it. Wherever all three are black, only the Base Layer shows.
-
Layer Blending Source: Where the blend values come from.
-
Vertex Color: The mesh's vertex colors, so layers can be painted directly onto the mesh with a vertex painting tool. -
Mask Texture: A texture mapped with the mesh's first UV set.
-
-
Mask (RGBA) (Mask Texture): The blend mask, with tiling and offset.
- Bicubic Sampling: Samples the mask with bicubic filtering, which smooths out the blocky edges of low resolution masks.
The bottom layer, shown wherever the other layers aren't.
- Base Color: The layer's color texture, multiplied by the color next to it.
- Normal Map: Determines how light behaves on the surface. Primarily used to fake small details or smooth bevels. The value sets its strength.
- Packed Map: A single texture holding the layer's occlusion, roughness, metallic, and optional height values in its channels (by default occlusion in red, roughness in green, metallic in blue, and height in alpha).
-
UV Set: Which UV set the layer's textures use:
UV0βUV4. The Tiling and Offset below it apply to all of the layer's textures. - Roughness Channel, Metallic Channel, and Occlusion Channel: Which channel of the Packed Map holds each value.
- Height Channel (Height Mapping): Which channel of the Packed Map holds the height.
- Roughness: Multiplies the roughness from the Packed Map. Rougher surfaces have blurrier reflections and broader highlights.
- Metallic: Multiplies the metallic value from the Packed Map. Higher values decrease visibility of the base color in favor of reflective color, like metal.
- Occlusion: How strongly the occlusion from the Packed Map darkens crevices and corners.
- Height Strength (Height Mapping): How deep the Parallax Occlusion effect looks. Only used when Parallax Occlusion is enabled.
- Height Offset (Height Mapping): Shifts the whole height map up or down for Parallax Occlusion, changing how far the surface appears to be pushed in.
-
Parallax Falloff (Parallax Occlusion): Fades the effect out based on distance. This can help with performance in larger scale environments.
- Min Range: The distance from the viewer, in meters, within which parallax is at full strength.
- Max Range: The distance, in meters, where parallax has fully faded out.
- Stochastic Sampling: Uses the UVs to generate pseudo-random sampling positions that hide tiling artifacts. 3 samples per texture. Can't be combined with Height Mapping.
- Height Mapping: Enables the use of height-based features including Parallax Occlusion, Layer Height Blend, and Puddles, using the height from the Packed Map.
- Parallax Occlusion (Height Mapping): Uses parallax occlusion mapping to simulate detailed 3D geometry on the surface, based on the height map.
-
Puddle Height Blend (Height Mapping): Fills the low areas of the height map with puddles. Inside a puddle, the layer's normal map, roughness, and occlusion fade out, leaving a flat, glossy water surface. Puddles only form on surfaces facing nearly straight up.
- Puddle Blend Threshold: The height range of the puddle's shoreline. Areas below the minimum are fully flooded, areas above the maximum stay dry, and areas in between blend.
- Puddle Tint: How much of the layer's color remains inside puddles. Lower values give darker, wetter looking puddles; 1 leaves the color unchanged.
Enabled with its toggle. Controlled by the red channel of the blending source, and drawn on top of the Base Layer.
- Blend Threshold: Remaps the red channel before it's used. Below the minimum, the layer is hidden; above the maximum, it fully covers the layers below. A narrow range gives sharp transitions, and a wide range gives soft ones.
- All of the Base Layer settings, plus:
-
Layer Height Blend (Height Mapping): Uses the height maps to decide where this layer appears as it's blended in. Instead of fading in evenly, it shows up on the highest points first, like sand settling between stones or moss growing on top of them.
- Layer Edge Mask: Only applies the height blending near the edges of the blended area, so the layer stays solid where it's fully painted in. The value sets how far in from the edge the height blending reaches; higher values widen it.
- Layer Blend Threshold: The height range over which the layer blends in. Below the minimum it's hidden, and above the maximum it's fully shown. A narrow range gives a sharper transition.
The same settings as Layer 1, controlled by the green channel and drawn on top of Layer 1.
The same settings as Layer 1, controlled by the blue channel and drawn on top of Layer 2.
- Specular Highlights: GGX specular highlights from realtime lights. The value sets their brightness.
- 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: Reflections of whatever is visible on screen, on top of the probe reflections. The value (up to 1) sets how strongly they replace the probe reflections. Enabling them moves the material to the Transparent render queue (3000) with a grab pass. They can be expensive, so use them sparingly.
- 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. At 0 the edges are hard.
- Depth: The distance from the surface at which objects will appear in screenspace reflections. Larger values will lose precision for closer objects.
- Enable in VR: Whether SSR is also used for VR players.
- Fresnel: The Fresnel effect changes the behavior of specularity (reflections and specular highlights) based on viewing angle. Reflections are more visible on surfaces when viewed from a sharp angle. The value sets its strength. When off, reflections are equally strong from every angle.
-
Specular Occlusion: Uses shadows from either realtime directional lights or baked lightmaps to occlude reflections and specular highlights, so shaded areas don't reflect as brightly as lit ones. The value sets its strength. On lightmapped surfaces, it's based on the lightmap and also affects Bakery and light volume highlights. On other surfaces, it's based on realtime shadows and only affects reflections.
- Lightmap Tint: A color multiplied into the lightmap-based occlusion, which tints the reflections it affects.
- Lightmap Brightness: Multiplies the lightmap before it's used as occlusion. Higher values mean only darker areas of the lightmap occlude reflections.
- Lightmap Contrast: Adjusts the contrast of the lightmap before it's used as occlusion. Higher values separate lit and shadowed areas more sharply.
- Lightmap HDR: Blends toward a gamma-expanded version of the lightmap, which darkens its midtones so shadows occlude more strongly.
- Global Roughness: Multiplies the roughness of every layer.
- Contact Hardening: Sharpens reflections at points of contact between box reflection probe bounds and geometry. Only affects box projected reflection probes.
Procedural rain ripples. The ripples use the mesh's first UV set, regardless of each layer's UV Set.
- Base Layer, Layer 1 (R), Layer 2 (G), and Layer 3 (B): Which layers get ripples.
- Strength: How strongly the ripples distort the surface's normals.
- Scale: How large the ripple pattern is. Higher values give smaller, denser ripples.
- Speed: How fast ripples play out.
- Angle Mask: How flat a surface must be to get rain. Higher values limit rain to flatter surfaces.
- Angle Mask Blend: How gradually the rain fades out around the Angle Mask.
- 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.
- Puddle Ripple Density and Puddle Ripple Size: Separate ripple settings used inside puddles (with Puddle Height Blend), so pooled water can ripple differently than wet ground.
Only appears when LTCGI is installed in your project. LTCGI lets video players and other screens light up and reflect on the surface realistically.
- Strength: Brightness of LTCGI's lighting and reflections. At 0 they're turned off.
- Roughness Multiplier: Multiplies the surface roughness used for LTCGI reflections. Higher values give blurrier reflections.
- Diffuse Color: A color multiplied over the light LTCGI casts onto the surface.
- Specular Color: A color multiplied over LTCGI's reflections.
Only appears when AreaLit is installed in your project. AreaLit adds realistic lighting and reflections from rectangular area lights, like screens and light panels.
- Strength: Brightness of AreaLit's lighting and reflections.
- Roughness Multiplier: Multiplies the surface roughness used for AreaLit reflections. Higher values give blurrier reflections.
- Opaque Lights: AreaLit's opaque lights option.
- Apply Specular Occlusion: Also applies Specular Occlusion to AreaLit's lighting. Requires Specular Occlusion to be enabled.
- 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.
-
Occlusion: A texture that darkens AreaLit's lighting, like an ambient occlusion map, with tiling and offset.
-
UV Set: Which UVs the occlusion texture uses:
UV0βUV4, orUV1_LightmapST(the lightmap UVs with the lightmap's scale and offset, so it lines up with a baked lightmap layout).
-
UV Set: Which UVs the occlusion texture uses:
The AreaLit package files must be inside a folder named AreaLit (case sensitive) directly in the Assets folder (Assets/AreaLit).
Support for VRChat Light Volumes, which provide higher quality, more localized baked lighting than Unity's light probes. Enabled by default.
- Strength: How much light volumes replace regular light probe lighting.
- Additive Volumes: Enables additive light volumes, which add extra light on top of lightmapped surfaces. 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, which make baked lighting respond to normal maps:
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.
- Non-Linear SH: Evaluates light probe lighting and Bakery's SH and MonoSH lightmaps with a non-linear method, which gives more accurate contrast between lit and unlit sides.
- 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.
Enabled with its toggle. Replaces the material's output with the selected components, to help troubleshoot layers and lighting. Enabling several adds them together.
- Layer Blending: The blend values from the vertex colors or mask texture.
- Base Color: The blended base color.
- Normals: The blended normal maps.
- Roughness, Metallic, and Occlusion: The blended values from the packed maps.
- Height: The blended height, with Height Mapping enabled.
- Realtime Shadows: Shadows and shading from realtime lights.
- Reflections: The reflections, with Environment Reflections enabled.
- Specular Highlights: The specular highlights, with Specular Highlights enabled.
- Rain Angle Mask: Where rain can appear based on the Angle Mask, with Rain enabled.
Mochie's Shaders β’ Created by Mochie β’ GitHub β’ Found an issue? Submit a report