#pragma clang diagnostic ignored "-Wmissing-prototypes"

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

using namespace metal;

// Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
template<typename Tx, typename Ty>
inline Tx mod(Tx x, Ty y)
{
    return x - y * floor(x / y);
}

struct Globals
{
    float4x4 uVP;
    packed_float3 uCam;
    float uTime;
    float uRain;
};

struct main0_out
{
    float vV [[user(locn0)]];
    float4 gl_Position [[position]];
};

struct main0_in
{
    float4 aData [[attribute(0)]];
};

vertex main0_out main0(main0_in in [[stage_in]], constant Globals& _32 [[buffer(0)]])
{
    main0_out out = {};
    out.vV = in.aData.w;
    float H = 26.0;
    float speed = 22.0;
    float streak = 1.39999997615814208984375;
    float fall = mod(in.aData.y - (_32.uTime * speed), H);
    float y = (_32.uCam[1u] + ((H * 0.5) - fall)) + (in.aData.w * streak);
    float3 w = float3(floor(_32.uCam[0u]) + in.aData.x, y, floor(_32.uCam[2u]) + in.aData.z);
    out.gl_Position = _32.uVP * float4(w, 1.0);
    out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5;
    return out;
}

