- Home /
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.
Dude! Thanks! Could you post that as an answer so I can rate you up? :)
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/
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/
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
Follow this Question
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