Help adding transparency to this simple vertex shader

Hi therem
I have this super simple vertex color shader…

Shader "Vertex Colour + Tint" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
}

Category {
	SubShader {
		Pass{
			ColorMaterial AmbientAndDiffuse
        	SetTexture [_MainTex] {
            	constantColor [_Color]
            	Combine previous * constant
        	}  
		}		
		}
	} 
}

And I’d love to have the trasparency based on the tint color’s transparency, could anyone help me get that happening?
It must be really simple but I can’t seem to get it working.

Thanks,
Pete

Hey Dudes,
Figured it out so I thought I’d pass this on in case anyone else was looking for the same thing -

Shader "Vertex Colour + Transparencey" {

Properties {
	_Color ("Solid Color (A = Opacity)", Color) = (0,0,0,1)	
}

Category {

	Blend SrcAlpha OneMinusSrcAlpha 
    SubShader {
        Pass{
            ColorMaterial AmbientAndDiffuse
            SetTexture [_MainTex] {
                constantColor [_Color]
                Combine previous * constant
            }  
        }       
        }
    } 
}

Damn!, this shader works fine for me but now the editor keeps telling me this -
“Shader wants texture coordinates, but the mesh doesn’t have them”
It’s a bit annoying, dos anyone know how I can make this shader forget about the uvs? I’m not using them on anything in my scenes…

Do you only use objects with a flat vertex color?

An alternative to uv-mapping is ‘triplanar mapping’ which however generally is overly taxing for normal situations. Just as a beginning example; a triplanar mapped shader uses up to 3x the amount of drawcalls a single would

An other option would be to make a static uv size, but it needs a reference like screenPos or worldPos

Im just using vertex colours from meshes, so no textures (or co-ordinates) needed.
It all works fine. The only problem I have is that the “Shader wants texture coordinates” messages fill up the console. :frowning:

I’d use the implementation used on this page ; Radiator Blog: The joys of using world space / procedural UVs for Unity3D
Or an implimentation like how some things are cast based on screen position

Example Code:

struct Input{
float4 screenPos;
};
void surf (Input IN, inout SurfaceOutput o){
fixed2 screenUV = (IN.screenPos.xy) / (IN.screenPos.w);
}
ENDCG

So you’d just give some UV co-ordinates at runtime to keep it happy? I’ll see how I go.

Aye, purely theoretically even using “fixed2(0,0)” as a UV should work in your case i realize now i’ve finally had my coffee :stuck_out_tongue:

Hehe that’s cool.
Thanks for the link too, pretty interesting.
Pete