Brute Force - Sand Shader Documentation

9. Terrain Feature

Untitled-1.jpg

There is a template scene for terrain environment in the asset package (both built-in and URP) located here:

Untitled-1.jpg

If you want to create your own terrain and implement the sand shader here's the important steps to follow:

1. Setup the terrain

Untitled-1.jpg

Create a new terrain with a 100x100 dimension (works best out of the box rather than the HUGE 1000x1000 default terrain)

Then add the "SandTerrain01" material or its URP equivalent or your own Sand material

Untitled-1.jpg

IMPORTANT: You need to add the "BF_SandTerrain" script to your terrain for it to work properly and if you're only using the terrain feature of the sand shader without regards for other terrain assets compatibility you are not required to add a "terrainToCopy" parameter nor should you press the "Sync terrain Data" button

VERY IMPORTANT: Be extra careful with these fields, if you assign or press the sync terrain button on a terrain you do not want to change its previous height map it will override and change it, you can press the revert button to set the values back to how they were.

After you've set the right shader/material to your terrain get over the paint terrain tool in the terrain inspector:

2. Edit terrain layers

Untitled-1.jpg

To draw snow on the terrain use the SandLayer01, the position in the terrain layers arrangement is very important, the first one SHOULD ALWAYS be the sand layer.

To draw rock on the terrain use the other SandLayer (02,03), if you don't want/need other sand/rock layers you can delete them via the "Edit Terrain Layers" button (Currently limited to 4 layers).

If you want to edit the layers to have a new sand/rock layer you should head over to the corresponding "NewLayerXX" in the asset project:

Untitled-1.jpg

The first layer which should ALWAYS be a sand layer;

If you want to have a Sand Layer:

Diffuse is the Albedo Texture,

Normal Map is the bump map,

Normal Scale is the normal multiplier,

Mask Map is the displacement map,

Specular is the overall color of the sand,

Metalic should be set to 0,

Size.XY is the Tiling size

If you want to have a Rock Layer:

Diffuse is the Albedo Texture,

Normal Map is the bump map,

Normal Scale is the normal multiplier,

Mask Map is the Height Map,

Specular is the overall color of the rock,

Metalic should be set to 1,

Size.XY is the Tiling size

The only difference between a Sand Layer and an Rock Layer are Mask Map and Metallic slider.

STOP there if you don't use any other terrain assets and are not looking for cross-compatibility!

3. Terrain Asset compatibility (optional)

I implemented a solution for users to use my sand shader with any other terrain assets out there.

Here is what you need to do in order to get it working:

SnowDoc38.jpg

Let's assume you have a working terrain working with another terrain asset (it must be using the built-in terrain as a base)

SnowDoc39.jpg

Setup the sand terrain just like described in the steps before, add the sand terrain material and the BF_SandTerrain.cs script.

Untitled-1.jpg

In the BF_SandTerrain component; drag and drop the other asset terrain in the "TerrainToCopy" field.

Then press the Sync Terrain Data button to sync the dimensions and height texture.

(I strongly recommend you to lower the tessellation count on the sand terrain material, you don't need as much precision for sand on a terrain)

Untitled-1.jpg

The first layer should be a sand layer with metallic set to 0 just like the regular setup. And the second layer has to be a rock layer with metallic set to 1, use this layer to remove sand of the first layer.

Untitled-1.jpg

Now you should be able to draw sand with the sand layers and cull the sand to show the other terrain asset with the second layer of rock! You can add sand layers to this process for more variety.

Please keep in mind that these steps are only necessary when you want to use my sand shader terrain feature with other terrain assets, you do not need to do this if you only use my shaders.

If you're having trouble setting up a terrain with the sand shader here's a step-by-step video to complement the informations above:

Untitled-1.jpg