- Home /
Why does this Shader become hidden behind a skybox?
The shader below makes my objects disappear when I turn my sky box on. I guess it's got something to do with the Blend:
http://docs.unity3d.com/Documentation/Components/SL-Blend.html
But when I use anything other than "Blend SrcAlpha OneMinusSrcAlpha" it changes the effect I want.
I just want a self Illum shader with a separate alpha channel, is this the best way of doing it or does anyone else have a better, simple shader?
Shader "WormHoleShader2" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_AlphaTex ("Trans. (Alpha)", 2D) = "white" {}
}
SubShader {
ZWrite Off
Lighting On
Blend SrcAlpha OneMinusSrcAlpha
Pass {
SetTexture [_MainTex] {Combine texture}
SetTexture [_AlphaTex] {Combine previous, texture}
}
}
}
Answer by sethuraj · Oct 17, 2013 at 06:26 PM
Your sky-box is drawing in front of your mesh that's why it disappears. You need to turn On depth writing and turn of culling to draw both sides of the polygons.(If u know,ignore this - Your second texture '_AlphaTex' should have an alpha channel.It wont mask from RGB even if its only has Black n white)
Try this code (no tested properly)
Shader "WormHoleShader2"
{
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_AlphaTex ("Trans. (Alpha)", 2D) = "white" {}
}
SubShader
{
Tags
{
"Queue"="Transparent"
"RenderType"="Transparent"
}
Cull Off
ZWrite On
Lighting Off
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
SetTexture [_MainTex] {Combine texture}
SetTexture [_AlphaTex] {Combine previous, texture}
}
}
}
Hope this helps ...!!!
Your answer

Follow this Question
Related Questions
Fading in/out SVGs without showing the half-transparent SVG-layers 1 Answer
Mesh transparency halfway cutoff script 0 Answers
Need help with opacity error 0 Answers
Is it possible to create a blur effect based on the alpha of a transparent texture on a plane? 0 Answers
Alpha not displaying when changed in code, unless changed manually in the inspector 0 Answers