// Touches du clavier : fond = couleur de sommet, symbole = canal alpha de l'atlas.
Shader "VRCMessages/Keys"
{
    Properties
    {
        _Atlas ("Atlas de police (alpha)", 2D) = "white" {}
        _GlyphColor ("Couleur du symbole", Color) = (1,1,1,1)
        _Brightness ("Luminosité", Range(0.5, 3)) = 1.2
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" "Queue"="Geometry" }
        Cull Off
        Lighting Off

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            sampler2D _Atlas;
            fixed4 _GlyphColor;
            float _Brightness;

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
                fixed4 color : COLOR;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct v2f
            {
                float4 pos : SV_POSITION;
                float2 uv : TEXCOORD0;
                fixed4 color : COLOR;
                UNITY_VERTEX_OUTPUT_STEREO
            };

            v2f vert (appdata v)
            {
                v2f o;
                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_INITIALIZE_OUTPUT(v2f, o);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
                o.pos = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                o.color = v.color;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                float a = tex2D(_Atlas, i.uv).a;
                fixed3 bg = i.color.rgb;
                fixed3 col = lerp(bg, _GlyphColor.rgb, a) * _Brightness;
                return fixed4(col, 1);
            }
            ENDCG
        }
    }
}
