Skip to content

MichaelEGA/Procedural-Stochastic-Terrain-Shader

Repository files navigation

Procedural Stochastic Terrain Shader

A simple procedural terrain shadergraph for Unity's inbuilt terrain system

Get it here: https://github.com/michael-evan-allison/Procedural-Stochastic-Terrain-Shader

Tested In: Unity URP 2022.2.2f1, Unity URP 2022.2.9f1

Version History

  • 01/02/2023 - Stochastic now seemlessly textures across neighbour terrains
  • 31/01/2023 - Added stochastic node option
  • 25/01/2023 - Initial commit

Features

  • Detail and Distance textures
  • Five detail textures (shore/sea, ground, mountain, peak, cliff)
  • Five distance textures (shore/sea, ground, mountain, peak, cliff)
  • Automatically transitions between textures according to height (shore/sea, ground, mountain, peak) and angle (cliff)
  • Tri-Planar for cliffs (to prevent texture warping)
  • Two different blend modes between detail and distance textures:
    1. Overlay blend (combines distance and detail textures together)
    2. Transition (seemlessly transitions between distance and detail textures according to camera distance)
  • Automatic generation of normal maps (it's a bit hacky but it works)
  • Smoothness, Metallic, Normal and Color settings for each individual texture
  • Seemlessly transitions between normal, smoothness, and metallic settings based on camera distance
  • Use noise to variegate ground layer between ground texture and mountain texture
  • Doesn't need splatmaps, great for procedural terrain
  • Optional stochastic (antitiling) option (now tiles seemlessly across neighbour terrains)

Distance Desert_Distance

Detail Desert_Detail

Distance Grasslands_Distance

Detail Grasslands_Detail

Distance Ice_Distance

Detail Ice_Detail

Stochastic Off StochasticOff

Stochastic On StochasticOn

Inspector

How To Use

  1. Add the shader and sub-shaders to your project
  2. Create a new terrain
  3. Create a material
  4. Set material shader to Terrain Shadergraph (Shader Graphs -> Terrrain Shadergraph)
  5. Add the material to the terrain settings in the inspector
  6. Add your textures in the material inspector

Some Hints and Tips

  • The texture height is set relative the terrain texture height i.e. if your terrain is set 600 height all your texture heights will be lower than this.
  • Normals for distance textures need to be A LOT HIGHER than detail textures, a detail texture normal will normal be between 1-5 but distance texture will be between 2000-3000
  • For height textures (shore/sea, ground, mountain, peak) the scaling is as you would expect. For detail textures 2000 means that the texture will be tiled 2000 times across the terrain, whereas 1 for distance textures means that the texture will stretch to cover the whole terrain, BUT because of Tri-Planar cliff scaling is inverted so you will be typing in values like 0.005 or 0.1.

I have included a bunch of examples in the 'Examples' folder. This folder is not essential and can be deleted.

Credits

Licensed under Apache 2.0

About

A simple procedural terrain shader for unity's inbuilt terrain system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages