shader 0 "null" [
    in vec4 vvertex;
    void main(void)
    {
        gl_Position = vvertex;
    }
] [
    layout(location = 0) out vec4 fragcolor;
    void main(void)
    {
        fragcolor = vec4(1.0, 0.0, 1.0, 1.0);
    }
]

//////////////////////////////////////////////////////////////////////
//
// for filling the z-buffer only (i.e. multi-pass rendering, OQ)
//
//////////////////////////////////////////////////////////////////////

shader 0 "nocolor" [
    in vec4 vvertex;
    uniform mat4 camprojmatrix;
    void main() { gl_Position = camprojmatrix * vvertex; }
] [
    void main() {}
]

shader 0 "bbquery" [
    in vec4 vvertex;
    uniform mat4 camprojmatrix;
    uniform vec3 bborigin, bbsize;
    void main() { gl_Position = camprojmatrix * vec4(bborigin + vvertex.xyz*bbsize, vvertex.w); }
] [
    void main() {}
]

shader 0 "depth" [
    in vec4 vvertex;
    uniform mat4 camprojmatrix;
    @(ginterpdepth out)
    void main()
    {
        gl_Position = camprojmatrix * vvertex;
        @(gdepthpackvert)
    }
] [
    @(? $gdepthformat [
        layout(location = 0) out vec4 gdepth;
    ])
    @(ginterpdepth in)
    void main()
    {
        @(if (= $gdepthformat 1) [result [
            @(gpackdepth packdepth lineardepth)
            gdepth.rgb = packdepth;
            gdepth.a = 0.0;
        ]] [? (> $gdepthformat 1) [
            gdepth.r = lineardepth;
        ]])
    }
]

//////////////////////////////////////////////////////////////////////
//
// LDR variants of default shaders
//
//////////////////////////////////////////////////////////////////////

shader 0 "ldr" [
    in vec4 vvertex, vcolor;
    in vec2 vtexcoord0;
    uniform mat4 camprojmatrix;
    uniform float ldrscale;
    out vec2 texcoord0;
    out vec4 colorscale;
    void main(void)
    {
        gl_Position = camprojmatrix * vvertex;
        texcoord0 = vtexcoord0; 
        colorscale = vec4(ldrscale * vcolor.rgb, vcolor.a);
    }
] [
    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 "ldrnotexture" [
    in vec4 vvertex, vcolor;
    uniform mat4 camprojmatrix;
    uniform float ldrscale;
    out vec4 color;
    void main(void)
    {
        gl_Position = camprojmatrix * vvertex;
        color = vec4(ldrscale * vcolor.rgb, vcolor.a);
    }
] [
    in vec4 color;
    layout(location = 0) out vec4 fragcolor;
    void main(void)
    {
        fragcolor = color;
    }
]

//////////////////////////////////////////////////////////////////////
//
// fogged variants of default shaders
//
//////////////////////////////////////////////////////////////////////

shader 0 "fogged" [
    //:fog
    in vec4 vvertex, vcolor;
    in vec2 vtexcoord0;
    uniform mat4 camprojmatrix;
    out vec2 texcoord0;
    out vec4 colorscale;
    void main(void)
    {
        gl_Position = camprojmatrix * 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 "foggednotexture" [
    //:fog
    in vec4 vvertex, vcolor;
    uniform mat4 camprojmatrix;
    out vec4 color;
    void main(void)
    {
        gl_Position = camprojmatrix * vvertex;
        color = vcolor;
    }
] [
    in vec4 color;
    layout(location = 0) out vec4 fragcolor;
    void main(void)
    {
        fragcolor = color;
    }
]

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

