Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Bikupan · Jun 25, 2015 at 09:51 AM · shaderalphashaderlabcg

custom Standard Shader alpha issues.

Sorry for the generic title but I'm having a hard time explaining this issue in a simple way. I've made a custom shader based on the standard lighting model, my goal being simply to animate the emission component of the shader. Everything works splendidly, except for the alpha, of all things.

My issue is that the alpha never really becomes fully transparent, even though it should be. The texture maps used have correct alpha, and even if I were to manually set the alpha to zero in the shader, I'd get the following result:

alt textalt text

When viewed from an angle like the picture to the right, the issue is less prominent, dunno if this is a clue. To further eliminate possible culprits, all the lighting stuff for the mesh is turned off, lighting is turned off in the shader, and fog as well.

 //
 SubShader {
         Tags {"Queue" = "Transparent" "RenderType" = "Transparent"}
         Blend SrcAlpha OneMinusSrcAlpha
         Lighting Off
         Fog {Mode Off}
         Zwrite Off
         LOD 200
 
         CGPROGRAM
 
         #include "UnityCG.cginc"
 
         // Physically based Standard lighting model, and enable shadows on all light types
         #pragma surface surf Standard alpha
 
         // Use shader model 3.0 target, to get nicer looking lighting
         #pragma target 3.0
 
         fixed4 _Color;
         sampler2D _MainTex;
         fixed4 _GlowColor;
         sampler2D _GlowTex;
         fixed _Speed;
         fixed _Power;
         fixed _Falloff;
         fixed _Alpha;
 
         struct Input {
             float2 uv_MainTex;
         };
 
         void surf (Input IN, inout SurfaceOutputStandard o) {
 
             float4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
             clip (c.a);
             o.Albedo = c.rgb;
             o.Alpha = c.a;
             //o.Alpha = c.a * _Alpha;
             //float4 e = tex2D (_GlowTex, IN.uv_MainTex);
             //e.a = frac(e.a + -_Time) * c.a;
             //o.Emission = (e.rgb * c.a + pow(e.a, _Falloff)) * _Alpha * _GlowColor;
         }
         ENDCG
 //

Any ideas on how to tackle this?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bikupan · Jun 25, 2015 at 11:14 AM

After some digging around I found the problem.

 #pragma surface surf Standard alpha

should use alpha:fade instead. I'm not sure why the regular alpha mode didn't work properly, I don't see any reason why it shouldn't, but with alpha:fade it works.

Comment
Add comment · Show 1 · 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 Namey5 · Apr 10, 2016 at 06:35 AM 0
Share

I'm pretty sure the default alpha setting is premul, so it wouldn't go fully trans to allow for glass reflections, etc.

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.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

CG Shader: Setting output alpha changes RGB too 0 Answers

Add transparency to mask shader 1 Answer

Can anyone help me with reflective shader with fall off property? 0 Answers

Problem with lighting in CG Shader 1 Answer

Grab Pass alternative? Frag shader that applies alpha values behind it to itself. 1 Answer


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