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

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

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;

vec3 _11886;
float _11887;

void main()
{
    int _3243 = gl_InstanceIndex + gl_DrawIDARB;
    int _3244 = readFirstInvocationARB(_3243);
    uint _5138 = uint(gl_VertexIndex);
    uint _5141 = _5138 + _3253.g_cbMainArray._aMain[_3244]._Indices._uiPositionOffset;
    vec4 _5154 = vec4(g_rbVertices_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiPositionsBufferIndex].g_rbVertices[_5141].x, g_rbVertices_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiPositionsBufferIndex].g_rbVertices[_5141].y, g_rbVertices_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiPositionsBufferIndex].g_rbVertices[_5141].z, 1.0);
    uint _5161 = _5138 + _3253.g_cbMainArray._aMain[_3244]._Indices._uiNormalOffset;
    int _5190 = g_rbTBNs_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5161]._iNormal & 1023;
    int _5193 = (g_rbTBNs_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5161]._iNormal >> 10) & 1023;
    int _5196 = (g_rbTBNs_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5161]._iNormal >> 20) & 1023;
    int _11888;
    if (_5190 > 512)
    {
        _11888 = _5190 | (-1024);
    }
    else
    {
        _11888 = _5190;
    }
    int _11890;
    if (_5193 > 512)
    {
        _11890 = _5193 | (-1024);
    }
    else
    {
        _11890 = _5193;
    }
    int _11892;
    if (_5196 > 512)
    {
        _11892 = _5196 | (-1024);
    }
    else
    {
        _11892 = _5196;
    }
    vec3 _5249 = vec3(float(_11888), float(_11890), float(_11892)) * vec3(0.001956947147846221923828125);
    int _5258 = g_rbTBNs_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5161]._iTangent & 1023;
    int _5261 = (g_rbTBNs_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5161]._iTangent >> 10) & 1023;
    int _5264 = (g_rbTBNs_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5161]._iTangent >> 20) & 1023;
    int _11894;
    if (_5258 > 512)
    {
        _11894 = _5258 | (-1024);
    }
    else
    {
        _11894 = _5258;
    }
    int _11896;
    if (_5261 > 512)
    {
        _11896 = _5261 | (-1024);
    }
    else
    {
        _11896 = _5261;
    }
    int _11898;
    if (_5264 > 512)
    {
        _11898 = _5264 | (-1024);
    }
    else
    {
        _11898 = _5264;
    }
    float _5322 = float((g_rbTBNs_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiNormalsBufferIndex].g_rbTBNs[_5161]._iTangent >> 30) != 0);
    vec3 _5339 = _5154.xyz;
    vec3 _5453 = vec4(vec3(float(_11894), float(_11896), float(_11898)) * vec3(0.001956947147846221923828125), _5322).xyz;
    float _5662 = (((100.0 * in_LeafAnchorHint.x) + in_LeafAnchorHint.y) + in_lodPosition.x) + in_lodPosition.y;
    vec3 _5670 = vec3(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
    vec3 _5671 = mix(in_lodPosition.xyz, _5339, _5670);
    vec2 _5856 = _5671.xy;
    vec2 _5857 = _5856 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingBranch.x;
    vec2 _6024 = vec2(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.zw);
    vec2 _6025 = _5857 - _6024;
    vec2 _6026 = _6025 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
    float _6048 = 5.0 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.x;
    vec2 _6074 = cos(_6026);
    float _6076 = _6074.x;
    float _6078 = _6074.y;
    float _6079 = _6076 + _6078;
    float _6055 = _6026.x;
    float _6056 = 3.1415927410125732421875 * _6055;
    float _6058 = _6056 * _6048;
    float _6060 = _6026.y;
    float _6062 = _6060 * _6048;
    float _6063 = _6058 + _6062;
    float _6066 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * _6079;
    float _6067 = _6063 + _6066;
    float _6068 = sin(_6067);
    float _6069 = abs(_6068);
    float _6036 = _6069 * _6069;
    float _6039 = _6036 * _6036;
    float _5865 = mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingBranch.y, 1.0, _6039);
    float _5869 = _5865 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z;
    float _6092 = length(_5671);
    float _6103 = max(_5671.y - (0.25 / g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.z), 0.0) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.z;
    float _11907;
    if (_6103 != 0.0)
    {
        _11907 = pow(abs(_6103), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.w);
    }
    else
    {
        _11907 = _6103;
    }
    float _6117 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.x * 0.800000011920928955078125;
    vec4 _6118 = vec4(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.x, _6117, 0.0, 0.0);
    vec4 _6174 = _6118 + vec4(0.5);
    vec4 _6175 = fract(_6174);
    vec4 _6176 = _6175 * 2.0;
    vec4 _6178 = _6176 - vec4(1.0);
    vec4 _6179 = abs(_6178);
    vec4 _6183 = _6179 * _6179;
    vec4 _6185 = _6179 * 2.0;
    vec4 _6187 = vec4(3.0) - _6185;
    vec4 _6188 = _6183 * _6187;
    vec4 _6169 = _6188 - vec4(0.5);
    vec4 _6170 = _6169 * 2.0;
    float _6121 = _6170.x;
    float _6123 = _6170.y;
    float _6126 = _6123 * _6123;
    float _6127 = _6121 + _6126;
    float _6131 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.y * _6127;
    float _6136 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchAdherences.x / g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.z;
    float _6139 = _6136 * _5869;
    float _6141 = _6131 + _6139;
    float _6144 = _6141 * _11907;
    vec2 _6148 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xz * _6144;
    vec2 _6150 = _5671.xz;
    vec2 _6151 = _6150 + _6148;
    vec3 _6153 = vec3(_6151.x, _5671.y, _6151.y);
    vec3 _6158 = normalize(_6153);
    vec3 _6160 = _6158 * _6092;
    vec3 _5884 = _6160 - _5671;
    vec3 _6348 = vec3(in_windBranchData.y);
    vec3 _6349 = _6348 * vec3(0.0625, -1.0, 16.0);
    vec3 _6350 = fract(_6349);
    vec3 _6352 = _6350.xzy;
    vec3 _6353 = _6352 * 2.0;
    vec3 _6354 = _6353 - vec3(1.0);
    vec3 _6324 = _6354 * in_windBranchData.x;
    float _6423 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.x + in_windBranchData.y;
    float _6426 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.x * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.y;
    float _6428 = _6426 + in_windBranchData.y;
    float _6430 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.y * 0.5;
    float _6434 = _6430 * _6423;
    vec4 _6435 = vec4(_6423, _6428, _6434, 0.0);
    vec4 _6574 = _6435 + vec4(0.5);
    vec4 _6575 = fract(_6574);
    vec4 _6576 = _6575 * 2.0;
    vec4 _6578 = _6576 - vec4(1.0);
    vec4 _6579 = abs(_6578);
    vec4 _6583 = _6579 * _6579;
    vec4 _6585 = _6579 * 2.0;
    vec4 _6587 = vec4(3.0) - _6585;
    vec4 _6588 = _6583 * _6587;
    vec4 _6569 = _6588 - vec4(0.5);
    vec4 _6570 = _6569 * 2.0;
    float _6460 = _6570.x;
    float _6462 = _6570.y;
    float _6464 = _6570.z;
    float _6465 = _6462 * _6464;
    bool _6468 = _6465 < 0.0;
    float _11921;
    if (_6468)
    {
        _11921 = -_6465;
    }
    else
    {
        _11921 = _6465;
    }
    float _11967 = _6468 ? (-1.0) : 1.0;
    float _6478 = mix(_6465, _11967, _11921);
    float _6482 = mix(_6478, _11967, _11921);
    float _6485 = _6482 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.x;
    float _6488 = 1.0 - g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.w;
    float _6489 = _6485 * _6488;
    float _6492 = 1.0 - g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.x;
    float _6493 = _6460 * _6492;
    float _6494 = _6489 + _6493;
    vec3 _6339 = _6324 * _6494;
    vec3 _6341 = _6339 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.y;
    vec3 _6343 = _5671 + _6341;
    vec3 _5905 = _6343 - _5671;
    vec3 _11930;
    if (in_windExtraDataFlag.w > 0.0)
    {
        vec2 _7540 = (vec3(in_LeafAnchorHint.x, -in_LeafAnchorHint.z, _11887).xy - _6024) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
        vec2 _7588 = cos(_7540);
        float _7583 = abs(sin((((3.1415927410125732421875 * _7540.x) * _6048) + (_7540.y * _6048)) + (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_7588.x + _7588.y))));
        float _7550 = _7583 * _7583;
        float _7553 = _7550 * _7550;
        vec4 _7648 = abs((fract(vec4(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Ripple.x + _5662, 0.0, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec3 _7677 = (fract(vec3(in_windExtraDataFlag.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0);
        float _7492 = in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.y, 1.0, _7553), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
        vec3 _7712 = fract((vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z) + vec3(_5662)) * 30.299999237060546875);
        float _7720 = (_7712.x + _7712.y) + _7712.z;
        vec4 _7857 = abs((fract(vec4(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.x + _7720, (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.x * 0.75) - _7720, _11887, _11887) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _7848 = (((_7857 * _7857) * (vec4(3.0) - (_7857 * 2.0))) - vec4(0.5)) * 2.0;
        vec3 _7740 = (_5671 + ((_5249 * (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Ripple.y * ((((_7648 * _7648) * (vec4(3.0) - (_7648 * 2.0))) - vec4(0.5)) * 2.0).x)) * (in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.x, 1.0, _7553), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z)))) - vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z);
        float _7744 = _7848.x;
        float _7746 = _7848.y;
        float _7755 = (_7492 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.z) * (_7744 + (_7746 * _7746));
        float _7871 = sin(_7755);
        float _7874 = cos(_7755);
        float _7878 = 1.0 - _7874;
        float _7881 = _7677.x;
        float _7882 = _7878 * _7881;
        float _7894 = _7677.y;
        float _7895 = _7882 * _7894;
        float _7899 = _7677.z;
        float _7900 = _7871 * _7899;
        float _7908 = _7882 * _7899;
        float _7913 = _7871 * _7894;
        float _7931 = _7878 * _7894;
        float _7944 = _7931 * _7899;
        float _7949 = _7871 * _7881;
        vec3 _7761 = cross(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _7677);
        float _7766 = clamp(dot(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _7677), -1.0, 1.0);
        vec3 _11821 = _7761;
        _11821.y = _7761.y + _7766;
        vec3 _7773 = normalize(_11821);
        float _7790 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.z + _7720;
        vec4 _8042 = abs((fract(vec4(_7790 + (_5662 * _5662), (0.87000000476837158203125 * _7790) + _5662, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _8033 = (((_8042 * _8042) * (vec4(3.0) - (_8042 * 2.0))) - vec4(0.5)) * 2.0;
        float _8011 = _8033.y;
        float _7807 = _7492 * (((acos(_7766) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.w) + ((_7746 - (_7744 * _7744)) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.y)) + (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.x * pow(clamp((((_8033.x * _8011) * _8011) + 1.0) * 0.5, 0.0, 1.0), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.y)));
        float _8056 = sin(_7807);
        float _8059 = cos(_7807);
        float _8063 = 1.0 - _8059;
        float _8066 = _7773.x;
        float _8067 = _8063 * _8066;
        float _8079 = _7773.y;
        float _8080 = _8067 * _8079;
        float _8084 = _7773.z;
        float _8085 = _8056 * _8084;
        float _8093 = _8067 * _8084;
        float _8098 = _8056 * _8079;
        float _8116 = _8063 * _8079;
        float _8129 = _8116 * _8084;
        float _8134 = _8056 * _8066;
        _11930 = ((normalize((mat3(vec3((_7882 * _7881) + _7874, _7895 - _7900, _7908 + _7913), vec3(_7895 + _7900, (_7931 * _7894) + _7874, _7944 - _7949), vec3(_7908 - _7913, _7944 + _7949, ((_7878 * _7899) * _7899) + _7874)) * mat3(vec3((_8067 * _8066) + _8059, _8080 - _8085, _8093 + _8098), vec3(_8080 + _8085, (_8116 * _8079) + _8059, _8129 - _8134), vec3(_8093 - _8098, _8129 + _8134, ((_8063 * _8084) * _8084) + _8059))) * _7740) * length(_7740)) + vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z)) - _5671;
    }
    else
    {
        vec2 _6752 = (vec3(in_LeafAnchorHint.x, -in_LeafAnchorHint.z, _11887).xy - _6024) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
        vec2 _6800 = cos(_6752);
        float _6795 = abs(sin((((3.1415927410125732421875 * _6752.x) * _6048) + (_6752.y * _6048)) + (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_6800.x + _6800.y))));
        float _6762 = _6795 * _6795;
        float _6765 = _6762 * _6762;
        vec4 _6860 = abs((fract(vec4(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Ripple.x + _5662, 0.0, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec3 _6889 = (fract(vec3(in_windExtraDataFlag.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0);
        float _6704 = in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.y, 1.0, _6765), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
        vec3 _6924 = fract((vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z) + vec3(_5662)) * 30.299999237060546875);
        float _6932 = (_6924.x + _6924.y) + _6924.z;
        vec4 _7069 = abs((fract(vec4(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.x + _6932, (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.x * 0.75) - _6932, _11887, _11887) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _7060 = (((_7069 * _7069) * (vec4(3.0) - (_7069 * 2.0))) - vec4(0.5)) * 2.0;
        vec3 _6952 = (_5671 + ((_5249 * (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Ripple.y * ((((_6860 * _6860) * (vec4(3.0) - (_6860 * 2.0))) - vec4(0.5)) * 2.0).x)) * (in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.x, 1.0, _6765), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z)))) - vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z);
        float _6956 = _7060.x;
        float _6958 = _7060.y;
        float _6967 = (_6704 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.z) * (_6956 + (_6958 * _6958));
        float _7083 = sin(_6967);
        float _7086 = cos(_6967);
        float _7090 = 1.0 - _7086;
        float _7093 = _6889.x;
        float _7094 = _7090 * _7093;
        float _7106 = _6889.y;
        float _7107 = _7094 * _7106;
        float _7111 = _6889.z;
        float _7112 = _7083 * _7111;
        float _7120 = _7094 * _7111;
        float _7125 = _7083 * _7106;
        float _7143 = _7090 * _7106;
        float _7156 = _7143 * _7111;
        float _7161 = _7083 * _7093;
        vec3 _6973 = cross(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _6889);
        float _6978 = clamp(dot(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _6889), -1.0, 1.0);
        vec3 _11706 = _6973;
        _11706.y = _6973.y + _6978;
        vec3 _6985 = normalize(_11706);
        float _7002 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.z + _6932;
        vec4 _7254 = abs((fract(vec4(_7002 + (_5662 * _5662), (0.87000000476837158203125 * _7002) + _5662, 0.0, 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 _7223 = _7245.y;
        float _7019 = _6704 * (((acos(_6978) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.w) + ((_6958 - (_6956 * _6956)) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.y)) + (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.x * pow(clamp((((_7245.x * _7223) * _7223) + 1.0) * 0.5, 0.0, 1.0), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.y)));
        float _7268 = sin(_7019);
        float _7271 = cos(_7019);
        float _7275 = 1.0 - _7271;
        float _7278 = _6985.x;
        float _7279 = _7275 * _7278;
        float _7291 = _6985.y;
        float _7292 = _7279 * _7291;
        float _7296 = _6985.z;
        float _7297 = _7268 * _7296;
        float _7305 = _7279 * _7296;
        float _7310 = _7268 * _7291;
        float _7328 = _7275 * _7291;
        float _7341 = _7328 * _7296;
        float _7346 = _7268 * _7278;
        _11930 = ((normalize((mat3(vec3((_7094 * _7093) + _7086, _7107 - _7112, _7120 + _7125), vec3(_7107 + _7112, (_7143 * _7106) + _7086, _7156 - _7161), vec3(_7120 - _7125, _7156 + _7161, ((_7090 * _7111) * _7111) + _7086)) * mat3(vec3((_7279 * _7278) + _7271, _7292 - _7297, _7305 + _7310), vec3(_7292 + _7297, (_7328 * _7291) + _7271, _7341 - _7346), vec3(_7305 - _7310, _7341 + _7346, ((_7275 * _7296) * _7296) + _7271))) * _6952) * length(_6952)) + vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z)) - _5671;
    }
    vec3 _5981 = _5884 + _5905;
    vec3 _5986 = _11930 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z;
    vec3 _5987 = _5981 + _5986;
    vec3 _5989 = _5671 + _5987;
    float _8228 = _5989.x;
    float _8229 = _5989.y;
    float _8230 = _5989.z;
    vec4 _8231 = vec4(_8228, _8229, _8230, 1.0);
    vec4 _8232 = _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView * _8231;
    vec4 _8251 = _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelViewProj * _8231;
    vec4 _11960;
    if (_3500.g_cbPass._uDepthClamp == 4294967295u)
    {
        float _8285 = _8251.w;
        vec4 _11961;
        if ((_8251.z / _8285) > 1.0)
        {
            vec4 _11962;
            if (_8232.z > _3500.g_cbPass._fNearPlane)
            {
                vec4 _11876 = _8251;
                _11876.z = _8285;
                _11962 = _11876;
            }
            else
            {
                _11962 = _8251;
            }
            _11961 = _11962;
        }
        else
        {
            _11961 = _8251;
        }
        _11960 = _11961;
    }
    else
    {
        _11960 = _8251;
    }
    interp_instanceID = float(_3243) + 0.5;
    float _5021 = _8232.x;
    float _5022 = _8232.y;
    float _5023 = _8232.z;
    vec4 _5024 = vec4(_5021, _5022, _5023, 1.0);
    float _5025 = dot(_3500.g_cbPass._vfVsClippingPlane[0], _5024);
    float _5026 = -_5025;
    gl_ClipDistance[0] = _5026;
    interp_uv0 = in_uv0;
    interp_vfVsPosition = _8232.xyz;
    interp_vfVsTangent = mat3(_426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView[0].xyz, _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView[1].xyz, _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView[2].xyz) * _5453;
    interp_vfVsBinormal = mat3(_426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView[0].xyz, _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView[1].xyz, _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView[2].xyz) * (cross(_5249, _5453) * ((_5322 != 0.0) ? (-1.0) : 1.0));
    interp_vfVsNormal = mat3(_426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView[0].xyz, _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView[1].xyz, _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView[2].xyz) * _5249;
    gl_Position = _11960;
}

