#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 gfFadeValue;
    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 CustomPerMaterialUniforms
{
    vec4 gImposterDataVec4;
    vec4 gTileBlendScalesVec4;
    vec4 gHueOverlayParamsVec4;
    vec4 gSaturationOverlayParamsVec4;
    vec4 gValueOverlayParamsVec4;
    vec4 gTerrainColour1Vec4;
    vec4 gTerrainColour2Vec4;
    vec4 gWaveOneAmplitudeAndPosOffsetV4;
    vec4 gWaveOneFrequencyVec4;
    vec4 gWaveOneFallOffAndSpeedVec4;
    vec4 gWaveTwoAmplitudeVec4;
    vec4 gWaveTwoFrequencyVec4;
    vec4 gWaveTwoFallOffAndSpeedVec4;
    vec4 gMaterialParamsVec4;
    vec4 gMaterialColourVec4;
    vec4 gMaterialSFXVec4;
    vec4 gMaterialSFXColVec4;
    vec4 gSunPositionVec4;
    vec4 gAverageColour1Vec4;
    vec4 gAverageColour2Vec4;
    vec4 gRecolour1Vec4;
    vec4 gRecolour2Vec4;
    vec4 gSkyColourVec4;
    vec4 gHorizonColourVec4;
    vec4 gSunColourVec4;
    vec4 gWaterFogColourNearVec4;
    vec4 gWaterFogColourFarVec4;
    vec4 gWaterFogVec4;
    vec4 gHeightFogParamsVec4;
    vec4 gHeightFogColourVec4;
    vec4 gSpaceHorizonColourVec4;
    vec4 gFogColourVec4;
    vec4 gFogParamsVec4;
    vec4 gScatteringParamsVec4;
    vec4 gFogFadeHeightsVec4;
    vec4 gSpaceScatteringParamsVec4;
    vec4 gSkyUpperColourVec4;
    vec4 gLightTopColourVec4;
};

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

layout(location = 0) in vec4 mkLocalPositionVec4;
layout(location = 7) in vec4 mkLocalNormalVec4;
layout(location = 3) in vec4 mkTangentVec4;
layout(location = 0) out VertexBlock
{
    vec4 mTexCoordsVec4;
    vec4 mWorldPositionVec3_mfSpare;
    vec4 mColourVec4;
    vec4 mMaterialVec4;
    flat mat3 mUpMatrixMat3;
    vec3 mTangentMatRow1Vec3;
    vec3 mTangentMatRow2Vec3;
    vec3 mTangentMatRow3Vec3;
    vec4 mPrevScreenPosition;
    vec4 mScreenSpacePositionVec4;
    flat vec3 mfFadeValueForInstance_mfLodIndex_mfShearMotionLength;
} Out;

layout(location = 8) in vec4 mkColourVec4;
layout(location = 1) in vec4 mkTexCoordsVec4;

mat3 _2925;

void main()
{
    vec3 _798 = normalize(mkTangentVec4.xyz);
    Out.mfFadeValueForInstance_mfLodIndex_mfShearMotionLength.y = 0.0;
    Out.mfFadeValueForInstance_mfLodIndex_mfShearMotionLength.x = _813.lUniforms.mpCommonPerMesh.gfFadeValue;
    vec3 _851 = _813.lUniforms.mpCommonPerMesh.gWorldMat4[3].xyz - _813.lUniforms.mpCommonPerMesh.gPlanetPositionVec4.xyz;
    float _864 = _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.w * ((_851.x + _851.y) + _851.z);
    float _865 = _813.lUniforms.mpPerFrame.gfTime + _864;
    float _1495 = _865 * _813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.w;
    float _1639 = dot(_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.xyz, mkLocalPositionVec4.xyz);
    vec3 _1649 = vec3(sin(_1639 + _1495)) * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.xyz;
    bool _1514 = dot(_813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.xyz, _813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.xyz) > 0.0;
    float _2907;
    vec3 _2919;
    if (_1514)
    {
        float _2893;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.x > 0.0)
        {
            _2893 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.x;
        }
        else
        {
            _2893 = 0.0;
        }
        float _2894;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.y > 0.0)
        {
            _2894 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.y;
        }
        else
        {
            _2894 = 0.0;
        }
        float _2895;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.z > 0.0)
        {
            _2895 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.z;
        }
        else
        {
            _2895 = 0.0;
        }
        vec3 _1547 = vec3(_2893, _2894, _2895);
        _2919 = _1547;
        _2907 = dot(_1547, mkLocalPositionVec4.xyz);
    }
    else
    {
        _2919 = vec3(0.0);
        _2907 = 1.0;
    }
    float _1558 = _865 * _813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.w;
    float _1655 = dot(_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.xyz, mkLocalPositionVec4.xyz);
    vec3 _1665 = vec3(sin(_1655 + _1558)) * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.xyz;
    bool _1577 = dot(_813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.xyz, _813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.xyz) > 0.0;
    float _2911;
    vec3 _2913;
    if (_1577)
    {
        float _2900;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.x > 0.0)
        {
            _2900 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.x;
        }
        else
        {
            _2900 = 0.0;
        }
        float _2901;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.y > 0.0)
        {
            _2901 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.y;
        }
        else
        {
            _2901 = 0.0;
        }
        float _2902;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.z > 0.0)
        {
            _2902 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.z;
        }
        else
        {
            _2902 = 0.0;
        }
        vec3 _1610 = vec3(_2900, _2901, _2902);
        _2913 = _1610;
        _2911 = dot(_1610, mkLocalPositionVec4.xyz);
    }
    else
    {
        _2913 = vec3(0.0);
        _2911 = 1.0;
    }
    vec3 _1631 = mkLocalPositionVec4.xyz + ((_1649 * _2907) + (_1665 * _2911));
    mat3 _2970;
    if (_2907 != 1.0)
    {
        float _1677 = cos(dot(_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.xyz, _1631.xyz) + _1495) * _2907;
        float _1688 = _1649.x;
        float _1689 = _2919.x * _1688;
        mat3 _2673 = _2925;
        _2673[0].x = ((_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.x) * _1677) + _1689;
        float _1702 = _1649.y;
        mat3 _2679 = _2673;
        _2679[0].y = ((_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.y) * _1677) + (_2919.x * _1702);
        mat3 _2685 = _2679;
        _2685[0].z = ((_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.z) * _1677) + _1689;
        mat3 _2691 = _2685;
        _2691[1].x = ((_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.x) * _1677) + (_2919.y * _1688);
        mat3 _2697 = _2691;
        _2697[1].y = ((_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.y) * _1677) + (_2919.y * _1702);
        float _1758 = _1649.z;
        mat3 _2703 = _2697;
        _2703[1].z = ((_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.z) * _1677) + (_2919.y * _1758);
        mat3 _2709 = _2703;
        _2709[2].x = ((_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.x) * _1677) + (_2919.z * _1688);
        mat3 _2715 = _2709;
        _2715[2].y = ((_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.y) * _1677) + (_2919.z * _1702);
        mat3 _2721 = _2715;
        _2721[2].z = ((_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.z) * _1677) + (_2919.z * _1758);
        _2970 = _2721;
    }
    else
    {
        float _1813 = cos(dot(_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.xyz, _1631.xyz) + _1495);
        mat3 _2726 = _2925;
        _2726[0].x = (_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.x) * _1813;
        mat3 _2730 = _2726;
        _2730[0].y = (_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.y) * _1813;
        mat3 _2734 = _2730;
        _2734[0].z = (_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.z) * _1813;
        mat3 _2738 = _2734;
        _2738[1].x = (_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.x) * _1813;
        mat3 _2742 = _2738;
        _2742[1].y = (_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.y) * _1813;
        mat3 _2746 = _2742;
        _2746[1].z = (_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.z) * _1813;
        mat3 _2750 = _2746;
        _2750[2].x = (_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.x) * _1813;
        mat3 _2754 = _2750;
        _2754[2].y = (_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.y) * _1813;
        mat3 _2758 = _2754;
        _2758[2].z = (_813.lUniforms.mpCustomPerMaterial.gWaveOneFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.z) * _1813;
        _2970 = _2758;
    }
    mat3 _2971;
    if (_2911 != 1.0)
    {
        float _1898 = cos(dot(_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.xyz, _1631.xyz) + _1558) * _2911;
        float _1909 = _1665.x;
        float _1910 = _2913.x * _1909;
        mat3 _2765 = _2925;
        _2765[0].x = ((_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.x) * _1898) + _1910;
        float _1923 = _1665.y;
        mat3 _2771 = _2765;
        _2771[0].y = ((_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.y) * _1898) + (_2913.x * _1923);
        mat3 _2777 = _2771;
        _2777[0].z = ((_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.z) * _1898) + _1910;
        mat3 _2783 = _2777;
        _2783[1].x = ((_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.x) * _1898) + (_2913.y * _1909);
        mat3 _2789 = _2783;
        _2789[1].y = ((_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.y) * _1898) + (_2913.y * _1923);
        float _1979 = _1665.z;
        mat3 _2795 = _2789;
        _2795[1].z = ((_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.z) * _1898) + (_2913.y * _1979);
        mat3 _2801 = _2795;
        _2801[2].x = ((_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.x) * _1898) + (_2913.z * _1909);
        mat3 _2807 = _2801;
        _2807[2].y = ((_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.y) * _1898) + (_2913.z * _1923);
        mat3 _2813 = _2807;
        _2813[2].z = ((_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.z) * _1898) + (_2913.z * _1979);
        _2971 = _2813;
    }
    else
    {
        float _2034 = cos(dot(_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.xyz, _1631.xyz) + _1558);
        mat3 _2818 = _2925;
        _2818[0].x = (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.x) * _2034;
        mat3 _2822 = _2818;
        _2822[0].y = (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.y) * _2034;
        mat3 _2826 = _2822;
        _2826[0].z = (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.x * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.z) * _2034;
        mat3 _2830 = _2826;
        _2830[1].x = (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.x) * _2034;
        mat3 _2834 = _2830;
        _2834[1].y = (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.y) * _2034;
        mat3 _2838 = _2834;
        _2838[1].z = (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.y * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.z) * _2034;
        mat3 _2842 = _2838;
        _2842[2].x = (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.x) * _2034;
        mat3 _2846 = _2842;
        _2846[2].y = (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.y) * _2034;
        mat3 _2850 = _2846;
        _2850[2].z = (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFrequencyVec4.z * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.z) * _2034;
        _2971 = _2850;
    }
    vec3 _1450 = normalize(_798);
    vec3 _1462 = _2970[0] + _2971[0];
    vec3 _1465 = _2970[1] + _2971[1];
    vec3 _1468 = _2970[2] + _2971[2];
    mat3 _2853 = mat3(_1462, _1465, _1468);
    _2853[0].x = _1462.x + 1.0;
    mat3 _2856 = _2853;
    _2856[1].y = _1465.y + 1.0;
    mat3 _2859 = _2856;
    _2859[2].z = _1468.z + 1.0;
    float _1002 = _813.lUniforms.mpPerFrame.gfPrevTime + _864;
    float _2997;
    if (_1514)
    {
        float _2983;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.x > 0.0)
        {
            _2983 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.x;
        }
        else
        {
            _2983 = 0.0;
        }
        float _2984;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.y > 0.0)
        {
            _2984 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.y;
        }
        else
        {
            _2984 = 0.0;
        }
        float _2985;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.z > 0.0)
        {
            _2985 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.z;
        }
        else
        {
            _2985 = 0.0;
        }
        _2997 = dot(vec3(_2983, _2984, _2985), mkLocalPositionVec4.xyz);
    }
    else
    {
        _2997 = 1.0;
    }
    float _3001;
    if (_1577)
    {
        float _2990;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.x > 0.0)
        {
            _2990 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.x;
        }
        else
        {
            _2990 = 0.0;
        }
        float _2991;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.y > 0.0)
        {
            _2991 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.y;
        }
        else
        {
            _2991 = 0.0;
        }
        float _2992;
        if (_813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.z > 0.0)
        {
            _2992 = 1.0 / _813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.z;
        }
        else
        {
            _2992 = 0.0;
        }
        _3001 = dot(vec3(_2990, _2991, _2992), mkLocalPositionVec4.xyz);
    }
    else
    {
        _3001 = 1.0;
    }
    vec3 _2289 = mkLocalPositionVec4.xyz + (((vec3(sin(_1639 + (_1002 * _813.lUniforms.mpCustomPerMaterial.gWaveOneFallOffAndSpeedVec4.w))) * _813.lUniforms.mpCustomPerMaterial.gWaveOneAmplitudeAndPosOffsetV4.xyz) * _2997) + ((vec3(sin(_1655 + (_1002 * _813.lUniforms.mpCustomPerMaterial.gWaveTwoFallOffAndSpeedVec4.w))) * _813.lUniforms.mpCustomPerMaterial.gWaveTwoAmplitudeVec4.xyz) * _3001));
    Out.mWorldPositionVec3_mfSpare = vec4(0.0);
    vec4 _2327 = _813.lUniforms.mpCommonPerMesh.gWorldMat4 * vec4(_1631.x, _1631.y, _1631.z, mkLocalPositionVec4.w);
    vec3 _1110 = normalize((_813.lUniforms.mpCommonPerMesh.gWorldNormalMat4 * vec4(normalize(-cross(_2859 * normalize(cross(normalize(mkLocalNormalVec4.xyz), _1450)), _2859 * _1450)), 1.0)).xyz);
    Out.mWorldPositionVec3_mfSpare = vec4(_2327.x, _2327.y, _2327.z, Out.mWorldPositionVec3_mfSpare.w);
    Out.mWorldPositionVec3_mfSpare = vec4(_2327.x, _2327.y, _2327.z, Out.mWorldPositionVec3_mfSpare.w);
    vec3 _2349 = (_813.lUniforms.mpCommonPerMesh.gWorldNormalMat4 * vec4(_798, 1.0)).xyz;
    Out.mTangentMatRow1Vec3 = normalize(_2349);
    Out.mTangentMatRow2Vec3 = normalize(cross(_1110, _2349) * ((mkTangentVec4.w > 0.00999999977648258209228515625) ? 1.0 : (-1.0)));
    Out.mTangentMatRow3Vec3 = normalize(_1110);
    mat3 _2878 = _2925;
    _2878[0] = _813.lUniforms.mpPerFrame.gInverseWorldUpMatVec4[0].xyz;
    mat3 _2880 = _2878;
    _2880[1] = _813.lUniforms.mpPerFrame.gInverseWorldUpMatVec4[1].xyz;
    mat3 _2882 = _2880;
    _2882[2] = _813.lUniforms.mpPerFrame.gInverseWorldUpMatVec4[2].xyz;
    Out.mUpMatrixMat3 = _2882;
    Out.mColourVec4 = mkColourVec4;
    float _2373 = (_813.lUniforms.mpCustomPerMaterial.gMaterialColourVec4.x < 0.0) ? (-1.0) : 1.0;
    float _2376 = _813.lUniforms.mpCustomPerMaterial.gMaterialColourVec4.x * _2373;
    float _3037;
    if (_2376 > 1.0)
    {
        _3037 = pow(_2376, 2.400000095367431640625);
    }
    else
    {
        float _3038;
        if (_2376 > 0.0)
        {
            _3038 = pow(_2376, 2.2000000476837158203125);
        }
        else
        {
            _3038 = _2376;
        }
        _3037 = _3038;
    }
    float _2399 = (_813.lUniforms.mpCustomPerMaterial.gMaterialColourVec4.y < 0.0) ? (-1.0) : 1.0;
    float _2402 = _813.lUniforms.mpCustomPerMaterial.gMaterialColourVec4.y * _2399;
    float _3060;
    if (_2402 > 1.0)
    {
        _3060 = pow(_2402, 2.400000095367431640625);
    }
    else
    {
        float _3061;
        if (_2402 > 0.0)
        {
            _3061 = pow(_2402, 2.2000000476837158203125);
        }
        else
        {
            _3061 = _2402;
        }
        _3060 = _3061;
    }
    float _2425 = (_813.lUniforms.mpCustomPerMaterial.gMaterialColourVec4.z < 0.0) ? (-1.0) : 1.0;
    float _2428 = _813.lUniforms.mpCustomPerMaterial.gMaterialColourVec4.z * _2425;
    float _3064;
    if (_2428 > 1.0)
    {
        _3064 = pow(_2428, 2.400000095367431640625);
    }
    else
    {
        float _3065;
        if (_2428 > 0.0)
        {
            _3065 = pow(_2428, 2.2000000476837158203125);
        }
        else
        {
            _3065 = _2428;
        }
        _3064 = _3065;
    }
    Out.mMaterialVec4 = vec4(_3037 * _2373, _3060 * _2399, _3064 * _2425, _813.lUniforms.mpCustomPerMaterial.gMaterialColourVec4.w);
    Out.mTexCoordsVec4 = vec4(mkTexCoordsVec4.x, mkTexCoordsVec4.y, mkTexCoordsVec4.x, mkTexCoordsVec4.y) + (_813.lUniforms.mpCustomPerMesh.gUVScrollStepVec4 * _813.lUniforms.mpPerFrame.gfTime);
    vec4 _2449 = _813.lUniforms.mpPerFrame.gViewProjectionMat4 * _2327;
    
    _2449.x += vk3d_params.stereo.x * (_2449.w - vk3d_params.stereo.y); 
    
    Out.mScreenSpacePositionVec4 = _2449;
    Out.mPrevScreenPosition = _813.lUniforms.mpPerFrame.gPrevViewProjectionMat4 * (_813.lUniforms.mpCommonPerMesh.gWorldMotionMat4 * vec4(_2289.x, _2289.y, _2289.z, mkLocalPositionVec4.w));
    Out.mfFadeValueForInstance_mfLodIndex_mfShearMotionLength.z = 0.0;
    gl_Position = _2449;

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


