- Home /
iPhone Shader - Unlit, 2 textures (alpha blend), Base needs tint.
Hello Unity Community.
Thank you for taking the time to check out my question. I am trying to put a shader together. I snipped bits and piaces from all over. Including one of Jessy's answers on a blend material.
http://answers.unity3d.com/questions/32386/iphone-blend-two-textures-additive-blending.html
Which is great but I needed was a little closer to the Unity example on Texture blends.
 Shader "Examples/2 Alpha Blended Textures" {
     Properties {
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _BlendTex ("Alpha Blended (RGBA) ", 2D) = "white" {}
     }
     SubShader {
         Pass {
             // Apply base texture
             SetTexture [_MainTex] {
                 combine texture
             }
             // Blend in the alpha texture using the lerp operator
             SetTexture [_BlendTex] {
                 combine texture lerp (texture) previous
             }
         }
     }
 }  
The problem is that it does not allow me to Tint I have been trying to add it from other bits of code but with no luck. The closest thing I found was a Unlit shader with the ability to alter the tint that someone made, Then I added the blend alpha texture part of the shader and it works but parts of it are semi transparent and I am having a hard time figuring out why.
This is the closest shader I was able to snip together to do what I want. How would I remove the semi transparent aspect of it.
 Shader "Unlit/AlphaSelfIllum TexBlend" {
     Properties {
         _Color ("Color Tint", Color) = (1,1,1,1)
         _MainTex ("SelfIllum Color (RGB) ", 2D) = "white"
         _BlendTex ("Alpha Blended (RGBA) ", 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
                 }
                  // Blend in the alpha texture using the lerp operator
             SetTexture [_BlendTex] {
                 combine texture lerp (texture) previous
             }
             }
         } 
     }
 }
bump.
That is always the problem with more advanced questions. It takes so much longer to get an answer. I can only hope some expert walks into this question by chance.
Answer by Jessy · Nov 22, 2011 at 06:56 AM
You haven't said what you want to do with the alpha blend. I'm going to go with the assumption that you want the alpha channel of "Color Tint" to provide a constant value until you say otherwise.
(Lighting, and the Category block, were not useful to you. Just paste this in place of your Category block.)
 SubShader {
     Tags {"Queue"="Transparent"}
     ZWrite Off
     Blend SrcAlpha OneMinusSrcAlpha
     Pass {
         SetTexture[_MainTex] {
             ConstantColor[_Color]
             Combine texture * constant, constant
         }
         SetTexture[_BlendTex] {Combine texture Lerp(texture) previous, previous}
     }
 }
Thank you Jessy, this works great. I did not know what ZWrite Off actually does or Tag..And its not what I needed but once removed it worked great.
Thank you for your time.
Sorry if I did not explain it correctly. again. Thank you, I spent a lot of time yesterday trying to figure this out.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                