- Home /
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!
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!
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 ;)
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
Follow this Question
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