Constant shader with vertex colours

Is it possible to write a shader that is a flat unlit colour where the colour comes from vertex colours, without writing a vertex shader.

I see BindChannels in the ShaderLab help that seems to suggest it is possible but it doesn’t give any clear examples of how to use it.

I’d tried this

Shader "My Shaders/ConstantVertex" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
	}
	SubShader {
		Tags { "RenderType"="Opaque" }
		Pass {
			Name "BASE"
			Lighting Off
			BindChannels {
			   Bind "Color", color
			} 
			
		}
	}
}

But that throws a load of errors.

This shader is very close to what you’re looking for:

Shader "Vertex Colored" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SpecColor ("Spec Color", Color) = (1,1,1,1)
    _Emission ("Emmisive Color", Color) = (0,0,0,0)
    _Shininess ("Shininess", Range (0.01, 1)) = 0.7
    _MainTex ("Base (RGB)", 2D) = "white" {}
}
 
SubShader {
    Pass {
        Material {
            Shininess [_Shininess]
            Specular [_SpecColor]
            Emission [_Emission]    
        }
        ColorMaterial AmbientAndDiffuse
        Lighting Off
        SeperateSpecular On
        SetTexture [_MainTex] {
            Combine texture * primary, texture * primary
        }
        SetTexture [_MainTex] {
            constantColor [_Color]
            Combine previous * constant DOUBLE, previous * constant
        } 
    }
}
 
Fallback " VertexLit", 1
}

That does the trick thanks.
I actually had something like that before and it didn’t seem to work. I’ve now realised why, it had nothing to do with the shader and everything to do with how I was setting the vertex colours! :sweat_smile: