#version 450
// meteors
struct PerFrameUniforms
{
    mat4 gViewMat4;
    mat4 gViewProjectionMat4;
    mat4 gCameraMat4;
    mat4 gCameraNoHeadTrackingMat4;
    mat4 gPrevViewProjectionMat4;
    mat4 gThisToPrevViewProjectionMat4;
    mat4 gInverseViewMat4;
    mat4 gInverseProjectionMat4;
    mat4 gInverseProjectionSCMat4;
    mat4 gInverseViewProjectionMat4;
    vec4 gInverseWorldUpMatVec4[3];
    vec3 gViewPositionVec3;
    float gfTime;
    vec3 gVREyeInfoVec3;
    float gfPrevTime;
    vec4 gClipPlanesVec4;
    vec4 gMBlurSettingsVec4;
    vec3 gDeJitterVec3;
    int giFrameIndex;
    vec4 gTaaSettingsVec4;
    vec4 gTessSettingsVec4;
    vec4 gShellsSettingsVec4;
    vec4 gFrameBufferSizeVec4;
    vec4 gFoVValuesVec4;
    vec4 gShadowSizeVec4;
    vec3 gShadowProjScaleVec3;
    int giDisableAmbientAllowed;
    vec4 gShadowFadeParamVec4;
};

struct CommonPerMeshUniforms
{
    vec4 gPlanetPositionVec4;
    mat4 gWorldMat4;
    mat4 gWorldNormalMat4;
    float fdFadeValueDummy;
    vec4 gaParticleCornersVec4[4];
    vec4 gaParticlePositionsVec4[32];
    vec4 gaParticleSizeAndRotationsVec4[32];
    vec4 gaParticleNormalsVec4[32];
    vec4 gaParticleColoursVec4[32];
    vec4 gLightPositionVec4;
    vec4 gLightDirectionVec4;
    vec4 gLightOriginVec4;
    vec4 gLightColourVec4;
    vec4 gLightCustomParamsVec4;
    mat4 gWorldMotionMat4;
    mat4 gInverseModelMat4Dummy;
};

struct CustomPerMaterialUniforms
{
    vec4 gImposterDataVec4;
    vec4 gTileBlendScalesVec4;
    vec4 gHueOverlayParamsVec4;
    vec4 gSaturationOverlayParamsVec4;
    vec4 gValueOverlayParamsVec4;
    vec4 gTerrainColour1Vec4;
    vec4 gTerrainColour2Vec4;
    vec4 gMaterialParamsVec4;
    vec4 gMaterialColourVec4;
    vec4 gMaterialSFXVec4;
    vec4 gMaterialSFXColVec4;
    vec4 gSunPositionVec4;
};

struct CustomPerMeshUniforms
{
    vec4 gUVScrollStepVec4;
    vec4 gCustomParams01Vec4;
    vec4 gHeavyAirFadeOutVec4;
    vec4 gMultiTextureVec4;
};

struct UniformBuffer
{
    PerFrameUniforms mpPerFrame;
    CommonPerMeshUniforms mpCommonPerMesh;
    CustomPerMaterialUniforms mpCustomPerMaterial;
    CustomPerMeshUniforms mpCustomPerMesh;
};


// Vk3DVision (http://3dsurroundgaming.com/) - Stereo Injection
layout(set = 0, binding = 45, std140) uniform Vk3DParams
{
    vec4 stereo;
    vec4 custom_params;
} vk3d_params;

layout(set = 0, binding = 0, std140) uniform lUniforms_BLK
{
    UniformBuffer lUniforms;
} _228;

layout(location = 4) in float mkfParticleId;
layout(location = 2) in float mkfParticleCornerId;
layout(location = 1) in vec2 mkTexCoordsVec4;
layout(location = 0) out VertexBlock
{
    vec4 mColourVec4;
    vec4 mTexCoordsVec4;
    vec4 mScreenSpacePositionVec4;
} Out;

layout(location = 0) in vec3 mkLocalPositionVec3;

vec3 _1343;

void main()
{
    int _290 = int(mkfParticleId);
    vec4 _1307 = mkTexCoordsVec4.xyxy;
    _1307.x = (mkTexCoordsVec4.x / _228.lUniforms.mpCustomPerMesh.gMultiTextureVec4.x) + (mod(mkfParticleId, _228.lUniforms.mpCustomPerMesh.gMultiTextureVec4.x) / _228.lUniforms.mpCustomPerMesh.gMultiTextureVec4.x);
    Out.mTexCoordsVec4 = _1307;
    float _908 = _228.lUniforms.mpCommonPerMesh.gaParticleSizeAndRotationsVec4[_290].y * 0.01745329238474369049072265625;
    float _910 = sin(_908);
    float _912 = cos(_908);
    mat4 _1338;
    if (_228.lUniforms.mpPerFrame.gFoVValuesVec4.z == 2.0)
    {
        vec3 _933 = _228.lUniforms.mpCommonPerMesh.gaParticlePositionsVec4[_290].xyz - _228.lUniforms.mpPerFrame.gCameraNoHeadTrackingMat4[3].xyz;
        vec3 _945 = normalize(_933 - (_228.lUniforms.mpPerFrame.gCameraNoHeadTrackingMat4[1].xyz * dot(_228.lUniforms.mpPerFrame.gCameraNoHeadTrackingMat4[1].xyz, _933)));
        float _950 = dot(_945, _228.lUniforms.mpPerFrame.gCameraNoHeadTrackingMat4[2].xyz);
        float _960 = cos(asin(_950)) * sign(dot(_945, _228.lUniforms.mpPerFrame.gCameraNoHeadTrackingMat4[0].xyz));
        _1338 = _228.lUniforms.mpPerFrame.gCameraNoHeadTrackingMat4 * mat4(vec4(_950, 0.0, -_960, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(_960, 0.0, _950, 0.0), vec4(0.0, 0.0, 0.0, 1.0));
    }
    else
    {
        _1338 = _228.lUniforms.mpPerFrame.gCameraNoHeadTrackingMat4;
    }
    mat4 _1316 = _1338;
    _1316[3] = vec4(0.0, 0.0, 0.0, 1.0);
    mat4 _1318 = _1316;
    _1318[0].w = 0.0;
    mat4 _1320 = _1318;
    _1320[1].w = 0.0;
    mat4 _1322 = _1320;
    _1322[2].w = 0.0;
    Out.mColourVec4 = _228.lUniforms.mpCommonPerMesh.gaParticleColoursVec4[_290];
    float _1048 = (Out.mColourVec4.x < 0.0) ? (-1.0) : 1.0;
    float _1051 = Out.mColourVec4.x * _1048;
    float _1339;
    if (_1051 > 1.0)
    {
        _1339 = pow(_1051, 2.400000095367431640625);
    }
    else
    {
        float _1340;
        if (_1051 > 0.0)
        {
            _1340 = pow(_1051, 2.2000000476837158203125);
        }
        else
        {
            _1340 = _1051;
        }
        _1339 = _1340;
    }
    vec3 _1325 = _1343;
    _1325.x = _1339 * _1048;
    float _1074 = (Out.mColourVec4.y < 0.0) ? (-1.0) : 1.0;
    float _1077 = Out.mColourVec4.y * _1074;
    float _1345;
    if (_1077 > 1.0)
    {
        _1345 = pow(_1077, 2.400000095367431640625);
    }
    else
    {
        float _1346;
        if (_1077 > 0.0)
        {
            _1346 = pow(_1077, 2.2000000476837158203125);
        }
        else
        {
            _1346 = _1077;
        }
        _1345 = _1346;
    }
    vec3 _1328 = _1325;
    _1328.y = _1345 * _1074;
    float _1100 = (Out.mColourVec4.z < 0.0) ? (-1.0) : 1.0;
    float _1103 = Out.mColourVec4.z * _1100;
    float _1349;
    if (_1103 > 1.0)
    {
        _1349 = pow(_1103, 2.400000095367431640625);
    }
    else
    {
        float _1350;
        if (_1103 > 0.0)
        {
            _1350 = pow(_1103, 2.2000000476837158203125);
        }
        else
        {
            _1350 = _1103;
        }
        _1349 = _1350;
    }
    vec3 _1331 = _1328;
    _1331.z = _1349 * _1100;
    Out.mColourVec4 = vec4(_1331.x, _1331.y, _1331.z, Out.mColourVec4.w);
    Out.mColourVec4.w = Out.mColourVec4.w;
    Out.mColourVec4.w = min(Out.mColourVec4.w, 1.0);
    vec4 _1334 = vec4((_1322 * (mat4(vec4(_912, -_910, 0.0, 0.0), vec4(_910, _912, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)) * vec4(_228.lUniforms.mpCommonPerMesh.gaParticleCornersVec4[int(mkfParticleCornerId)].xyz * (_228.lUniforms.mpCommonPerMesh.gaParticleSizeAndRotationsVec4[_290].x * sqrt(dot(_228.lUniforms.mpCommonPerMesh.gWorldMat4[0].xyz, _228.lUniforms.mpCommonPerMesh.gWorldMat4[0].xyz))), 1.0))).xyz + _228.lUniforms.mpCommonPerMesh.gaParticlePositionsVec4[_290].xyz, 1.0);
    _1334.w = 1.0;
    vec4 _801 = _228.lUniforms.mpPerFrame.gViewProjectionMat4 * _1334;
    
    _801.x += vk3d_params.stereo.x * (_801.w - vk3d_params.stereo.y); 
    
    vec2 _811 = _801.xy - (_228.lUniforms.mpPerFrame.gDeJitterVec3.xy * _801.w);
    vec4 _813 = vec4(_811.x, _811.y, _801.z, _801.w);
    Out.mScreenSpacePositionVec4 = _813;
    gl_Position = _813;

// Vk3DVision (http://3dsurroundgaming.com/) - Stereo Injection
//gl_Position.x += vk3d_params.stereo.x * (gl_Position.w - vk3d_params.stereo.y); 
}


