• 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 AlucardJay · Nov 10, 2012 at 06:40 AM · texturematerialrendereralpha

Correct Unlit Shader to use when Fading a Material

I have a texture applied to a plane, and wish to dynamically set the alpha. The problem is fading the texture using the alpha channel of material.color, after manually assigning the colour white at start.

I have this script which works when using the default transparent diffuse, but not any of the unlt shaders. The shaders for unlit from owlchemy labs didnt work either, even though I can see the alpha bar moving up and down.

 // START
 theMaterial = gameObject.renderer.material;
 theMaterial.color = Color.white;

 // UPDATE
 theMaterial.color = Color( theMaterial.color.r, theMaterial.color.g, theMaterial.color.b, health * 0.01 );

How do I change the alpha of a texture using an unlit shader? Which shader should I use? Does anyone have a link to a shader (shaderlab and UnityGems are my first call when have time to learn CG and shaders). Thanks =]

Owlchemy Labs Unlit Alpha Shader :

 //Originally by Bill Vinton (Sync1B)
 
 Shader "Unlit/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
        Offset -1, -1
        Blend SrcAlpha OneMinusSrcAlpha
        Tags { "Queue" = "transparent" }
        SubShader {
             Material {
                Emission [_Color]
             }
             Pass {
                SetTexture [_MainTex] {
                       Combine Texture * Primary, Texture * Primary
                 }
             }
         }
     }
 }
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
2
Best Answer

Answer by Jessespike · Nov 11, 2012 at 07:13 AM

Not sure if this is the best way, but it worked for me.

In the Material add:

 Diffuse [_Color]
Comment
Add comment · Show 3 · 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 · Nov 11, 2012 at 10:26 AM 0
Share

I no nothing about shaders, have no idea what that change does to the shader, but it works. I now have control of the alpha, many thanks.

avatar image AlucardJay · Jan 03, 2013 at 06:25 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. D'oh !

avatar image FatWednesday · Feb 28, 2013 at 02:31 PM 0
Share

This tiny fix is great :)

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

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

Changing two different objects renderer colour 1 Answer

How to switch the texture being used by the material of the mesh renderer 1 Answer

How to change a value in custom shader through script, C# 1 Answer

How could I make the texture on one object follow the rotation of another object? 0 Answers

change child texture problem 2 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