///////////////////////////////////////////////////
//
// used for rendering to the HUD
//
///////////////////////////////////////////////////

shader 0 "hud" [
    in vec4 vvertex, vcolor;
    in vec2 vtexcoord0;
    uniform mat4 hudmatrix;
    out vec2 texcoord0;
    out vec4 colorscale;
    void main(void)
    {
        gl_Position = hudmatrix * vvertex;
        texcoord0 = vtexcoord0; 
        colorscale = vcolor;
    }
] [
    uniform sampler2D tex0;
    in vec2 texcoord0;
    in vec4 colorscale;
    layout(location = 0) out vec4 fragcolor;
    void main(void)
    {
        vec4 color = texture2D(tex0, texcoord0);
        fragcolor = colorscale * color;
    }
]

shader 0 "hudtext" [
    in vec4 vvertex, vcolor;
    in vec2 vtexcoord0;
    uniform mat4 hudmatrix;
    out vec2 texcoord0;
    out vec4 colorscale;
    void main(void)
    {
        gl_Position = hudmatrix * vvertex;
        texcoord0 = vtexcoord0; 
        colorscale = vcolor;
    }
] [
    uniform sampler2D tex0;
    uniform vec4 textparams;
    in vec2 texcoord0;
    in vec4 colorscale;
    layout(location = 0) out vec4 fragcolor;
    void main(void)
    {
        float dist = texture2D(tex0, texcoord0).r;
        float border = smoothstep(textparams.x, textparams.y, dist);
        float outline = smoothstep(textparams.z, textparams.w, dist);
        fragcolor = vec4(colorscale.rgb * outline, colorscale.a * border);
    }
]

shader 0 "hudrgb" [
    in vec4 vvertex, vcolor;
    in vec2 vtexcoord0;
    uniform mat4 hudmatrix;
    out vec2 texcoord0;
    out vec4 colorscale;
    void main(void)
    {
        gl_Position = hudmatrix * vvertex;
        texcoord0 = vtexcoord0; 
        colorscale = vcolor;
    }
] [
    uniform sampler2D tex0;
    in vec2 texcoord0;
    in vec4 colorscale;
    layout(location = 0) out vec4 fragcolor;
    void main(void)
    {
        vec4 color = texture2D(tex0, texcoord0);
        fragcolor.rgb = colorscale.rgb * color.rgb;
        fragcolor.a   = colorscale.a;
    }
]

shader 0 "hudnotexture" [
    in vec4 vvertex, vcolor;
    uniform mat4 hudmatrix;
    out vec4 color;
    void main(void)
    {
        gl_Position = hudmatrix * vvertex;
        color = vcolor;
    }
] [
    in vec4 color;
    layout(location = 0) out vec4 fragcolor;
    void main(void)
    {
        fragcolor = color;
    }
]

shader 0 "hudrect" [
    in vec4 vvertex, vcolor;
    in vec2 vtexcoord0;
    uniform mat4 hudmatrix;
    out vec2 texcoord0;
    out vec4 colorscale;
    void main(void)
    {
        gl_Position = hudmatrix * vvertex;
        texcoord0 = vtexcoord0; 
        colorscale = vcolor;
    }
] [
    uniform sampler2DRect tex0;
    in vec2 texcoord0;
    in vec4 colorscale;
    layout(location = 0) out vec4 fragcolor;
    void main(void)
    {
        fragcolor = colorscale * texture2DRect(tex0, texcoord0);
    }
]

shader 0 "hud3d" [
    in vec4 vvertex, vcolor;
    in vec3 vtexcoord0;
    uniform mat4 hudmatrix;
    out vec3 texcoord0;
    out vec4 color;
    void main(void)
    {
        gl_Position = hudmatrix * vvertex;
        texcoord0 = vtexcoord0;
        color = vcolor;
    }
] [
    uniform sampler3D tex0;
    in vec3 texcoord0;
    in vec4 color;
    layout(location = 0) out vec4 fragcolor;
    void main(void)
    {
        fragcolor = color * texture3D(tex0, texcoord0);
    }
]

shader 0 "hudcubemap" [
    in vec4 vvertex, vcolor;
    in vec3 vtexcoord0;
    uniform mat4 hudmatrix;
    out vec3 texcoord0;
    out vec4 colorscale;
    void main(void)
    {
        gl_Position = hudmatrix * vvertex;
        texcoord0 = vtexcoord0;
        colorscale = vcolor;
    }
] [
    uniform samplerCube tex0;
    in vec3 texcoord0;
    in vec4 colorscale;
    layout(location = 0) out vec4 fragcolor;
    void main(void)
    {
        fragcolor = colorscale * textureCube(tex0, texcoord0);
    }
]

