Hey everyone, as I am no good at shader coding, I am compelled to turn to unity answers
anyway, what I want is just a basic defuse shader that render behind everything except the terrain, which I want the shader to render in front of.
Try this. I modified the default diffuse texture and added several tags to accomplish what you need I think. The queue order setting should cause rendering after the terrain and before any geometry, and along with the ZWrite Off tag should insure your normal geometry renders over anything with this shader. I added an Offset to help this shader render over the terrain, even when very close to the terrain surface.
Just use two cameras. One camera renders only the terrain’s layer, and the other camera renders the seen-through things. Give the cameras different depths and a ‘don’t clear’ background, and one will render on top of the other.