Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 shadowriffe · May 19, 2012 at 12:59 AM · shadercolortransparencyunlitsolid

Unlit Shader With Texture, Color, Overbrightness, and Alpha-based Transparency

Today I was working on making code that would flash my mesh a certain color, and then return to the standard color. I am planning on baking in my own shadows on characters like Mega Man Legends, so I would like to know that what I am coloring in an external program is what I get in Unity. For this purpose, Unlit textures seems to be the way to go.

Basically, I need an unlit texture that has a color property such that when the color property is {127,127,127,255} it looks the same as an unlit shader. At {255,255,255,255} the character is solid white (Overbrightness?). At {0,0,0,255} the character is solid black.

But I also want the alpha channel of the color to determine the transparency of my character. So that at {127,127,127,127} he is colored like the unlit shader, but halfway transparent. When alpha is zero, he is invisible etc.

I have found a couple shaders that bring me close on the color aspect but not on the transparency.

 Shader "Custom" {
     Properties {
         _Color ("Main Color", Color) = (1,1,1,1)
         _MainTex ("Base (RGB)", 2D) = "white" {}
     }
     Category {
        SubShader {
             Tags { "Queue" = "Geometry" }
             Pass {
                 SetTexture [_MainTex] {
                     constantColor [_Color]
                     Combine texture * constant DOUBLE
                 }
             }
         }
     }
 }

The above shader is good because it is normal at {127,127,127,255}, but it is not bright enough at white (Not solid). Transparency does not match alpha.

 Shader "Vertex color unlit2" {
     Properties {
         _Color ("Color", Color) = (1,1,1,1)
         _MainTex ("Texture", 2D) = "white" {}
     }

     Category {
         Tags { "Queue"="Geometry" }
         Lighting Off
         BindChannels {
             Bind "Color", color
             Bind "Vertex", vertex
             Bind "TexCoord", texcoord
         }
        
         // ---- Dual texture cards
         SubShader {
             Pass {
                 SetTexture [_MainTex] {
                     //combine texture * primary
                 }
                 SetTexture [_MainTex] {
                     constantColor [_Color]
                     combine previous lerp (previous) constant DOUBLE
                 }
             }
         }
        
         // ---- Single texture cards (does not do vertex colors)
         SubShader {
             Pass {
                 Blend SrcAlpha OneMinusSrcAlpha     // Alpha blending
                 SetTexture [_MainTex] {
                     constantColor [_Color]
                     combine texture lerp(texture) constant DOUBLE
                 }
             }
         }
     }
 }

This second shader is good, but the "baseline" is Black and it is dark and the textures look burnt. When the color is white, the object is solid white which is desirable. This does not have the alpha based transparency that i want either.

I tried adding in the alpha, but nothing got the right look. I hope I made my desired effect clear, thank you in advance for any help.

https://www.dropbox.com/s/scrmqax06uxf12r/shader.png

^Here is a picture of the desired effect of the shader. From right to left: {127,127,127,255} {255,255,255,255} {127,127,255,127}

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

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Additive particle shader with higher max alpha? 0 Answers

How do I add transparency to a cg vertex lit shader 2 Answers

Add Color Property to Unlit Alpha? 1 Answer

Transparency cube shader? 1 Answer

Shader that renders all faces the same color and is affected by light? 0 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