@ctype mat4 HMM_Mat4
@ctype vec3 HMM_Vec3

@vs vs
layout(binding=0) uniform vs_params {
    mat4 mvp;
    vec3 cam_pos;
};

in vec4 position;
in vec3 norm;
in vec2 tex_uv;
in vec2 lightmap_uv;

out vec3 fs_norm;
out vec2 fs_tex_uv;
out vec2 fs_lightmap_uv;
out float depth;

void main() {
    // for now m == identity
    vec4 view_pos = mvp * position;
    depth = -view_pos.z;

    gl_Position = view_pos;
    fs_norm = norm;
    fs_tex_uv = tex_uv;
    fs_lightmap_uv = lightmap_uv;
}
@end

@fs fs
layout(binding=0) uniform texture2D tex;
layout(binding=0) uniform sampler smp;
layout(binding=1) uniform texture2D lightmap;
layout(binding=1) uniform sampler lightmap_smp;
in vec3 fs_norm;
in vec2 fs_tex_uv;
in vec2 fs_lightmap_uv;
in float depth;

out vec4 frag_color;

void main() {
    vec4 tex_color = texture(sampler2D(tex, smp), fs_tex_uv);
    vec4 lightmap_color = texture(sampler2D(lightmap, lightmap_smp), fs_lightmap_uv);
    frag_color = tex_color * lightmap_color;
}
@end

@program obj vs fs
