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

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

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 = 13) out vec3 interp_vfVsNormal;
layout(location = 23) out float interp_instanceID;

vec3 _11856;
float _11857;

void main()
{
    int _3229 = gl_InstanceIndex + gl_DrawIDARB;
    int _3230 = readFirstInvocationARB(_3229);
    uint _5124 = uint(gl_VertexIndex);
    uint _5127 = _5124 + _3239.g_cbMainArray._aMain[_3230]._Indices._uiPositionOffset;
    vec4 _5140 = vec4(g_rbVertices_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiPositionsBufferIndex].g_rbVertices[_5127].x, g_rbVertices_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiPositionsBufferIndex].g_rbVertices[_5127].y, g_rbVertices_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiPositionsBufferIndex].g_rbVertices[_5127].z, 1.0);
    uint _5147 = _5124 + _3239.g_cbMainArray._aMain[_3230]._Indices._uiNormalOffset;
    int _5176 = g_rbTBNs_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5147]._iNormal & 1023;
    int _5179 = (g_rbTBNs_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5147]._iNormal >> 10) & 1023;
    int _5182 = (g_rbTBNs_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5147]._iNormal >> 20) & 1023;
    int _11858;
    if (_5176 > 512)
    {
        _11858 = _5176 | (-1024);
    }
    else
    {
        _11858 = _5176;
    }
    int _11860;
    if (_5179 > 512)
    {
        _11860 = _5179 | (-1024);
    }
    else
    {
        _11860 = _5179;
    }
    int _11862;
    if (_5182 > 512)
    {
        _11862 = _5182 | (-1024);
    }
    else
    {
        _11862 = _5182;
    }
    vec3 _5235 = vec3(float(_11858), float(_11860), float(_11862)) * vec3(0.001956947147846221923828125);
    vec3 _5325 = _5140.xyz;
    float _5648 = (((100.0 * in_LeafAnchorHint.x) + in_LeafAnchorHint.y) + in_lodPosition.x) + in_lodPosition.y;
    vec3 _5656 = vec3(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
    vec3 _5657 = mix(in_lodPosition.xyz, _5325, _5656);
    vec2 _5842 = _5657.xy;
    vec2 _5843 = _5842 * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingBranch.x;
    vec2 _6010 = vec2(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.zw);
    vec2 _6011 = _5843 - _6010;
    vec2 _6012 = _6011 * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
    float _6034 = 5.0 * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.x;
    vec2 _6060 = cos(_6012);
    float _6062 = _6060.x;
    float _6064 = _6060.y;
    float _6065 = _6062 + _6064;
    float _6041 = _6012.x;
    float _6042 = 3.1415927410125732421875 * _6041;
    float _6044 = _6042 * _6034;
    float _6046 = _6012.y;
    float _6048 = _6046 * _6034;
    float _6049 = _6044 + _6048;
    float _6052 = g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * _6065;
    float _6053 = _6049 + _6052;
    float _6054 = sin(_6053);
    float _6055 = abs(_6054);
    float _6022 = _6055 * _6055;
    float _6025 = _6022 * _6022;
    float _5851 = mix(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingBranch.y, 1.0, _6025);
    float _5855 = _5851 * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z;
    float _6078 = length(_5657);
    float _6089 = max(_5657.y - (0.25 / g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.z), 0.0) * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.z;
    float _11868;
    if (_6089 != 0.0)
    {
        _11868 = pow(abs(_6089), g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.w);
    }
    else
    {
        _11868 = _6089;
    }
    float _6103 = g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.x * 0.800000011920928955078125;
    vec4 _6104 = vec4(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.x, _6103, 0.0, 0.0);
    vec4 _6160 = _6104 + vec4(0.5);
    vec4 _6161 = fract(_6160);
    vec4 _6162 = _6161 * 2.0;
    vec4 _6164 = _6162 - vec4(1.0);
    vec4 _6165 = abs(_6164);
    vec4 _6169 = _6165 * _6165;
    vec4 _6171 = _6165 * 2.0;
    vec4 _6173 = vec4(3.0) - _6171;
    vec4 _6174 = _6169 * _6173;
    vec4 _6155 = _6174 - vec4(0.5);
    vec4 _6156 = _6155 * 2.0;
    float _6107 = _6156.x;
    float _6109 = _6156.y;
    float _6112 = _6109 * _6109;
    float _6113 = _6107 + _6112;
    float _6117 = g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.y * _6113;
    float _6122 = g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchAdherences.x / g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.z;
    float _6125 = _6122 * _5855;
    float _6127 = _6117 + _6125;
    float _6130 = _6127 * _11868;
    vec2 _6134 = g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xz * _6130;
    vec2 _6136 = _5657.xz;
    vec2 _6137 = _6136 + _6134;
    vec3 _6139 = vec3(_6137.x, _5657.y, _6137.y);
    vec3 _6144 = normalize(_6139);
    vec3 _6146 = _6144 * _6078;
    vec3 _5870 = _6146 - _5657;
    vec3 _6334 = vec3(in_windBranchData.y);
    vec3 _6335 = _6334 * vec3(0.0625, -1.0, 16.0);
    vec3 _6336 = fract(_6335);
    vec3 _6338 = _6336.xzy;
    vec3 _6339 = _6338 * 2.0;
    vec3 _6340 = _6339 - vec3(1.0);
    vec3 _6310 = _6340 * in_windBranchData.x;
    float _6409 = g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.x + in_windBranchData.y;
    float _6412 = g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.x * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.y;
    float _6414 = _6412 + in_windBranchData.y;
    float _6416 = g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.y * 0.5;
    float _6420 = _6416 * _6409;
    vec4 _6421 = vec4(_6409, _6414, _6420, 0.0);
    vec4 _6560 = _6421 + vec4(0.5);
    vec4 _6561 = fract(_6560);
    vec4 _6562 = _6561 * 2.0;
    vec4 _6564 = _6562 - vec4(1.0);
    vec4 _6565 = abs(_6564);
    vec4 _6569 = _6565 * _6565;
    vec4 _6571 = _6565 * 2.0;
    vec4 _6573 = vec4(3.0) - _6571;
    vec4 _6574 = _6569 * _6573;
    vec4 _6555 = _6574 - vec4(0.5);
    vec4 _6556 = _6555 * 2.0;
    float _6446 = _6556.x;
    float _6448 = _6556.y;
    float _6450 = _6556.z;
    float _6451 = _6448 * _6450;
    bool _6454 = _6451 < 0.0;
    float _11879;
    if (_6454)
    {
        _11879 = -_6451;
    }
    else
    {
        _11879 = _6451;
    }
    float _11917 = _6454 ? (-1.0) : 1.0;
    float _6464 = mix(_6451, _11917, _11879);
    float _6468 = mix(_6464, _11917, _11879);
    float _6471 = _6468 * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.x;
    float _6474 = 1.0 - g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.w;
    float _6475 = _6471 * _6474;
    float _6478 = 1.0 - g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.x;
    float _6479 = _6446 * _6478;
    float _6480 = _6475 + _6479;
    vec3 _6325 = _6310 * _6480;
    vec3 _6327 = _6325 * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.y;
    vec3 _6329 = _5657 + _6327;
    vec3 _5891 = _6329 - _5657;
    vec3 _11888;
    if (in_windExtraDataFlag.w > 0.0)
    {
        vec2 _7526 = (vec3(in_LeafAnchorHint.x, -in_LeafAnchorHint.z, _11857).xy - _6010) * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
        vec2 _7574 = cos(_7526);
        float _7569 = abs(sin((((3.1415927410125732421875 * _7526.x) * _6034) + (_7526.y * _6034)) + (g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_7574.x + _7574.y))));
        float _7536 = _7569 * _7569;
        float _7539 = _7536 * _7536;
        vec4 _7634 = abs((fract(vec4(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Ripple.x + _5648, 0.0, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec3 _7663 = (fract(vec3(in_windExtraDataFlag.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0);
        float _7478 = in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.y, 1.0, _7539), g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
        vec3 _7698 = fract((vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z) + vec3(_5648)) * 30.299999237060546875);
        float _7706 = (_7698.x + _7698.y) + _7698.z;
        vec4 _7843 = abs((fract(vec4(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.x + _7706, (g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.x * 0.75) - _7706, _11857, _11857) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _7834 = (((_7843 * _7843) * (vec4(3.0) - (_7843 * 2.0))) - vec4(0.5)) * 2.0;
        vec3 _7726 = (_5657 + ((_5235 * (g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Ripple.y * ((((_7634 * _7634) * (vec4(3.0) - (_7634 * 2.0))) - vec4(0.5)) * 2.0).x)) * (in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.x, 1.0, _7539), g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z)))) - vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z);
        float _7730 = _7834.x;
        float _7732 = _7834.y;
        float _7741 = (_7478 * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.z) * (_7730 + (_7732 * _7732));
        float _7857 = sin(_7741);
        float _7860 = cos(_7741);
        float _7864 = 1.0 - _7860;
        float _7867 = _7663.x;
        float _7868 = _7864 * _7867;
        float _7880 = _7663.y;
        float _7881 = _7868 * _7880;
        float _7885 = _7663.z;
        float _7886 = _7857 * _7885;
        float _7894 = _7868 * _7885;
        float _7899 = _7857 * _7880;
        float _7917 = _7864 * _7880;
        float _7930 = _7917 * _7885;
        float _7935 = _7857 * _7867;
        vec3 _7747 = cross(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _7663);
        float _7752 = clamp(dot(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _7663), -1.0, 1.0);
        vec3 _11791 = _7747;
        _11791.y = _7747.y + _7752;
        vec3 _7759 = normalize(_11791);
        float _7776 = g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.z + _7706;
        vec4 _8028 = abs((fract(vec4(_7776 + (_5648 * _5648), (0.87000000476837158203125 * _7776) + _5648, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _8019 = (((_8028 * _8028) * (vec4(3.0) - (_8028 * 2.0))) - vec4(0.5)) * 2.0;
        float _7997 = _8019.y;
        float _7793 = _7478 * (((acos(_7752) * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.w) + ((_7732 - (_7730 * _7730)) * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.y)) + (g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.x * pow(clamp((((_8019.x * _7997) * _7997) + 1.0) * 0.5, 0.0, 1.0), g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.y)));
        float _8042 = sin(_7793);
        float _8045 = cos(_7793);
        float _8049 = 1.0 - _8045;
        float _8052 = _7759.x;
        float _8053 = _8049 * _8052;
        float _8065 = _7759.y;
        float _8066 = _8053 * _8065;
        float _8070 = _7759.z;
        float _8071 = _8042 * _8070;
        float _8079 = _8053 * _8070;
        float _8084 = _8042 * _8065;
        float _8102 = _8049 * _8065;
        float _8115 = _8102 * _8070;
        float _8120 = _8042 * _8052;
        _11888 = ((normalize((mat3(vec3((_7868 * _7867) + _7860, _7881 - _7886, _7894 + _7899), vec3(_7881 + _7886, (_7917 * _7880) + _7860, _7930 - _7935), vec3(_7894 - _7899, _7930 + _7935, ((_7864 * _7885) * _7885) + _7860)) * mat3(vec3((_8053 * _8052) + _8045, _8066 - _8071, _8079 + _8084), vec3(_8066 + _8071, (_8102 * _8065) + _8045, _8115 - _8120), vec3(_8079 - _8084, _8115 + _8120, ((_8049 * _8070) * _8070) + _8045))) * _7726) * length(_7726)) + vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z)) - _5657;
    }
    else
    {
        vec2 _6738 = (vec3(in_LeafAnchorHint.x, -in_LeafAnchorHint.z, _11857).xy - _6010) * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
        vec2 _6786 = cos(_6738);
        float _6781 = abs(sin((((3.1415927410125732421875 * _6738.x) * _6034) + (_6738.y * _6034)) + (g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_6786.x + _6786.y))));
        float _6748 = _6781 * _6781;
        float _6751 = _6748 * _6748;
        vec4 _6846 = abs((fract(vec4(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Ripple.x + _5648, 0.0, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec3 _6875 = (fract(vec3(in_windExtraDataFlag.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0);
        float _6690 = in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.y, 1.0, _6751), g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
        vec3 _6910 = fract((vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z) + vec3(_5648)) * 30.299999237060546875);
        float _6918 = (_6910.x + _6910.y) + _6910.z;
        vec4 _7055 = abs((fract(vec4(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.x + _6918, (g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.x * 0.75) - _6918, _11857, _11857) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _7046 = (((_7055 * _7055) * (vec4(3.0) - (_7055 * 2.0))) - vec4(0.5)) * 2.0;
        vec3 _6938 = (_5657 + ((_5235 * (g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Ripple.y * ((((_6846 * _6846) * (vec4(3.0) - (_6846 * 2.0))) - vec4(0.5)) * 2.0).x)) * (in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.x, 1.0, _6751), g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z)))) - vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z);
        float _6942 = _7046.x;
        float _6944 = _7046.y;
        float _6953 = (_6690 * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.z) * (_6942 + (_6944 * _6944));
        float _7069 = sin(_6953);
        float _7072 = cos(_6953);
        float _7076 = 1.0 - _7072;
        float _7079 = _6875.x;
        float _7080 = _7076 * _7079;
        float _7092 = _6875.y;
        float _7093 = _7080 * _7092;
        float _7097 = _6875.z;
        float _7098 = _7069 * _7097;
        float _7106 = _7080 * _7097;
        float _7111 = _7069 * _7092;
        float _7129 = _7076 * _7092;
        float _7142 = _7129 * _7097;
        float _7147 = _7069 * _7079;
        vec3 _6959 = cross(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _6875);
        float _6964 = clamp(dot(g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _6875), -1.0, 1.0);
        vec3 _11676 = _6959;
        _11676.y = _6959.y + _6964;
        vec3 _6971 = normalize(_11676);
        float _6988 = g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.z + _6918;
        vec4 _7240 = abs((fract(vec4(_6988 + (_5648 * _5648), (0.87000000476837158203125 * _6988) + _5648, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _7231 = (((_7240 * _7240) * (vec4(3.0) - (_7240 * 2.0))) - vec4(0.5)) * 2.0;
        float _7209 = _7231.y;
        float _7005 = _6690 * (((acos(_6964) * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.w) + ((_6944 - (_6942 * _6942)) * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.y)) + (g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.x * pow(clamp((((_7231.x * _7209) * _7209) + 1.0) * 0.5, 0.0, 1.0), g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.y)));
        float _7254 = sin(_7005);
        float _7257 = cos(_7005);
        float _7261 = 1.0 - _7257;
        float _7264 = _6971.x;
        float _7265 = _7261 * _7264;
        float _7277 = _6971.y;
        float _7278 = _7265 * _7277;
        float _7282 = _6971.z;
        float _7283 = _7254 * _7282;
        float _7291 = _7265 * _7282;
        float _7296 = _7254 * _7277;
        float _7314 = _7261 * _7277;
        float _7327 = _7314 * _7282;
        float _7332 = _7254 * _7264;
        _11888 = ((normalize((mat3(vec3((_7080 * _7079) + _7072, _7093 - _7098, _7106 + _7111), vec3(_7093 + _7098, (_7129 * _7092) + _7072, _7142 - _7147), vec3(_7106 - _7111, _7142 + _7147, ((_7076 * _7097) * _7097) + _7072)) * mat3(vec3((_7265 * _7264) + _7257, _7278 - _7283, _7291 + _7296), vec3(_7278 + _7283, (_7314 * _7277) + _7257, _7327 - _7332), vec3(_7291 - _7296, _7327 + _7332, ((_7261 * _7282) * _7282) + _7257))) * _6938) * length(_6938)) + vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z)) - _5657;
    }
    vec3 _5967 = _5870 + _5891;
    vec3 _5972 = _11888 * g_rbObjects_Buffer[_3239.g_cbMainArray._aMain[_3230]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z;
    vec3 _5973 = _5967 + _5972;
    vec3 _5975 = _5657 + _5973;
    float _8214 = _5975.x;
    float _8215 = _5975.y;
    float _8216 = _5975.z;
    vec4 _8217 = vec4(_8214, _8215, _8216, 1.0);
    vec4 _8218 = _426.g_rbMatrices[_3239.g_cbMainArray._aMain[_3230]._Indices._uiMatricesIndex]._mModelView * _8217;
    vec4 _8237 = _426.g_rbMatrices[_3239.g_cbMainArray._aMain[_3230]._Indices._uiMatricesIndex]._mModelViewProj * _8217;
    vec4 _11912;
    if (_3486.g_cbPass._uDepthClamp == 4294967295u)
    {
        float _8271 = _8237.w;
        vec4 _11913;
        if ((_8237.z / _8271) > 1.0)
        {
            vec4 _11914;
            if (_8218.z > _3486.g_cbPass._fNearPlane)
            {
                vec4 _11846 = _8237;
                _11846.z = _8271;
                _11914 = _11846;
            }
            else
            {
                _11914 = _8237;
            }
            _11913 = _11914;
        }
        else
        {
            _11913 = _8237;
        }
        _11912 = _11913;
    }
    else
    {
        _11912 = _8237;
    }
    interp_instanceID = float(_3229) + 0.5;
    float _5007 = _8218.x;
    float _5008 = _8218.y;
    float _5009 = _8218.z;
    vec4 _5010 = vec4(_5007, _5008, _5009, 1.0);
    float _5011 = dot(_3486.g_cbPass._vfVsClippingPlane[0], _5010);
    float _5012 = -_5011;
    gl_ClipDistance[0] = _5012;
    interp_uv0 = in_uv0;
    interp_vfVsPosition = _8218.xyz;
    interp_vfVsNormal = mat3(_426.g_rbMatrices[_3239.g_cbMainArray._aMain[_3230]._Indices._uiMatricesIndex]._mModelView[0].xyz, _426.g_rbMatrices[_3239.g_cbMainArray._aMain[_3230]._Indices._uiMatricesIndex]._mModelView[1].xyz, _426.g_rbMatrices[_3239.g_cbMainArray._aMain[_3230]._Indices._uiMatricesIndex]._mModelView[2].xyz) * _5235;
    gl_Position = _11912;
}

