

#include "/lib/uniforms.glsl"

varying vec4 color;
varying float NdotL;
varying vec3 viewVector;
flat varying vec3 torch;
varying vec4 lmtexcoord;
uniform float lightSign0;

#include "/lib/taa/res_params.glsl"
uniform mat4 gbufferModelViewInverse;
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
vec4 toClipSpace3(vec3 viewSpacePosition)
{
    return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition), -viewSpacePosition.z);
}
vec3 viewToWorld(vec3 viewPos)
{
    return (gbufferModelViewInverse * vec4(viewPos, 0.0)).xyz;
}

//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////

const vec3 torchColor = vec3(3.000, 1.382, 0.408);

void main()
{

    lmtexcoord.xy = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
    color = gl_Color;
    viewVector = (gl_ModelViewMatrix * gl_Vertex).xyz;

    vec3 normal = gl_Normal;

    torch = (pow(gl_MultiTexCoord1.x * recip, 3.0) * 0.2) * torchColor;

    NdotL = clamp(dot(normal, sunVec) * lightSign0, 0.0, 1.0);

    lmtexcoord.z = (gl_MultiTexCoord1.y * (15.0 * recip) + 0.5) * texelSize.y;
    gl_Position = ftransform();
}
