• 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
1
Question by phildude · Jun 01, 2010 at 03:21 PM ·

Glow shader on selective objects?

Hello! I've understood that the glow shader affects objects based on the alpha channel. I have an object in my scene that I don't want to be affected by glow, but it needs to have an alpha activated. The reason for this is that when other glowing objects pass over it, the glow effect gets multiplied or something which looks awesome but crazy. And unfortunately we cannot ship with that "feature" =P

Can I use a twin camera technique or something? Have one camera that sees everything that's supposed to glow and then overlay that to the camera the player looks through?

I have Pro. Thanks for reading! Phil

EDIT - quote from forum:

I think there's still some confusion in this thread as to how the glow effect works. As Jonathan said, most built-in shaders allow you to change the glow on a per-texel basis using the alpha channel of the main texture, and modulate it using the main colour's alpha (just like you can modulate the colour of the whole object).

The only time you need a special shader is when you have a shader that uses its texture alpha channel for something else. Usually, these shaders do not write to the screen's alpha, and so you can do one of two things:

  1. Add a pass (and possibly a source texture) to the shader in that writes alpha to the screen.
  2. Duplicate the geometry you want to glow, and use an alpha-only shader, such as "Fire zee alpha" from above, or something that gives you a source texture.

I'd like to really understand this matter, which I don't right now. Sorry for the n00bish nonsense coming up.

I understand from above that the shader written in the thread (Fire ze alpha) will make stuff glow. This is fine. But my problem remains; I have stuff in scene that glows because they use alpha for a semi-transparent texture (in some areas transparent, it's a galaxy picture). How will this help me if two semi-transparent textures get on top of each other and fire off this huge bloom?

I'm really sorry for being so daft.. I have no experience with shader programming and I didn't really understand the whole concept from the unity-video explaining how shaders work. I'm really grateful for any explanation as I'm having a hard time grasping it all (I suspect there are more than me!) :)

Comment
Add comment · Show 3
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 jonas-echterhoff ♦♦ · Jun 01, 2010 at 04:10 PM 0
Share

Why does that object need to render to the alpha channel?

avatar image phildude · Jun 01, 2010 at 04:17 PM 0
Share

It's a plane with an image on. The image has alpha and needs to show stuff under it... or have I misunderstood the technique?

avatar image equalsequals · Jun 01, 2010 at 07:41 PM 0
Share

Hey phildude, I'll edit my answer and give you a little insight of how I got around this hump.

3 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by noradninja · Oct 13, 2010 at 12:08 PM

Cant you place the non glow objects on a separate layer and use a second camera that renders only those objects without the glow effect?

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
2

Answer by equalsequals · Jun 01, 2010 at 05:00 PM

Hey phildude,

I recently came across the exact same bump. There is actually a few threads on the forums that discuss this as well. There is a shader example in the thread here that should give you a helping hand.

[Edit]

In response to your edit above -

What the glow shader does is go over your fully rendered frame, and use the alpha value of all of your objects to determine how much glow shows (full opaque is max glow, full transparent is no glow).

I believe this much you already know. So, the question is how you get an object that actually uses the alpha channel to give the material translucency to not glow.

What I did was duplicate the object I wanted to override the alpha of and apply an Alpha Override material to it.

The alpha override material used this shader:

Shader "Alpha Override" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _GlowMap ("Glow (A)", 2D) = "bump" {} } Category { Tags {"Queue" = "Transparent" } SubShader { Pass { ZWrite Off Offset -1, -1 Cull Back Colormask A SetTexture [_GlowMap] { constantColor [_Color] combine constant, texture * constant }

   }
  }

}

--it got a little messed up in copying it over but meh, it's all there.

I suppose you could also attach this as a second material to the same Mesh Renderer as well, but for what I used it for I needed a separate transform all together.

Hope that helps!

==

Comment
Add comment · Show 5 · 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 phildude · Jun 01, 2010 at 09:01 PM 0
Share

Okay I tried this but I still get some crazy effects.. I'm supposed to just duplicate it and make it a child of the original or the other way around? From what I've understood if this shader is closer to the camera than the normal shader, there's not supposed to be any glow, right?

avatar image phildude · Jun 01, 2010 at 09:02 PM 0
Share

Oh and thank you very much for taking the time to explain :)

avatar image equalsequals · Jun 01, 2010 at 09:25 PM 0
Share

I had it just occupying the same space as the other object, its position in the Hierarchy is irrelevant. Set your override object to be an alpha of 0 (no glow) and it will override the translucent object. A tip when playing around with this is to click the little drag box in the Editor View where it says (RGB) and set it to (Alpha) so that you get a better idea of whats producing glow and what isn't.

avatar image phildude · Jun 01, 2010 at 11:22 PM 0
Share

Hmm I'm probably doing something wrong or something is very special with my scene.. I'm actually getting a stronger effect of glow when it seems that I've correctly followed the procedure. I'll see if I can strip the scene and upload it somewhere for anyone to look at... thanks for your time!

avatar image Julian-Glenn · Jul 20, 2010 at 08:25 PM 0
Share

Shader script is missing a closing brace } at the bottom ;)

avatar image
1

Answer by Noise crime · Jan 08, 2011 at 08:31 AM

Which shader specifically is the model that you don't want to glow using?

Since the problem is that it renders its final alpha into the alpha of the color buffer, would not simply disabling writing to alpha fix the issue? Off hand I don't think disabling writing the alpha would stop it being rendered with alpha, but have never tested it myself. However if you have several alpha textured models overlaying each other using this method it might cause graphical issues, so may not be a fix for all cases.

To be clear I'm talking about adding, ColorMask RGB to the shader pass, this means only RGB values are written into the colour buffer, but not alpha.

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.

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

No one has followed this question yet.


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