#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct type_TransformBuffer
{
    float4x4 world_to_projection;
    float4x4 projection_to_world;
    float4x4 world_to_view;
    float4x4 view_to_projection;
    packed_float3 camera_pos_world;
    float viewport_min_z;
    packed_float3 camera_dir_world;
    float viewport_max_z;
    float2 viewport_size;
    float2 viewport_offset;
    float2 render_size;
    float time;
};

struct main0_out
{
    float2 out_var_TEXCOORD0 [[user(locn0)]];
    float4 out_var_COLOR0 [[user(locn1)]];
    float3 out_var_NORMAL [[user(locn2)]];
    float3 out_var_COLOR1 [[user(locn3)]];
    float4 gl_Position [[position]];
};

struct main0_in
{
    float3 in_var_pos [[attribute(0)]];
    float2 in_var_uv [[attribute(1)]];
    float4 in_var_color [[attribute(2)]];
    float3 in_var_norm [[attribute(3)]];
};

vertex main0_out main0(main0_in in [[stage_in]], constant type_TransformBuffer& TransformBuffer [[buffer(0)]])
{
    main0_out out = {};
    out.gl_Position = TransformBuffer.world_to_projection * float4(in.in_var_pos, 1.0);
    out.out_var_TEXCOORD0 = in.in_var_uv;
    out.out_var_COLOR0 = in.in_var_color;
    out.out_var_NORMAL = in.in_var_norm;
    out.out_var_COLOR1 = float3(0.20000000298023223876953125) + (float3(1.0) * precise::max(dot(in.in_var_norm, fast::normalize(-fast::normalize(float3(1.0)))), 0.0));
    return out;
}

