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 Dubious-Drewski · Jun 21, 2014 at 08:10 AM · shaderalphaopacity

A shader with self-illumination and alpha control - doesn't exist?

I need a shader that can have its opacity changed "material.color.a = 0.5f" etc. I also need it to be self-illuminated. I have been Googling all night long, and I can't find an answer. The two shaders which come closest to what I need are:

Transparent/Diffuse - I can change the alpha, but it isn't self-lit.

Unlit/Transparent - It's self-lit, but I can't affect the alpha in any way.

I also found this person's custom shader, but I can't get the alpha to change no matter what I try. I'm desperate for suggestions, if anyone's got any! Please!

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
1

Answer by Dubious-Drewski · Jun 26, 2014 at 05:12 PM

I've been trying to figure this out, with no luck.

Using Shaderlab, if I define my _Color as (1.0, 1.0, 1.0, 0.5) then why doesn't it make it half-transparent when I "Combine" at the end? It just stays fully-opaque. I don't understand.

I'm using the right blend mode, right? - Blend SrcAlpha OneMinusSrcAlpha

And I've put the shader in the right render position, right? - Tags {Queue=Transparent}

So what am I missing?

I'm trying to study the shaders that come with Unity, but they're all already compiled, and they're 10,000 lines long with blocks of gibberish letters in them. I can't follow it. The official tutorials explain a lot, but none have a basic example showing simple transparency control.

My question is simple, and there MUST be a simple answer out there. Please help!

Comment
Add comment · Show 2 · 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 tanoshimi · Jun 26, 2014 at 05:29 PM 1
Share

This should be trivial, but I'm not near a PC right now to check. However, I will just point out that the source for all built-in shaders is available at https://unity3d.com/unity/download/archive rather than trying to slog through the compiled versions ;)

avatar image Dubious-Drewski · Jun 26, 2014 at 06:19 PM 3
Share

You did it! You really actually helped me! THAN$$anonymous$$ YOU.

I downloaded the shaders Zip (for version, 4.5.1) and combined lines from Illum-Diffuse shader with the Alpha-Diffuse shader and I made this:

 Shader "Transparent/AlphaSelfIllum3" {
     Properties {
         _Color ("$$anonymous$$ain Color", Color) = (1,1,1,1)
         _$$anonymous$$ainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
         _EmissionL$$anonymous$$ ("Emission (Lightmapper)", Float) = 0        
     }
     
     SubShader {
         Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
         LOD 200
     
         CGPROGRA$$anonymous$$
         #pragma surface surf Lambert alpha
         
         sampler2D _$$anonymous$$ainTex;
         sampler2D _Illum;
         fixed4 _Color;
         
         struct Input {
             float2 uv_$$anonymous$$ainTex;
             float2 uv_Illum;
         };
         
         void surf (Input IN, inout SurfaceOutput o) {
             fixed4 c = tex2D(_$$anonymous$$ainTex, IN.uv_$$anonymous$$ainTex) * _Color;
             o.Albedo = c.rgb;
             o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a;
             o.Alpha = c.a;
         }
         ENDCG
     }
     
     Fallback "Transparent/VertexLit"
 }
 

It doesn't use Shaderlab as much as I hoped, and I only vaguely understand each line, but It works it works it works! Thank you so much!

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

21 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Transperency not working correctly on imported objects. 1 Answer

transparent mode does not work at alpha=255 1 Answer

Toon shader and alphas 0 Answers

Shader Graph Increment vector1 1 Answer

Alpha Shader not working with obj collision 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