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

Stylized triplanar

Shader name: Sorolif/RTS Terrain/Triplanar Stylized

The stylized shader uses the same world-space top/side projection and adds:

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

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.