- Home /
Terrain transparent texture
How do I can use transparent texture on my terrain in Unity5? This shader don't work http://wiki.unity3d.com/index.php/TerrainTransparency
Answer by FortisVenaliter · Jan 27, 2016 at 02:59 PM
The standard shaders' source code are all available for download here.
I recommend you open up the terrain one, and modify it to allow transparency, then import the modified shader into your project. The docs for writing shaders are pretty good.
Sorry, I'am not good in shaders, may you discribe it better? Or at least something about which sader I should replace?
Has anyone done this and have some code to share? I'd like to be able to then access the transparency map from scripts to change transparency of portions of the terrain dynamically.
Answer by PeteXZ · Mar 17, 2018 at 10:06 PM
I've just spent a few hours working this out, so here is my answer for anyone else who is stuck on this.
First of all, download the shader source code as described by @FortisVenaliter. You will get a zip file with lots of shaders in. Find Standard-FirstPass.shader and copy it to your Assets directory. This will replace one of the built in terrain shaders, but nothing will change at the moment because it's still the same as it always was.
Now open the file in an editor. Search for the SplatmapMix line. After it, add a line reading: if(splat_control.r > 0.05) discard;
This means that any pixels which would normally be rendered with the first texture are now thrown away. You should therefore use some dummy texture as your first one, then put your real terrain textures after that. It follows that when you create a new terrain, it will initially be entirely transparent, so it may appear not to have worked. Just paint something on the terrain and you should see it working.
Your answer
Follow this Question
Related Questions
Terrain look 1 Answer
Changing terrain texture on contact (collision) 2 Answers
Fuzzy Texture On FPS Camera 2 Answers
Terrain Painting, brush smaller than 1? 1 Answer
How do I determine what texture I am hitting on a terrain? 0 Answers