Terrain AddPass Turn off alpha blending

Hi there

Is it possible to change the terrain shader’s “AddPass.shader” to draw over the existing textures as opposed to using additive blending. Essentially what I want is that the AddPass simply draws over the existing terrain wherever the alpha is 1, and draw nothing when its 0. I’ve tried removing the “decal:add” option, but this seems to cause issues with the fog calculation. The same happens when I use “decal:blend”. The areas seem to go black and are unaffected by fog.

The reason why I need this is because I have a terrain with many layers and I want the higher layers to be drawn over the lower ones. Because the technique is additive I get areas where the terrain starts going white is some areas. I am generating the alpha splat programmatically. So its possible to get values in the alpha map as such:

heightmap[x,y, 0]  = 0.1f;
heightmap[x,y, 1]  = 0.1f;
heightmap[x,y, 2]  = 0.1f;
heightmap[x,y, 3]  = 1;  // This can be 1
heightmap[x,y, 4]  = 1; // This can also be 1

Because index 3 and 4 are both 1, the terrain goes white in those areas.

As you can see the desert texture in the corner gets stronger as it gets the edge, but also whiter because the alpha values for the underlying textures are also getting strong. I want it so that the desert texture is simply drawn over the other textures as opposed to being added together.

Is this possible? Many thanks for any insight :slight_smile:

This is when I remove the decal option:

Did you ever figure this out? I’m running into the same issue and this is the only thread I’ve found that’s relevant.

You can add alphatest:_Cutoff to the surface shader options and define a _Cutoff variable in your terrain shader to control it. That gives you a hard alpha cutoff for your add pass. Some (brief) details at Unity - Manual: Writing Surface Shaders