#version 450
 
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 gLightPositionVec4;
    vec4 gLightDirectionVec4;
    vec4 gLightOriginVec4;
    vec4 gScanParamsPosVec4;
    vec4 gScanParamsCfg1Vec4;
    vec4 gScanParamsCfg2Vec4;
    vec4 gScanParamsCfg3Vec4;
    vec4 gScanColourVec4;
    mat4 gaShadowMat4[3];
    vec4 gLightColourVec4;
    vec4 gLightCustomParamsVec4;
    mat4 gWorldMotionMat4;
    mat4 gInverseModelMat4Dummy;
};

struct CustomPerMeshUniforms
{
    vec4 gDoFParamsVec4;
};

struct CustomPerMaterialUniforms
{
    vec4 gSpaceCloudColourVec4;
    vec4 gSpaceNebulaColour3Vec4;
    vec4 gSpaceNebulaParamsVec4;
    vec4 gSpaceSkyColour1Vec4;
};

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


// 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;
} _86;

layout(location = 1) in vec3 mkCustom1Vec4;
layout(location = 0) in vec2 mkfParticleCornerId;
layout(location = 7) in vec4 mkCustom2Vec4;
layout(location = 8) in vec4 mkCustom3Vec4;
layout(location = 0) out VertexBlock
{
    vec2 mUV;
    vec4 mDepth_Field_Seed2;
    vec4 mColour;
    vec4 mBlends;
    vec4 mWorldPositionVec4;
} Out;


vec4 _397;

void main()
{
    float _395;
    if (_86.lUniforms.mpPerFrame.gFoVValuesVec4.z == 2.0)
    {
        _395 = mkCustom1Vec4.x * 2.0;
    }
    else
    {
        _395 = mkCustom1Vec4.x;
    }
    vec2 _125 = mkfParticleCornerId - vec2(0.5);
    vec4 _151 = _86.lUniforms.mpCommonPerMesh.gWorldMat4 * vec4(mkCustom2Vec4.xyz, 1.0);
    vec3 _171 = (_151.xyz + (_86.lUniforms.mpPerFrame.gCameraMat4[0].xyz * (_125.x * _395))).xyz + (_86.lUniforms.mpPerFrame.gCameraMat4[1].xyz * (_125.y * _395));
    float _373 = clamp((length(_171.xyz - _86.lUniforms.mpPerFrame.gCameraMat4[3].xyz) - _86.lUniforms.mpCommonPerMesh.gLightColourVec4.x) * _86.lUniforms.mpCommonPerMesh.gLightColourVec4.y, 0.0, 1.0);
    gl_Position = _86.lUniforms.mpPerFrame.gViewProjectionMat4 * vec4(_171.x, _171.y, _171.z, _151.w);

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

    float _214 = 1.0 - _373;
    float _218 = smoothstep(0.87999999523162841796875, 1.0, _214);
    vec4 _381 = _397;
    _381.x = _218;
    vec4 _383 = _381;
    _383.y = smoothstep(0.959999978542327880859375, 1.0, _214);
    vec4 _385 = _383;
    _385.z = smoothstep(0.100000001490116119384765625, 1.0, _214);
    vec4 _387 = _385;
    _387.w = sin(clamp((_373 - 0.20000000298023223876953125) * 1.60000002384185791015625, 0.0, 1.0) * 1.5707962512969970703125);
    vec3 _257 = mix(mkCustom3Vec4.xyz, vec3(0.87300002574920654296875, 0.91900002956390380859375, 1.0), vec3((1.0 - _218) * (1.0 - mkCustom3Vec4.w)));
    Out.mUV = mkfParticleCornerId;
    Out.mDepth_Field_Seed2 = vec4(_373, 0.0, fract(sin(vec3(dot(mkCustom2Vec4.xz, vec2(127.09999847412109375, 311.70001220703125)), dot(mkCustom2Vec4.xz, vec2(269.5, 183.3000030517578125)), dot(mkCustom2Vec4.xz, vec2(419.20001220703125, 371.899993896484375)))) * 43758.546875).xy);
    Out.mColour = vec4(_257.x, _257.y, _257.z, mkCustom3Vec4.w);
    Out.mBlends = _387;
    Out.mWorldPositionVec4 = vec4(normalize(mkCustom2Vec4.xyz), 1.0);
}


