#version 450

invariant gl_Position;

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 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 gCustomParams02Vec4;
    vec4 gObjectColourVec4;
};

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;
} _229;

layout(location = 0) in vec4 mkLocalPositionVec4;
layout(location = 7) in vec4 mkLocalNormalVec4;
layout(location = 3) in vec4 mkTangentVec4;
layout(location = 9) in vec4 mkTransformMat4R0;
layout(location = 10) in vec4 mkTransformMat4R1;
layout(location = 11) in vec4 mkTransformMat4R2;
layout(location = 12) in vec4 mkTransformMat4R3;
layout(location = 0) out VertexBlock
{
    vec4 mTexCoordsVec4;
    vec4 mWorldPositionVec3_mfSpare;
    vec4 mColourVec4;
    vec4 mPrevScreenPosition;
    vec4 mScreenSpacePositionVec4;
    flat vec3 mfFadeValueForInstance_mfLodIndex_mfShearMotionLength;
} Out;

layout(location = 14) in vec4 mkTransformMat4R5;
layout(location = 13) in vec4 mkTransformMat4R4;
layout(location = 8) in vec4 mkColourVec4;
layout(location = 1) in vec4 mkTexCoordsVec4;

mat4 _492;

void main()
{
    mat4 _471 = _492;
    _471[0] = mkTransformMat4R0;
    mat4 _473 = _471;
    _473[1] = mkTransformMat4R1;
    mat4 _475 = _473;
    _475[2] = mkTransformMat4R2;
    mat4 _477 = _475;
    _477[3] = mkTransformMat4R3;
    Out.mfFadeValueForInstance_mfLodIndex_mfShearMotionLength.x = mkTransformMat4R0.w;
    mat4 _480 = _477;
    _480[0].w = 0.0;
    mat4 _482 = _480;
    _482[1].w = 0.0;
    mat4 _484 = _482;
    _484[2].w = 0.0;
    mat4 _486 = _484;
    _486[3].w = 1.0;
    vec2 _193 = mkTransformMat4R5.xy - mkTransformMat4R5.zw;
    Out.mfFadeValueForInstance_mfLodIndex_mfShearMotionLength.y = mkTransformMat4R4.w;
    Out.mWorldPositionVec3_mfSpare = vec4(0.0);
    vec4 _404 = _486 * (_229.lUniforms.mpCommonPerMesh.gWorldMat4 * mkLocalPositionVec4);
    Out.mWorldPositionVec3_mfSpare = vec4(_404.x, _404.y, _404.z, Out.mWorldPositionVec3_mfSpare.w);
    Out.mWorldPositionVec3_mfSpare = vec4(_404.x, _404.y, _404.z, Out.mWorldPositionVec3_mfSpare.w);
    Out.mColourVec4 = mkColourVec4;
    Out.mTexCoordsVec4 = vec4(mkTexCoordsVec4.x, mkTexCoordsVec4.y, mkTexCoordsVec4.x, mkTexCoordsVec4.y) + (_229.lUniforms.mpCustomPerMesh.gUVScrollStepVec4 * _229.lUniforms.mpPerFrame.gfTime);
    vec4 _465 = _229.lUniforms.mpPerFrame.gViewProjectionMat4 * _404;

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

    Out.mScreenSpacePositionVec4 = _465;
    Out.mPrevScreenPosition = _229.lUniforms.mpPerFrame.gPrevViewProjectionMat4 * _404;
    Out.mfFadeValueForInstance_mfLodIndex_mfShearMotionLength.z = dot(_193, _193);
    vec4 _490 = _465;
    _490.z = _465.z + 9.9999999747524270787835121154785e-07;
    gl_Position = _490;

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


