• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Neon_Apollo · Feb 24, 2019 at 06:40 AM · shaderterrainshaderstransparency

How to make terrain partially transparent (lower opacity)

Hey all, I have been through a few tutorials on how to make terrain transparent, but the only information most give is the code for a shader. What do I do with the shader and how do I use it to make the terrain transparent? Thanks for any answers.

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by dan_wipf · Feb 24, 2019 at 08:25 AM

Wehave you read t$$anonymous$$s here? https://answers.unity.com/questions/1162779/unity-5-transparent-terrain-shader.html it replaces the standard terrain shader


Edit


as mentioned in the above article, copy paste t$$anonymous$$s in a new created shader file

 Shader "Terrain/Transparency" 
  {
       Properties {
           [HideInInspector] _Control ("Control (RGBA)", 2D) = "red" {}
           [HideInInspector] _Splat3 ("Layer 3 (A)", 2D) = "w$$anonymous$$te" {}
           [HideInInspector] _Splat2 ("Layer 2 (B)", 2D) = "w$$anonymous$$te" {}
           [HideInInspector] _Splat1 ("Layer 1 (G)", 2D) = "w$$anonymous$$te" {}
           [HideInInspector] _Splat0 ("Layer 0 (R)", 2D) = "w$$anonymous$$te" {}
           [HideInInspector] _Normal3 ("Normal 3 (A)", 2D) = "bump" {}
           [HideInInspector] _Normal2 ("Normal 2 (B)", 2D) = "bump" {}
           [HideInInspector] _Normal1 ("Normal 1 (G)", 2D) = "bump" {}
           [HideInInspector] _Normal0 ("Normal 0 (R)", 2D) = "bump" {}
           // used in fallback on old cards & base map
           [HideInInspector] _MainTex ("BaseMap (RGB) Trans (A)", 2D) = "w$$anonymous$$te" {}
           [HideInInspector] _Color ("Main Color", Color) = (1,1,1,1)
       }
   
       CGINCLUDE
           #pragma surface surf Lambert alpha vertex:SplatmapVert finalcolor:SplatmapFinalColor finalprepass:SplatmapFinalPrepass finalgbuffer:SplatmapFinalGBuffer
           #pragma multi_compile_fog
           #include "TerrainSplatmapCommon.cginc"
   
           void surf(Input IN, inout SurfaceOutput o)
           {
               half4 splat_control;
               half weight;
               fixed4 mixedDiffuse;
               SplatmapMix(IN, splat_control, weight, mixedDiffuse, o.Normal);
               o.Albedo = mixedDiffuse.rgb;
               o.Alpha = mixedDiffuse.a;
           }
       ENDCG
   
       Category {
           Tags {
               "Queue" = "Transparent+1"
               "RenderType" = "Transparent"
           }
           // TODO: Seems like "#pragma target 3.0 _TERRAIN_NORMAL_MAP" can't fallback correctly on less capable devices?
           // Use two sub-shaders to simulate different features for different targets and still fallback correctly.
           SubShader { // for sm3.0+ targets
               CGPROGRAM
                   #pragma target 3.0
                   #pragma multi_compile __ _TERRAIN_NORMAL_MAP
               ENDCG
           }
           SubShader { // for sm2.0 targets
               CGPROGRAM
               ENDCG
           }
       }
   
       Dependency "AddPassShader" = "Hidden/TerrainEngine/Splatmap/Diffuse-AddPass"
       Dependency "BaseMapShader" = "Diffuse"
       Dependency "Details0"      = "Hidden/TerrainEngine/Details/Vertexlit"
       Dependency "Details1"      = "Hidden/TerrainEngine/Details/WavingDoublePass"
       Dependency "Details2"      = "Hidden/TerrainEngine/Details/BillboardWavingDoublePass"
       Dependency "Tree0"         = "Hidden/TerrainEngine/BillboardTree"
   
       Fallback "Diffuse"
  }


create a new Material and asign t$$anonymous$$s shader to it. under the Terrain Settings, you’re able to asign the material under the Setting: Material to the Terrain.


now to paint Transparency to your Terrain you need to have a Transparent Image, t$$anonymous$$s you asign just as normal teztures to the Terrain. the Trick is now, that your other Textures don’t have a Alpha Channel, unless you want the texture to have Transparency!


If you don’t want to have Transparency om the Textures you need to delete the Alpha Channel in a 3d Party Programm like Photoshop, Gimp.

Comment

People who like this

0 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Neon_Apollo · Feb 27, 2019 at 12:52 AM 0
Share

Hi thanks for the reply, I'm still not exactly sure how this is supposed to work? I created a new standard shader, deleted all of its default code and pasted all of the code from that link into it and saved it. What do I do then? when I go to paint a texture on the terrain it still shows up 100% opacity.

EDIT: Don't worry, I have figured out a workaround, all I needed to do was create a material with low opacity and change my terrains material to that. Thanks for the help anyways!

avatar image dan_wipf Neon_Apollo · Feb 27, 2019 at 02:01 AM 0
Share

@Neon_Apollo edited my Answer

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

186 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Objects visible through terrain 2 Answers

How to hide Unity terrain trees when they are blocking the camera view? 0 Answers

Rendering transparent objects back to back (HDRP Lit shader) 0 Answers

FX/Flare is always on top 0 Answers

Simplest Unlit Instanced shader - how to enable switching it on/off (with AlphaTest)? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges