
// Vk3DVision (http://3dsurroundgaming.com/) - Original Shader
#version 450
#extension GL_EXT_nonuniform_qualifier : require
#extension GL_ARB_shader_draw_parameters : require
#extension GL_ARB_shader_ballot : require

out float gl_ClipDistance[1];

invariant gl_Position;

struct S_MATRICES
{
    mat4 _mModelViewProj;
    mat4 _mModelViewProjPrevious;
    mat4 _mModelView;
    mat4 _mInvModelView;
};

struct unaligned_float3
{
    float x;
    float y;
    float z;
};

struct S_TBN
{
    int _iNormal;
    int _iTangent;
};

struct S_INDICES
{
    uint _uiObjectIndex;
    uint _uiMaterialIndex;
    uint _uiMaterialInstanceIndex;
    uint _uiLastFrameMaterialIndex;
    uint _uiLastFrameMaterialInstanceIndex;
    uint _uiPositionsBufferIndex;
    uint _uiPrevPositionsBufferIndex;
    uint _uiNormalsBufferIndex;
    uint _uiPositionOffset;
    uint _uiPrevPositionOffset;
    uint _uiNormalOffset;
    uint _uiMatricesIndex;
};

struct S_MAIN_DEFAULT
{
    S_INDICES _Indices;
};

struct S_MAIN_DEFAULT_ARRAY
{
    S_MAIN_DEFAULT _aMain[32];
};

struct S_SPEEDTREE_MESH_OBJECT
{
    mat4 _mModel;
    mat4 _mModelLast;
    mat4 _mInvModel;
    mat4 _mInvModelLast;
    vec4 _vDiversityOffset;
    uint _uiSceneZoneIndex;
    uint _uiNeighborSceneZoneIndex;
    uint _uiDisplayFlags;
    uint _uiPackedLocalExposureCompensation;
    vec4 _vPortalDirAndDistance;
    int _iPickingID[2];
    uint _uiPadding[2];
    vec4 _vTreeRotation;
    vec4 _vWindGlobal;
    vec4 _vWindVector;
    vec4 _vWindBranchAdherences;
    vec4 _vWindBranch;
    vec4 _vWindBranchTwitch;
    vec4 _vWindBranchWhipTurbulences;
    vec4 _vWindFrondRipple;
    vec4 _vWindLeaf1Ripple;
    vec4 _vWindLeaf1Tumble;
    vec4 _vWindLeaf1Twitch;
    vec4 _vWindLeaf2Ripple;
    vec4 _vWindLeaf2Tumble;
    vec4 _vWindLeaf2Twitch;
    vec4 _vAnchorAllTime;
    vec4 _vRollingBranch;
    vec4 _vRollingLeafOffset;
    vec4 _vRollingNoise;
    uint _uiLOD;
    uint _uiSmooth;
    float _fLocalExposureCompensation;
    float _fLocalExposureCompensationEV100;
    vec4 _vWindGlobalLast;
    vec4 _vWindBranchLast;
    vec4 _vWindFrondRippleLast;
    vec4 _vWindLeaf1RippleLast;
    vec4 _vWindLeaf1TumbleLast;
    vec4 _vWindLeaf1TwitchLast;
    vec4 _vWindLeaf2RippleLast;
    vec4 _vWindLeaf2TumbleLast;
    vec4 _vAnchorAllTimeLast;
};

struct S_PASS_MATRICES
{
    mat4 _mViewJitteredProj;
    mat4 _mViewProj;
    mat4 _mView;
    mat4 _mInvView;
    mat4 _mJitteredProj;
};

struct S_EYE_DATA
{
    S_PASS_MATRICES _mCurrentFrameMatrices[2];
    S_PASS_MATRICES _mPreviousFrameMatrices[2];
    mat4 _mJitteredProjection[2];
    mat4 _mNoJitterProjection[2];
    mat4 _mInvViewJitteredProj[2];
    vec4 _vWorldSpaceCameraVector[2];
    vec4 _vWorldSpaceCameraPosition[2];
    vec4 _vFrameBufferScale;
    vec4 _vFrameBufferViewportSize;
    vec4 _vFrameBufferOneOnViewportSize;
    vec4 _vViewportSize;
    vec4 _vFogSubCrop;
    uint _uiAlignment0;
    uint _uiAlignment1;
    float _vCameraJitterDeltaX;
    float _vCameraJitterDeltaY;
    vec4 _vfRcpFVolumetricFogDepthTileSize;
};

struct S_CASCADED_SHADOW
{
    mat4 _mCascadeMatrix[2][8];
    mat4 _mViewSpaceToStaticShadowMapSpace[2];
    vec4 _vfCascadeShadowAttenuation;
    vec4 _vfShadowCascadeTextureTexelSize;
    vec4 _vfStaticShadowBlurRadius;
    vec4 _vfCascadeLinearZProjFactors[8];
    vec4 _vfCascadeParams[8];
};

struct S_CLUSTER_LIGHT_SETUP
{
    S_CASCADED_SHADOW _CascadedShadow;
    vec4 _vfSkinUVParamsAndNormalBias;
    vec4 _vfShadowTextureTexelSize;
    vec4 _vfDummy_SkinFresnelF0AndF90;
    uint _uiCascadedUsed;
    float _fSSSWidth;
    float _fOffsetBias;
    float _fDummy;
};

struct S_CLUSTER_INFO
{
    mat4 _mViewToClusterView[2];
    mat4 _mClusterProjMatrix;
    mat4 _mClusterInvProjMatrix;
    vec4 _vfLeftEyeToCombinedEyeVsDeltaXZ;
    uint _uiFinestMipWidth;
    uint _uiFinestMipHeight;
    uint _uiFinestMipDepth;
    uint _uiFinestMipWidthHeight;
    float _fZSliceGeomFactor;
    float _fRcpLogZSliceGeomFactor;
    float _fDummy0;
    float _fDummy1;
    float _fNearP;
    float _fInvNearP;
    float _fFarP;
    float _fClusterCoincidentWithCamera;
};

struct S_PASS
{
    S_EYE_DATA _EyeData;
    vec4 _avFrustumCorners[4];
    vec4 _vTime;
    vec4 _cFogColor;
    vec4 _vFogSetup;
    vec4 _cSunColor;
    vec4 _vSunDir;
    vec4 _vProjectionSetup;
    vec4 _vProjectionCoeff;
    vec4 _vOutputColor;
    vec4 _vfVsClippingPlane[2];
    S_CLUSTER_LIGHT_SETUP _LightSetup;
    S_CLUSTER_INFO _ClusterInfo;
    float _fIBLIntensity;
    float _fGIIntensity;
    float _fAmbiantOcclusionDirectIntensity;
    float _fAmbiantOcclusionIndirectIntensity;
    float _fNormalSign;
    int _iFogType;
    float _fSelfOcclusionDebugRatio;
    float _fEmissive;
    int _iEnableSkinSSSSS;
    int _iUseHairOpaquePrepass;
    float _fLocalSceneExposure;
    uint _uiDebugMode;
    uint _sFlags;
    float _fTAADropsSharpness;
    uint _uNeoScaleX;
    uint _uNeoScaleY;
    uint _uiDirectOverdrawFilter;
    float _fCoderTest0;
    float _fCoderTest1;
    float _fCoderTest2;
    uint _uiBakeOutput;
    float _fDefaultAmbientIntensity;
    float _fDefaultLightingIntensity;
    uint _uiOutputColor;
    float _fAARotation;
    float _fClampDirectSpecular;
    float _fNearPlane;
    float _fFarPlane;
    float _fNDFFilteringScreenSpaceVariance;
    float _fNDFFilteringThreshold;
    float _fNDFFilteringScreenSpaceVariance_EyeShader;
    float _fNDFFilteringThreshold_EyeShader;
    float _fSurfaceGradientTextureFiltering;
    float _fZero;
    uint _uDepthClamp;
    uint _uiLightDebugMode;
    vec4 _vfFragCoordToDepthTexFactor;
    vec4 _vfFragCoordToDepthTexFactor_HalfRes;
    uint _uHdr;
    uint _uiDrawMayaSwatch;
    float _fEyeRoughnessBias;
    float _fDummy1;
};

layout(set = 1, binding = 24, std430) readonly buffer stc_g_rbMatrices_Layout
{
    S_MATRICES g_rbMatrices[];
} _426;

layout(set = 1, binding = 39, std430) readonly buffer g_rbVertices_Layout
{
    unaligned_float3 g_rbVertices[];
} g_rbVertices_Buffer[];

layout(set = 1, binding = 40, std430) readonly buffer g_rbTBNs_Layout
{
    S_TBN g_rbTBNs[];
} g_rbTBNs_Buffer[];

layout(set = 0, binding = 52, std140) uniform dyn_CONSTANT_BUFFER_BLOCK_CB_S_MAIN_ARRAY_BINDING
{
    S_MAIN_DEFAULT_ARRAY g_cbMainArray;
} _3339;

layout(set = 1, binding = 33, std430) readonly buffer g_rbObjects_Layout
{
    S_SPEEDTREE_MESH_OBJECT g_rbObjects[];
} g_rbObjects_Buffer[];

layout(set = 2, binding = 53, std140) uniform dyn_CONSTANT_BUFFER_BLOCK_CB_S_PASS_BINDING
{
    S_PASS g_cbPass;
} _3585;

layout(location = 8) in vec2 in_uv0;
layout(location = 10) in vec4 in_lodPosition;
layout(location = 11) in vec4 in_windBranchData;
layout(location = 12) in vec4 in_windExtraDataFlag;
layout(location = 13) in vec4 in_LeafAnchorHint;
layout(location = 8) out vec2 interp_uv0;
layout(location = 21) out vec3 interp_vfVsPosition;
layout(location = 14) out vec3 interp_vfVsTangent;
layout(location = 15) out vec3 interp_vfVsBinormal;
layout(location = 13) out vec3 interp_vfVsNormal;
layout(location = 23) out float interp_instanceID;

float _12191;

void main()
{
    int _3329 = gl_InstanceIndex + gl_DrawIDARB;
    int _3330 = readFirstInvocationARB(_3329);
    uint _5223 = uint(gl_VertexIndex);
    uint _5226 = _5223 + _3339.g_cbMainArray._aMain[_3330]._Indices._uiPositionOffset;
    vec4 _5239 = vec4(g_rbVertices_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiPositionsBufferIndex].g_rbVertices[_5226].x, g_rbVertices_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiPositionsBufferIndex].g_rbVertices[_5226].y, g_rbVertices_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiPositionsBufferIndex].g_rbVertices[_5226].z, 1.0);
    uint _5246 = _5223 + _3339.g_cbMainArray._aMain[_3330]._Indices._uiNormalOffset;
    int _5275 = g_rbTBNs_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5246]._iNormal & 1023;
    int _5278 = (g_rbTBNs_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5246]._iNormal >> 10) & 1023;
    int _5281 = (g_rbTBNs_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5246]._iNormal >> 20) & 1023;
    int _12192;
    if (_5275 > 512)
    {
        _12192 = _5275 | (-1024);
    }
    else
    {
        _12192 = _5275;
    }
    int _12194;
    if (_5278 > 512)
    {
        _12194 = _5278 | (-1024);
    }
    else
    {
        _12194 = _5278;
    }
    int _12196;
    if (_5281 > 512)
    {
        _12196 = _5281 | (-1024);
    }
    else
    {
        _12196 = _5281;
    }
    vec3 _5334 = vec3(float(_12192), float(_12194), float(_12196)) * vec3(0.001956947147846221923828125);
    int _5343 = g_rbTBNs_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5246]._iTangent & 1023;
    int _5346 = (g_rbTBNs_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5246]._iTangent >> 10) & 1023;
    int _5349 = (g_rbTBNs_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5246]._iTangent >> 20) & 1023;
    int _12198;
    if (_5343 > 512)
    {
        _12198 = _5343 | (-1024);
    }
    else
    {
        _12198 = _5343;
    }
    int _12200;
    if (_5346 > 512)
    {
        _12200 = _5346 | (-1024);
    }
    else
    {
        _12200 = _5346;
    }
    int _12202;
    if (_5349 > 512)
    {
        _12202 = _5349 | (-1024);
    }
    else
    {
        _12202 = _5349;
    }
    float _5407 = float((g_rbTBNs_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5246]._iTangent >> 30) != 0);
    vec3 _5424 = _5239.xyz;
    vec3 _5538 = vec4(vec3(float(_12198), float(_12200), float(_12202)) * vec3(0.001956947147846221923828125), _5407).xyz;
    float _5747 = (((100.0 * in_LeafAnchorHint.x) + in_LeafAnchorHint.y) + in_lodPosition.x) + in_lodPosition.y;
    bool _6022 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiLOD == 6u;
    bool _6024 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiLOD == 8u;
    bool _6027 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiLOD == 9u;
    bool _6028 = (_6022 || _6024) || _6027;
    bool _6032 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiLOD == 3u;
    bool _6041 = ((_6032 || _6022) || _6024) || _6027;
    bool _6044 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiLOD == 2u;
    bool _6047 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiLOD == 5u;
    bool _6050 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiLOD == 7u;
    float _12213;
    if (true && _6032)
    {
        vec2 _6376 = ((_5239.xy * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingBranch.x) - vec2(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.zw)) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
        float _6398 = 5.0 * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.x;
        vec2 _6424 = cos(_6376);
        float _6419 = abs(sin((((3.1415927410125732421875 * _6376.x) * _6398) + (_6376.y * _6398)) + (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_6424.x + _6424.y))));
        float _6386 = _6419 * _6419;
        float _6069 = mix(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingBranch.y, 1.0, _6386 * _6386);
        float _12214;
        if (_6028)
        {
            _12214 = _6069 * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z;
        }
        else
        {
            _12214 = _6069;
        }
        _12213 = _12214;
    }
    else
    {
        _12213 = 0.0;
    }
    vec3 _12264;
    if (true && (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiLOD != 0u))
    {
        float _6453 = max(g_rbVertices_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiPositionsBufferIndex].g_rbVertices[_5226].y - (0.25 / g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.z), 0.0) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.z;
        float _12215;
        if (_6453 != 0.0)
        {
            _12215 = pow(abs(_6453), g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.w);
        }
        else
        {
            _12215 = _6453;
        }
        vec4 _6529 = abs((fract(vec4(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.x, g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.x * 0.800000011920928955078125, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _6520 = (((_6529 * _6529) * (vec4(3.0) - (_6529 * 2.0))) - vec4(0.5)) * 2.0;
        float _6473 = _6520.y;
        vec2 _6501 = _5239.xz + (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xz * (((g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.y * (_6520.x + (_6473 * _6473))) + ((g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchAdherences.x / g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.z) * _12213)) * _12215));
        _12264 = (normalize(vec3(_6501.x, _5239.y, _6501.y)) * length(_5424)) - _5424;
    }
    else
    {
        _12264 = vec3(0.0);
    }
    vec3 _12270;
    if (true && (((_6041 || _6044) || _6047) || _6050))
    {
        float _6787 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.x + in_windBranchData.y;
        vec4 _6943 = abs((fract(vec4(_6787, (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.x * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.y) + in_windBranchData.y, (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.y * 0.5) * _6787, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _6934 = (((_6943 * _6943) * (vec4(3.0) - (_6943 * 2.0))) - vec4(0.5)) * 2.0;
        float _6829 = _6934.y * _6934.z;
        bool _6832 = _6829 < 0.0;
        float _12233;
        if (_6832)
        {
            _12233 = -_6829;
        }
        else
        {
            _12233 = _6829;
        }
        float _12314 = _6832 ? (-1.0) : 1.0;
        float _6852 = 1.0 - g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.w;
        float _7098 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.z + in_windBranchData.w;
        vec4 _7254 = abs((fract(vec4(_7098, (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.z * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.w) + in_windBranchData.w, (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.w * 0.5) * _7098, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _7245 = (((_7254 * _7254) * (vec4(3.0) - (_7254 * 2.0))) - vec4(0.5)) * 2.0;
        float _7140 = _7245.y * _7245.z;
        bool _7143 = _7140 < 0.0;
        float _12249;
        if (_7143)
        {
            _12249 = -_7140;
        }
        else
        {
            _12249 = _7140;
        }
        float _12315 = _7143 ? (-1.0) : 1.0;
        _12270 = ((_5424 + (((((fract(vec3(in_windBranchData.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0)) * in_windBranchData.x) * (((mix(mix(_6829, _12314, _12233), _12314, _12233) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.x) * _6852) + (_6934.x * (1.0 - g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.x)))) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.y)) + (((((fract(vec3(in_windBranchData.w) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0)) * in_windBranchData.z) * (((mix(mix(_7140, _12315, _12249), _12315, _12249) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.z) * _6852) + (_7245.x * (1.0 - g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.z)))) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.w)) - _5424;
    }
    else
    {
        _12270 = vec3(0.0);
    }
    vec3 _12276;
    if (_6032 && true)
    {
        vec3 _6163 = _5239.xyz;
        vec3 _12277;
        if ((false || (in_LeafAnchorHint.w > 1.0)) && _6041)
        {
            vec3 _12278;
            if (in_windExtraDataFlag.w > 0.0)
            {
                vec2 _8340 = (vec3(g_rbVertices_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiPositionsBufferIndex].g_rbVertices[_5226].x, -g_rbVertices_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiPositionsBufferIndex].g_rbVertices[_5226].z, _12191).xy - vec2(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.zw)) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
                float _8362 = 5.0 * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.x;
                vec2 _8388 = cos(_8340);
                float _8383 = abs(sin((((3.1415927410125732421875 * _8340.x) * _8362) + (_8340.y * _8362)) + (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_8388.x + _8388.y))));
                float _8350 = _8383 * _8383;
                vec3 _8404 = (fract(vec3(in_windExtraDataFlag.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0);
                float _8292 = in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.y, 1.0, _8350 * _8350), _6028 ? g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z : 1.0);
                vec3 _8439 = fract((_6163 + vec3(_5747)) * 30.299999237060546875);
                float _8447 = (_8439.x + _8439.y) + _8439.z;
                vec4 _8585 = abs((fract(vec4(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.x + _8447, (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.x * 0.75) - _8447, _12191, _12191) + vec4(0.5)) * 2.0) - vec4(1.0));
                vec4 _8576 = (((_8585 * _8585) * (vec4(3.0) - (_8585 * 2.0))) - vec4(0.5)) * 2.0;
                vec3 _8467 = _5424 - _6163;
                float _8471 = _8576.x;
                float _8473 = _8576.y;
                float _8482 = (_8292 * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.z) * (_8471 + (_8473 * _8473));
                float _8599 = sin(_8482);
                float _8602 = cos(_8482);
                float _8606 = 1.0 - _8602;
                float _8609 = _8404.x;
                float _8610 = _8606 * _8609;
                float _8622 = _8404.y;
                float _8623 = _8610 * _8622;
                float _8627 = _8404.z;
                float _8628 = _8599 * _8627;
                float _8636 = _8610 * _8627;
                float _8641 = _8599 * _8622;
                float _8659 = _8606 * _8622;
                float _8672 = _8659 * _8627;
                float _8677 = _8599 * _8609;
                vec3 _8488 = cross(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _8404);
                float _8493 = clamp(dot(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _8404), -1.0, 1.0);
                vec3 _12122 = _8488;
                _12122.y = _8488.y + _8493;
                vec3 _8500 = normalize(_12122);
                float _8517 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.z + _8447;
                vec4 _8770 = abs((fract(vec4(_8517 + (_5747 * _5747), (0.87000000476837158203125 * _8517) + _5747, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
                vec4 _8761 = (((_8770 * _8770) * (vec4(3.0) - (_8770 * 2.0))) - vec4(0.5)) * 2.0;
                float _8739 = _8761.y;
                float _8534 = _8292 * (((acos(_8493) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.w) + ((_8473 - (_8471 * _8471)) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.y)) + (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.x * pow(clamp((((_8761.x * _8739) * _8739) + 1.0) * 0.5, 0.0, 1.0), g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.y)));
                float _8784 = sin(_8534);
                float _8787 = cos(_8534);
                float _8791 = 1.0 - _8787;
                float _8794 = _8500.x;
                float _8795 = _8791 * _8794;
                float _8807 = _8500.y;
                float _8808 = _8795 * _8807;
                float _8812 = _8500.z;
                float _8813 = _8784 * _8812;
                float _8821 = _8795 * _8812;
                float _8826 = _8784 * _8807;
                float _8844 = _8791 * _8807;
                float _8857 = _8844 * _8812;
                float _8862 = _8784 * _8794;
                _12278 = ((((mat3(vec3((_8610 * _8609) + _8602, _8623 - _8628, _8636 + _8641), vec3(_8623 + _8628, (_8659 * _8622) + _8602, _8672 - _8677), vec3(_8636 - _8641, _8672 + _8677, ((_8606 * _8627) * _8627) + _8602)) * mat3(vec3((_8795 * _8794) + _8787, _8808 - _8813, _8821 + _8826), vec3(_8808 + _8813, (_8844 * _8807) + _8787, _8857 - _8862), vec3(_8821 - _8826, _8857 + _8862, ((_8791 * _8812) * _8812) + _8787))) * _8467) * length(_8467)) + _6163) - _5424;
            }
            else
            {
                vec2 _7560 = (vec3(g_rbVertices_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiPositionsBufferIndex].g_rbVertices[_5226].x, -g_rbVertices_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiPositionsBufferIndex].g_rbVertices[_5226].z, _12191).xy - vec2(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.zw)) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
                float _7582 = 5.0 * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.x;
                vec2 _7608 = cos(_7560);
                float _7603 = abs(sin((((3.1415927410125732421875 * _7560.x) * _7582) + (_7560.y * _7582)) + (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_7608.x + _7608.y))));
                float _7570 = _7603 * _7603;
                float _7573 = _7570 * _7570;
                float _7482 = _6028 ? g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z : 1.0;
                vec4 _7668 = abs((fract(vec4(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Ripple.x + _5747, 0.0, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
                vec3 _7697 = (fract(vec3(in_windExtraDataFlag.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0);
                float _7512 = in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.y, 1.0, _7573), _7482);
                vec3 _7732 = fract((_6163 + vec3(_5747)) * 30.299999237060546875);
                float _7740 = (_7732.x + _7732.y) + _7732.z;
                vec4 _7878 = abs((fract(vec4(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.x + _7740, (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.x * 0.75) - _7740, _12191, _12191) + vec4(0.5)) * 2.0) - vec4(1.0));
                vec4 _7869 = (((_7878 * _7878) * (vec4(3.0) - (_7878 * 2.0))) - vec4(0.5)) * 2.0;
                vec3 _7760 = (_5424 + ((_5334 * (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Ripple.y * ((((_7668 * _7668) * (vec4(3.0) - (_7668 * 2.0))) - vec4(0.5)) * 2.0).x)) * (in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.x, 1.0, _7573), _7482)))) - _6163;
                float _7764 = _7869.x;
                float _7766 = _7869.y;
                float _7775 = (_7512 * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.z) * (_7764 + (_7766 * _7766));
                float _7892 = sin(_7775);
                float _7895 = cos(_7775);
                float _7899 = 1.0 - _7895;
                float _7902 = _7697.x;
                float _7903 = _7899 * _7902;
                float _7915 = _7697.y;
                float _7916 = _7903 * _7915;
                float _7920 = _7697.z;
                float _7921 = _7892 * _7920;
                float _7929 = _7903 * _7920;
                float _7934 = _7892 * _7915;
                float _7952 = _7899 * _7915;
                float _7965 = _7952 * _7920;
                float _7970 = _7892 * _7902;
                vec3 _7781 = cross(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _7697);
                float _7786 = clamp(dot(g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _7697), -1.0, 1.0);
                vec3 _12009 = _7781;
                _12009.y = _7781.y + _7786;
                vec3 _7793 = normalize(_12009);
                float _7810 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.z + _7740;
                vec4 _8063 = abs((fract(vec4(_7810 + (_5747 * _5747), (0.87000000476837158203125 * _7810) + _5747, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
                vec4 _8054 = (((_8063 * _8063) * (vec4(3.0) - (_8063 * 2.0))) - vec4(0.5)) * 2.0;
                float _8032 = _8054.y;
                float _7827 = _7512 * (((acos(_7786) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.w) + ((_7766 - (_7764 * _7764)) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.y)) + (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.x * pow(clamp((((_8054.x * _8032) * _8032) + 1.0) * 0.5, 0.0, 1.0), g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.y)));
                float _8077 = sin(_7827);
                float _8080 = cos(_7827);
                float _8084 = 1.0 - _8080;
                float _8087 = _7793.x;
                float _8088 = _8084 * _8087;
                float _8100 = _7793.y;
                float _8101 = _8088 * _8100;
                float _8105 = _7793.z;
                float _8106 = _8077 * _8105;
                float _8114 = _8088 * _8105;
                float _8119 = _8077 * _8100;
                float _8137 = _8084 * _8100;
                float _8150 = _8137 * _8105;
                float _8155 = _8077 * _8087;
                _12278 = ((((mat3(vec3((_7903 * _7902) + _7895, _7916 - _7921, _7929 + _7934), vec3(_7916 + _7921, (_7952 * _7915) + _7895, _7965 - _7970), vec3(_7929 - _7934, _7965 + _7970, ((_7899 * _7920) * _7920) + _7895)) * mat3(vec3((_8088 * _8087) + _8080, _8101 - _8106, _8114 + _8119), vec3(_8101 + _8106, (_8137 * _8100) + _8080, _8150 - _8155), vec3(_8114 - _8119, _8150 + _8155, ((_8084 * _8105) * _8105) + _8080))) * _7760) * length(_7760)) + _6163) - _5424;
            }
            _12277 = _12278;
        }
        else
        {
            _12277 = vec3(0.0);
        }
        _12276 = _12277;
    }
    else
    {
        _12276 = vec3(0.0);
    }
    vec3 _12282;
    if (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiLOD == 4u)
    {
        _12282 = _5424 + (_12264 * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
    }
    else
    {
        vec3 _12283;
        if (_6047)
        {
            _12283 = _5424 + ((_12264 + _12270) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
        }
        else
        {
            vec3 _12284;
            if (_6022)
            {
                _12284 = _5424 + (((_12264 + _12270) + _12276) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
            }
            else
            {
                vec3 _12285;
                if (_6050)
                {
                    _12285 = _5424 + (_12264 + (_12270 * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z));
                }
                else
                {
                    vec3 _12286;
                    if (_6024)
                    {
                        _12286 = _5424 + (_12264 + ((_12270 + _12276) * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z));
                    }
                    else
                    {
                        vec3 _12287;
                        if (_6027)
                        {
                            _12287 = _5424 + ((_12264 + _12270) + (_12276 * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z));
                        }
                        else
                        {
                            vec3 _12288;
                            if (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiLOD == 1u)
                            {
                                _12288 = _5424 + _12264;
                            }
                            else
                            {
                                vec3 _12289;
                                if (_6044)
                                {
                                    _12289 = _5424 + (_12264 + _12270);
                                }
                                else
                                {
                                    vec3 _12290;
                                    if (_6032)
                                    {
                                        _12290 = _5424 + ((_12264 + _12270) + _12276);
                                    }
                                    else
                                    {
                                        _12290 = _5424;
                                    }
                                    _12289 = _12290;
                                }
                                _12288 = _12289;
                            }
                            _12287 = _12288;
                        }
                        _12286 = _12287;
                    }
                    _12285 = _12286;
                }
                _12284 = _12285;
            }
            _12283 = _12284;
        }
        _12282 = _12283;
    }
    vec2 _12305;
    if (g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._uiSmooth > 0u)
    {
        _12305 = in_lodPosition.xy * mix(in_lodPosition.w, 1.0, g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
    }
    else
    {
        _12305 = in_lodPosition.xy;
    }
    float _5860 = -in_lodPosition.z;
    vec3 _5863 = vec3(_12305, _5860);
    vec3 _5866 = _5863 * g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.w;
    vec4 _5873 = vec4(_12282, 1.0);
    vec4 _5874 = g_rbObjects_Buffer[_3339.g_cbMainArray._aMain[_3330]._Indices._uiObjectIndex].g_rbObjects[0]._mModel * _5873;
    float _5879 = _5874.x;
    float _5880 = _5874.y;
    float _5881 = _5874.z;
    vec4 _5882 = vec4(_5879, _5880, _5881, 1.0);
    vec4 _5883 = _3585.g_cbPass._EyeData._mCurrentFrameMatrices[0]._mView * _5882;
    vec3 _5884 = _5883.xyz;
    vec3 _5887 = _5884 + _5866;
    float _5891 = _5887.x;
    float _5892 = _5887.y;
    float _5893 = _5887.z;
    vec4 _5894 = vec4(_5891, _5892, _5893, 1.0);
    vec4 _5895 = _3585.g_cbPass._EyeData._mCurrentFrameMatrices[0]._mInvView * _5894;
    float _5902 = _5895.x;
    float _5903 = _5895.y;
    float _5904 = _5895.z;
    vec4 _5905 = vec4(_5902, _5903, _5904, 1.0);
    vec4 _5906 = _3585.g_cbPass._EyeData._mCurrentFrameMatrices[0]._mViewJitteredProj * _5905;
    vec4 _5927 = _3585.g_cbPass._EyeData._mCurrentFrameMatrices[0]._mView * _5905;
    vec4 _12307;
    if (_3585.g_cbPass._uDepthClamp == 4294967295u)
    {
        float _8932 = _5906.w;
        vec4 _12308;
        if ((_5906.z / _8932) > 1.0)
        {
            vec4 _12309;
            if (_5927.z > _3585.g_cbPass._fNearPlane)
            {
                vec4 _12181 = _5906;
                _12181.z = _8932;
                _12309 = _12181;
            }
            else
            {
                _12309 = _5906;
            }
            _12308 = _12309;
        }
        else
        {
            _12308 = _5906;
        }
        _12307 = _12308;
    }
    else
    {
        _12307 = _5906;
    }
    interp_instanceID = float(_3329) + 0.5;
    float _5106 = _5927.x;
    float _5107 = _5927.y;
    float _5108 = _5927.z;
    vec4 _5109 = vec4(_5106, _5107, _5108, 1.0);
    float _5110 = dot(_3585.g_cbPass._vfVsClippingPlane[0], _5109);
    float _5111 = -_5110;
    gl_ClipDistance[0] = _5111;
    interp_uv0 = in_uv0;
    interp_vfVsPosition = _5927.xyz;
    interp_vfVsTangent = mat3(_426.g_rbMatrices[_3339.g_cbMainArray._aMain[_3330]._Indices._uiMatricesIndex]._mModelView[0].xyz, _426.g_rbMatrices[_3339.g_cbMainArray._aMain[_3330]._Indices._uiMatricesIndex]._mModelView[1].xyz, _426.g_rbMatrices[_3339.g_cbMainArray._aMain[_3330]._Indices._uiMatricesIndex]._mModelView[2].xyz) * _5538;
    interp_vfVsBinormal = mat3(_426.g_rbMatrices[_3339.g_cbMainArray._aMain[_3330]._Indices._uiMatricesIndex]._mModelView[0].xyz, _426.g_rbMatrices[_3339.g_cbMainArray._aMain[_3330]._Indices._uiMatricesIndex]._mModelView[1].xyz, _426.g_rbMatrices[_3339.g_cbMainArray._aMain[_3330]._Indices._uiMatricesIndex]._mModelView[2].xyz) * (cross(_5334, _5538) * ((_5407 != 0.0) ? (-1.0) : 1.0));
    interp_vfVsNormal = mat3(_426.g_rbMatrices[_3339.g_cbMainArray._aMain[_3330]._Indices._uiMatricesIndex]._mModelView[0].xyz, _426.g_rbMatrices[_3339.g_cbMainArray._aMain[_3330]._Indices._uiMatricesIndex]._mModelView[1].xyz, _426.g_rbMatrices[_3339.g_cbMainArray._aMain[_3330]._Indices._uiMatricesIndex]._mModelView[2].xyz) * _5334;
    gl_Position = _12307;
}

