AlphaAlpha

i’m wondering if someone with shader knowledge can help me, i haven’t had the time to learn anything about shaders yet - i think this is something simple and i tried to wing it by skimming the docs cutting-pasting from other shaders but i can’t seem to get it to work.

i need a shader that has a maintex with alpha (which i would have tiled) a separate, 2nd alpha channel texture slot as well. its like the two layer terrain, only no second texture (the 2nd alpha mask would not be tiled is for overall transparency not a second texture mix).

i’ve been fooling around with terrains i’d really like to try out some tests with this shader, and like the terrain two layer it doesn’t need 2 uv sets (as an aside - i imagine this could also be a method to have tiled terrains with lightmaps for those of us without maya).

hopefully this isn’t to complex, would anyone be able to put this together for me?

What do you want to use these two alphas for? Transparency or something else? How the alphas should be combined (added, multipled, …)?

sorry aras, both would be for transparency. i don’t quite understand combine modes with alpha, but i think multiply is what i’m looking for.

actually maybe i should describe specifically something i want to apply this to since i don’t understand what i need in shader terminology:

for instance, a large semi-flat mesh representing a cloud:

for the shader:

texture 1 would be tiled:
-rgb for color
-alpha for detailed transparency

texture 2 would not be tiled:
-no rgb needed
-alpha for overall transparency mask, so you don’t see the polys around the edges it just fades out nicely

hopefully that makes sense ; )

I think something like this shader could work:

Shader "Alpha/VertexLit TwoLayer" {
    Properties {
        _Color ("Main Color", Color) = (1,1,1,1)
        _SpecColor ("Spec Color", Color) = (1,1,1,0)
        _Emission ("Emmisive Color", Color) = (0,0,0,0)
        _Shininess ("Shininess", Range (0.1, 1)) = 0.7
        _MainTex ("Base (RGB) Trans (A)", 2D) = "gray" {}
        _AlphaTex ("Transparency (A)", 2D) = "white" {}
    }
    Category {
        ZWrite Off
        Alphatest Greater 0
        Tags {Queue=Transparent}
        Blend SrcAlpha OneMinusSrcAlpha 
        ColorMask RGB
        SubShader {
            Material {
                Diffuse [_Color]
                Ambient [_Color]
                Shininess [_Shininess]
                Specular [_SpecColor]
                Emission [_Emission]    
            }
            Pass {
                Lighting On
                SeperateSpecular On
                SetTexture [_MainTex] {
                    constantColor [_Color]
                    Combine texture * primary DOUBLE, texture * constant
                } 
                SetTexture [_AlphaTex] {
                    Combine previous, texture * previous DOUBLE
                }
            }
        } 
    }
}

It is exactly like builtin Alpha/VertexLit, just adds one more alpha-only texture (called _AlphaTex inside the shader). This texture does not modify the color (just takes “previous”), and combines alpha of both textures like: alpha1alpha22.

So if you use the alpha-only texture to control overall transparency, then primary texture’s alpha will work like a detail texture - alpha of 50% in the main texture will mean “don’t change overall alpha”, and lower/higher values will decrease/increase alpha.

thank you Aras ; )
i will try this out after work.