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
1
Question by badjano · Nov 13, 2012 at 04:23 AM · shadermaterialtransparencyalphaself-illumination

Changing material color´s alpha in self iluminated shader

I am having problem changing material´s alpha value on my self iluminated shader material, I am able to change the other values of the color ( such as red, green or blue values ) but not the alpha value, this is what I´m trying to do:

 this.renderer.material.color = new Color( 1.0f, 1.0f, 1.0f, 0.0f );

By doing that, I expected the material to be totally transparent, but it just ignores the alpha value of 0 that I assigned, this is the shader´s code that I´m using:

 Shader "AlphaSelfIllum" {
     Properties {
         _Color ("Color Tint", Color) = (1,1,1,1)
         _MainTex ("SelfIllum Color (RGB) Alpha (A)", 2D) = "white"
     }
     Category {
        Lighting On
        ZWrite Off
        Cull Back
        Blend SrcAlpha OneMinusSrcAlpha
        Tags {Queue=Transparent}
        SubShader {
             Material {
                Emission [_Color]
             }
             Pass {
                SetTexture [_MainTex] {
                       Combine Texture * Primary, Texture * Primary
                 }
             }
         } 
     }
 }

I´m totally noob at shader coding, so if anyone could point me in a direction, I would be very thankfull.

Comment
Add comment · Show 2
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 badjano · Nov 13, 2012 at 03:39 PM 0
Share

Dude! Thanks! Could you post that as an answer so I can rate you up? :)

avatar image AlucardJay · Nov 13, 2012 at 05:28 PM 0
Share

Ok, thanks for that. Am just glad it worked (one day I'll know why!). $$anonymous$$y guess is that Diffuse applies alpha while Emission just pumps out the colour. All the best.

To future readers : Check out UnityGems for an introduction to program$$anonymous$$g shaders (along with lots of other helpful Unity program$$anonymous$$g help) : http://unitygems.com/noobshader1/

1 Reply

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

Answer by AlucardJay · Nov 13, 2012 at 06:33 AM

I had exactly the same problem ! : http://answers.unity3d.com/questions/345917/correct-unlit-shader-to-use-when-fading-a-material.html

Like you , I no nothing about CG and shaders, but the advice given to me there was : under material,

add Diffuse [_Color]

e.g.

 SubShader {
     Material {
         Emission [_Color]
         Diffuse [_Color]
     }

it's funny, the shaders look like almost the same script, but I have no idea what they do or the difference! Maybe this will help, good luck =]

UnityGems have a shader tutorial now. I shall be checking that out when ready : http://unitygems.com/noobshader1/

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 AlucardJay · Jan 03, 2013 at 06:26 PM 0
Share

Update : I'm silly, there is an Unlit Alpha Self-Illum With Fade at the same place I got this, from Owlchemy Labs (http://owlchemylabs.com/content/). D'oh !

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

10 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

Related Questions

(c#) Transparency Problem - Toggle not Gradient 1 Answer

Add transparency to mask shader 1 Answer

Alpha as Illumination AND Transparency? 0 Answers

How do you make an X-ray vision following the mouse? 1 Answer

Shader alpha depth problem? 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