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 Curious-George · Nov 08, 2012 at 04:29 PM · shadermaterialimage effectsglow

Why is Alpha Cutoff Shader affected by glow?

My player character uses an Alpha-Cutoff-Diffuse shader to render, and the glow from the Image Effects/Glow is getting drawn on top of the player character.

Is there a way to alter the Alpha-Cutoff shader so that the glow won't show through it?

 Shader "Custom/Alpha Cut Off"
 {
     Properties
     {
         _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
         _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
     }
 
     SubShader
     {
         Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
         LOD 200
         
         CGPROGRAM
         #pragma surface surf Lambert alphatest:_Cutoff
 
         sampler2D _MainTex;
 
         struct Input
         {
             float2 uv_MainTex;
         };
 
         void surf (Input IN, inout SurfaceOutput o)
         {
             fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
             o.Albedo = c.rgb;
             o.Alpha = c.a;
         }
         ENDCG
     }
 
     Fallback "Transparent/Cutout/VertexLit"
 }

alt text

glow through.jpg (176.9 kB)
Comment
Add comment · Show 8
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 whydoidoit · Nov 08, 2012 at 04:59 PM 0
Share

Its a guess - but I presume that the alpha cutout shader is still writing to the o.Alpha of the output pixel and that this is in some way getting into the final image. If that happens then things with a high alpha glow.

Perhaps, and it's just perhaps, modifying the shader to say:

     o.Alpha = c.a < _Cutoff ? 0 : c.a;

You would need to add a float _Cutoff variable above the surf function.

avatar image whydoidoit · Nov 08, 2012 at 05:01 PM 0
Share

If you mean that the character is glowing where it isn't transparent then I can't quite figure out how to do it.

avatar image whydoidoit · Nov 08, 2012 at 05:03 PM 0
Share

Actually scrub that - I can: you could modify the final colour of the pixel with a finalcolor: function and remove the alpha from that.

    #pragma surface surf Lambert alphatest:_Cutoff finalcolor:final

   void final(Input IN, SurfaceOutput o, inout fixed4 color) {
       color.a = 0; //or whatever
 }
avatar image Curious-George · Nov 08, 2012 at 05:55 PM 0
Share

"color.a = 0"

tried this, and the result is nothing being drawn at all.

avatar image whydoidoit · Nov 08, 2012 at 05:57 PM 0
Share

Hmm, I was afraid of that. Did you try the o.Alpha = line?

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by markpdolby · Nov 08, 2012 at 04:59 PM

I believe it is because the glow effect uses the alpha channel to deter-main where it should blur and increase the brightness: http://docs.unity3d.com/Documentation/Components/script-GlowEffect.html

You could try using a modified version that this guy on the forums did: http://forum.unity3d.com/threads/13107-Glow-effect-with-adjustable-threshold-(enjoy)

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

Answer by Curious-George · Feb 12, 2013 at 12:12 AM

Finally found the answer to this one. The alpha has to be set to zero, or else the object glows, but if the alpha is set to zero, you see nothing n screen....... unless you use the right blend mode!

Blend One Zero color.a = 0;

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

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

11 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

Related Questions

Planet/Atmosphere shader problem. 0 Answers

How to create a Surface Shader in Unity? 1 Answer

Glowing column of light 1 Answer

Glow Effect 3 Answers

Rune glow effect on stones? 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