Triplanar Terrain Shaders
Sorolif RTS Map Generator includes two world-space terrain shaders. They are designed for generated terrain where conventional UVs stretch across steep plateau walls, mountain slopes and coast drops.
Natural triplanar
Shader name: Sorolif/RTS Terrain/Triplanar
Top Texture: texture projected on upward-facing terrain.
Cliff / Side Texture: texture projected on steep faces.
Top Tint and Side Tint: independent color grading for horizontal and vertical surfaces.
World Texture Scale: world-space texture frequency. The texture remains consistent across separately generated meshes.
Projection Blend: sharpness of the transition between the three projections.
Texture Detail Strength: blends the texture pattern with the biome tint; zero gives an untextured flat tint. The default 0.65 keeps ground readable at an RTS camera distance.
Texture Brightness: balances pale source textures against the material tint without changing the biome palette.
Repeat Seam Blend: blends in a half-period sample near repeat boundaries. Zero retains the original authored repeat; 0.05 is the default. It adds one texture sample per projection when enabled.
Broad Color Variation: subtle world-space grading shared across generated chunks; zero disables it.
Slope Darkening: adds depth to cliffs without requiring a second material.
High Ground Tint, High Ground Start and High Ground Blend: optional altitude-based variation for plateaus and mountains.
Light Direction, Ambient Light and Lighting Strength: portable lighting controls that do not require a render-pipeline-specific material upgrade.
Stylized triplanar
Shader name: Sorolif/RTS Terrain/Triplanar Stylized
The stylized shader uses the same world-space top/side projection and adds:
Slope Accent: a controlled darker or colored cliff treatment.
Light Bands: quantized lighting for illustrated and low-poly art directions.
Light Band Softness: softens band boundaries while retaining broad lighting planes. Both shaders use wrapped diffuse to keep side faces readable.
Rim Color and Rim Strength: silhouette separation at an RTS camera angle.
Tools > Sorolif > Map Generation > Create Starter Biome Assets creates Triplanar_Stylized_Preset.mat so the stylized controls can be evaluated without modifying the active Forest biome.
Instanced decoration
Both shaders include an instancing variant and initialize the vertex instance ID
before reading the world transform. This keeps each repeated prop's texture
anchored to its own world position. Newly created starter materials using these
shaders enable GPU Instancing; refresh preserves an existing material's choice.
Enable the option on your own materials when using an instanced renderer.
Ordinary terrain MeshRenderers do not require it.
The Built-in ordinary variant retains target 3.0, while INSTANCING_ON requests
target 3.5. The URP passes use target 3.5. Unity documents conditional targets in
Shader model requirements.
Real-device Editor tests compare two instanced objects against individual draws;
they are skipped, not passed, when the device cannot support instancing.
Texture recommendations
- Use seamless textures with matching visual scale.
- Start with
World Texture Scale between 0.08 and 0.25 for maps using the default one-unit cell size.
- Keep side textures slightly darker and less saturated than top textures for readable height changes.
- Increase
Projection Blend for harder low-poly transitions; lower it for soil, snow and eroded rock.
- Built-in and URP rendering retain authored directional lighting and realtime main-light shadows. Native URP Editor checks cover Unity 6000.2 / URP 17.2 and Unity 6000.4 / URP 17.4 in Forward and Deferred; see URP setup and verification. HDRP and a full PBR lighting stack require suitable project shaders.
Face normals and cast shadows
With Enable Mesh Optimization, coincident vertices and triangle edges are shared
within each material. Surfaces using the same material and Unity layer can be
combined; surfaces with custom transforms remain separate. The generated object
keeps the name of the first surface in its group. Do not use that name to infer
all terrain categories in an optimized mesh; use the logical grid instead.
Both terrain shaders reconstruct the face normal from world-position derivatives
on optimized generated meshes, retaining the faceted style without duplicating
each triangle's vertices. UV channel 3 (Unity's uv4) carries the generated-mesh
marker and is preserved by EmbeddedMeshFilter. Existing unmarked meshes continue
to use their authored normals. Conventional customer shaders retain UV and hard
normal seams. The owned water shader uses continuous UVs and shared cell corners;
custom water materials retain their repeated cell UVs. Meshes with at most 65535
vertices use 16-bit indices; larger meshes use 32-bit indices.
Disable Enable Mesh Optimization to retain separate, flat-shaded surface meshes.
Both terrain shaders include their own ShadowCaster pass and receive the main
directional light's realtime shadows. Use Cast Shadow Strength and Cast Shadow
Tint for readable, soft-colored contact shadows. The material's Light Direction
still controls its authored terrain lighting. Shadow rendering also follows
your directional light and the project's quality and distance settings.
New starter materials use Texture Detail Strength 0.48, World Texture Scale
0.085 and Broad Color Variation 0.055 to keep large surfaces quieter. Refresh
preserves existing custom materials and colors.
Stylized water
Sorolif/RTS Terrain/Stylized Water provides animated world-space color waves,
a restrained glint, deep/shallow colors and a narrow shore highlight. Rendered
wave displacement does not change CPU mesh or collision geometry. Adjust Deep Water, Shallow
Water, Shallow Depth Range, Shore Highlight Depth/Strength, Wave Color Strength,
Wave Speed and Light Glint Strength on the material.
The shader includes Built-in and URP passes. Add the included StylizedWaterDepthCamera
component to a custom camera; in Built-in, Depth in Camera.depthTextureMode
also enables depth-only effects.
Starter and included demo cameras request depth automatically. Perspective,
orthographic and PNG capture cameras are covered. Without a usable depth
texture, the deep palette and wave shading remain available. For URP, configure
Copy Depth Mode before transparent rendering as described in URP setup.