Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
This question was closed Mar 17, 2018 at 07:38 AM by hexagonius for the following reason:

Question is off-topic or not relevant. Unity answers is not for letting other people do your work but asking and learning.

avatar image
0
Question by newfinalflashers · Mar 15, 2018 at 11:45 PM · shaderalphamaskaddplanet

Can someone add a 2D texture alpha mask to this planet shader

Shader "Custom/Planet" { Properties { _MainTex ("Diffuse(RGB) Spec(A)", 2D) = "white" {} _BumpMap ("Bumpmap", 2D) = "bump" {} _EmissionMap("Night Lights Map", 2D) = "white" {} _EmissionStr("Night Lights Strength", Range(0,1)) = 0.5 _EmissionColor("Night Lights Color", Color) = (1.0, 1.0, 1.0, 1.0) _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1) _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _SpecPower ("Specular Power", Float) = 48.0 } SubShader { Tags { "RenderType" = "Opaque" } CGPROGRAM

     #pragma surface surf Planet noambient
     float _Shininess;
     float _SpecPower;
     float _EmissionStr;
     half4 _EmissionColor;
     
     half4 LightingPlanet (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
         half3 lightView = normalize (lightDir + viewDir);
         half diffuse = max (0, dot (s.Normal, lightDir));
         float specStr = max (0, dot(s.Normal, lightView));
         float spec = pow (specStr, _SpecPower);
         half4 c;
         c.rgb = _LightColor0.rgb * (atten * 2) * (s.Albedo * diffuse + 
             spec * s.Specular * _Shininess * _SpecColor) + 
             (saturate(1.0-2*diffuse) * s.Alpha * _EmissionStr * _EmissionColor);
         c.a = s.Specular;
         return c;
     }
     
     struct Input {
         float2 uv_MainTex;
         float2 uv_BumpMap;
         float2 uv_EmissionMap;
         float3 viewDir;
     };
     sampler2D _MainTex;
     sampler2D _BumpMap;
     sampler2D _EmissionMap;
 
     void surf (Input IN, inout SurfaceOutput o) {
         o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
         o.Specular = tex2D (_MainTex, IN.uv_MainTex).a;
         o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
         o.Alpha = length(tex2D (_EmissionMap, IN.uv_EmissionMap).rgb);
     }
     
     ENDCG
 } 
 Fallback "Diffuse"

}

Comment
Add comment
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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

122 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

Related Questions

Cut out shader with geometry depth and alpha 0 Answers

Shader problem with 2D fake lighting 1 Answer

Shader mask using greyscale instead of alpha? 0 Answers

How should I add an alpha mask AND an alpha multiplier into a shader? 0 Answers

shader problem 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