
// 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 _12271;
float _12272;

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 _12273;
    if (_5190 > 512)
    {
        _12273 = _5190 | (-1024);
    }
    else
    {
        _12273 = _5190;
    }
    int _12275;
    if (_5193 > 512)
    {
        _12275 = _5193 | (-1024);
    }
    else
    {
        _12275 = _5193;
    }
    int _12277;
    if (_5196 > 512)
    {
        _12277 = _5196 | (-1024);
    }
    else
    {
        _12277 = _5196;
    }
    vec3 _5249 = vec3(float(_12273), float(_12275), float(_12277)) * 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 _12279;
    if (_5258 > 512)
    {
        _12279 = _5258 | (-1024);
    }
    else
    {
        _12279 = _5258;
    }
    int _12281;
    if (_5261 > 512)
    {
        _12281 = _5261 | (-1024);
    }
    else
    {
        _12281 = _5261;
    }
    int _12283;
    if (_5264 > 512)
    {
        _12283 = _5264 | (-1024);
    }
    else
    {
        _12283 = _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(_12279), float(_12281), float(_12283)) * 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 _12292;
    if (_6103 != 0.0)
    {
        _12292 = pow(abs(_6103), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.w);
    }
    else
    {
        _12292 = _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 * _12292;
    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 _6362 = vec3(in_windBranchData.y);
    vec3 _6363 = _6362 * vec3(0.0625, -1.0, 16.0);
    vec3 _6364 = fract(_6363);
    vec3 _6366 = _6364.xzy;
    vec3 _6367 = _6366 * 2.0;
    vec3 _6368 = _6367 - vec3(1.0);
    vec3 _6338 = _6368 * in_windBranchData.x;
    float _6437 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.x + in_windBranchData.y;
    float _6440 = 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 _6442 = _6440 + in_windBranchData.y;
    float _6444 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.y * 0.5;
    float _6448 = _6444 * _6437;
    vec4 _6449 = vec4(_6437, _6442, _6448, 0.0);
    vec4 _6588 = _6449 + vec4(0.5);
    vec4 _6589 = fract(_6588);
    vec4 _6590 = _6589 * 2.0;
    vec4 _6592 = _6590 - vec4(1.0);
    vec4 _6593 = abs(_6592);
    vec4 _6597 = _6593 * _6593;
    vec4 _6599 = _6593 * 2.0;
    vec4 _6601 = vec4(3.0) - _6599;
    vec4 _6602 = _6597 * _6601;
    vec4 _6583 = _6602 - vec4(0.5);
    vec4 _6584 = _6583 * 2.0;
    float _6474 = _6584.x;
    float _6476 = _6584.y;
    float _6478 = _6584.z;
    float _6479 = _6476 * _6478;
    bool _6482 = _6479 < 0.0;
    float _12306;
    if (_6482)
    {
        _12306 = -_6479;
    }
    else
    {
        _12306 = _6479;
    }
    float _12377 = _6482 ? (-1.0) : 1.0;
    float _6492 = mix(_6479, _12377, _12306);
    float _6496 = mix(_6492, _12377, _12306);
    float _6499 = _6496 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.x;
    float _6502 = 1.0 - g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.w;
    float _6503 = _6499 * _6502;
    float _6506 = 1.0 - g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.x;
    float _6507 = _6474 * _6506;
    float _6508 = _6503 + _6507;
    vec3 _6353 = _6338 * _6508;
    vec3 _6355 = _6353 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.y;
    vec3 _6357 = _5671 + _6355;
    vec3 _6673 = vec3(in_windBranchData.w);
    vec3 _6674 = _6673 * vec3(0.0625, -1.0, 16.0);
    vec3 _6675 = fract(_6674);
    vec3 _6677 = _6675.xzy;
    vec3 _6678 = _6677 * 2.0;
    vec3 _6679 = _6678 - vec3(1.0);
    vec3 _6649 = _6679 * in_windBranchData.z;
    float _6748 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.z + in_windBranchData.w;
    float _6751 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.z * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.w;
    float _6753 = _6751 + in_windBranchData.w;
    float _6755 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.w * 0.5;
    float _6759 = _6755 * _6748;
    vec4 _6760 = vec4(_6748, _6753, _6759, 0.0);
    vec4 _6899 = _6760 + vec4(0.5);
    vec4 _6900 = fract(_6899);
    vec4 _6901 = _6900 * 2.0;
    vec4 _6903 = _6901 - vec4(1.0);
    vec4 _6904 = abs(_6903);
    vec4 _6908 = _6904 * _6904;
    vec4 _6910 = _6904 * 2.0;
    vec4 _6912 = vec4(3.0) - _6910;
    vec4 _6913 = _6908 * _6912;
    vec4 _6894 = _6913 - vec4(0.5);
    vec4 _6895 = _6894 * 2.0;
    float _6785 = _6895.x;
    float _6787 = _6895.y;
    float _6789 = _6895.z;
    float _6790 = _6787 * _6789;
    bool _6793 = _6790 < 0.0;
    float _12319;
    if (_6793)
    {
        _12319 = -_6790;
    }
    else
    {
        _12319 = _6790;
    }
    float _12378 = _6793 ? (-1.0) : 1.0;
    float _6803 = mix(_6790, _12378, _12319);
    float _6807 = mix(_6803, _12378, _12319);
    float _6810 = _6807 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.z;
    float _6814 = _6810 * _6502;
    float _6817 = 1.0 - g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranchTwitch.z;
    float _6818 = _6785 * _6817;
    float _6819 = _6814 + _6818;
    vec3 _6664 = _6649 * _6819;
    vec3 _6666 = _6664 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindBranch.w;
    vec3 _6668 = _6357 + _6666;
    vec3 _5905 = _6668 - _5671;
    vec3 _12331;
    if (in_windExtraDataFlag.w > 0.0)
    {
        float _7813 = in_windExtraDataFlag.x * mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Ripple.z, 1.0, (dot(-normalize(in_LeafAnchorHint.xz), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xy) + 1.0) * 0.5);
        vec2 _7907 = (vec3(in_LeafAnchorHint.x, -in_LeafAnchorHint.z, _12272).xy - _6024) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
        vec2 _7955 = cos(_7907);
        float _7950 = abs(sin((((3.1415927410125732421875 * _7907.x) * _6048) + (_7907.y * _6048)) + (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_7955.x + _7955.y))));
        float _7917 = _7950 * _7950;
        float _7920 = _7917 * _7917;
        vec4 _8015 = 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 _8044 = (fract(vec3(in_windExtraDataFlag.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0);
        float _7859 = _7813 * mix(1.0, mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.y, 1.0, _7920), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
        vec3 _8079 = fract((vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z) + vec3(_5662)) * 30.299999237060546875);
        float _8087 = (_8079.x + _8079.y) + _8079.z;
        vec4 _8224 = abs((fract(vec4(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.x + _8087, (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.x * 0.75) - _8087, _12272, _12272) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _8215 = (((_8224 * _8224) * (vec4(3.0) - (_8224 * 2.0))) - vec4(0.5)) * 2.0;
        vec3 _8107 = (_5671 + ((((fract(vec3(in_windExtraDataFlag.z) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0)) * (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Ripple.y * ((((_8015 * _8015) * (vec4(3.0) - (_8015 * 2.0))) - vec4(0.5)) * 2.0).x)) * (_7813 * mix(1.0, mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.x, 1.0, _7920), 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 _8111 = _8215.x;
        float _8113 = _8215.y;
        float _8122 = (_7859 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.z) * (_8111 + (_8113 * _8113));
        float _8238 = sin(_8122);
        float _8241 = cos(_8122);
        float _8245 = 1.0 - _8241;
        float _8248 = _8044.x;
        float _8249 = _8245 * _8248;
        float _8261 = _8044.y;
        float _8262 = _8249 * _8261;
        float _8266 = _8044.z;
        float _8267 = _8238 * _8266;
        float _8275 = _8249 * _8266;
        float _8280 = _8238 * _8261;
        float _8298 = _8245 * _8261;
        float _8311 = _8298 * _8266;
        float _8316 = _8238 * _8248;
        vec3 _8128 = cross(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _8044);
        float _8133 = clamp(dot(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _8044), -1.0, 1.0);
        vec3 _12206 = _8128;
        _12206.y = _8128.y + _8133;
        vec3 _8140 = normalize(_12206);
        float _8157 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.z + _8087;
        vec4 _8409 = abs((fract(vec4(_8157 + (_5662 * _5662), (0.87000000476837158203125 * _8157) + _5662, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _8400 = (((_8409 * _8409) * (vec4(3.0) - (_8409 * 2.0))) - vec4(0.5)) * 2.0;
        float _8378 = _8400.y;
        float _8174 = _7859 * (((acos(_8133) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.w) + ((_8113 - (_8111 * _8111)) * 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((((_8400.x * _8378) * _8378) + 1.0) * 0.5, 0.0, 1.0), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.y)));
        float _8423 = sin(_8174);
        float _8426 = cos(_8174);
        float _8430 = 1.0 - _8426;
        float _8433 = _8140.x;
        float _8434 = _8430 * _8433;
        float _8446 = _8140.y;
        float _8447 = _8434 * _8446;
        float _8451 = _8140.z;
        float _8452 = _8423 * _8451;
        float _8460 = _8434 * _8451;
        float _8465 = _8423 * _8446;
        float _8483 = _8430 * _8446;
        float _8496 = _8483 * _8451;
        float _8501 = _8423 * _8433;
        _12331 = ((normalize((mat3(vec3((_8249 * _8248) + _8241, _8262 - _8267, _8275 + _8280), vec3(_8262 + _8267, (_8298 * _8261) + _8241, _8311 - _8316), vec3(_8275 - _8280, _8311 + _8316, ((_8245 * _8266) * _8266) + _8241)) * mat3(vec3((_8434 * _8433) + _8426, _8447 - _8452, _8460 + _8465), vec3(_8447 + _8452, (_8483 * _8446) + _8426, _8496 - _8501), vec3(_8460 - _8465, _8496 + _8501, ((_8430 * _8451) * _8451) + _8426))) * _8107) * length(_8107)) + vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z)) - _5671;
    }
    else
    {
        float _7004 = in_windExtraDataFlag.x * mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Ripple.z, 1.0, (dot(-normalize(in_LeafAnchorHint.xz), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xy) + 1.0) * 0.5);
        vec2 _7098 = (vec3(in_LeafAnchorHint.x, -in_LeafAnchorHint.z, _12272).xy - _6024) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
        vec2 _7146 = cos(_7098);
        float _7141 = abs(sin((((3.1415927410125732421875 * _7098.x) * _6048) + (_7098.y * _6048)) + (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_7146.x + _7146.y))));
        float _7108 = _7141 * _7141;
        float _7111 = _7108 * _7108;
        vec4 _7206 = 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 _7235 = (fract(vec3(in_windExtraDataFlag.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0);
        float _7050 = _7004 * mix(1.0, mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.y, 1.0, _7111), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
        vec3 _7270 = fract((vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z) + vec3(_5662)) * 30.299999237060546875);
        float _7278 = (_7270.x + _7270.y) + _7270.z;
        vec4 _7415 = abs((fract(vec4(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.x + _7278, (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.x * 0.75) - _7278, _12272, _12272) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _7406 = (((_7415 * _7415) * (vec4(3.0) - (_7415 * 2.0))) - vec4(0.5)) * 2.0;
        vec3 _7298 = (_5671 + ((((fract(vec3(in_windExtraDataFlag.z) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0)) * (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Ripple.y * ((((_7206 * _7206) * (vec4(3.0) - (_7206 * 2.0))) - vec4(0.5)) * 2.0).x)) * (_7004 * mix(1.0, mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.x, 1.0, _7111), 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 _7302 = _7406.x;
        float _7304 = _7406.y;
        float _7313 = (_7050 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.z) * (_7302 + (_7304 * _7304));
        float _7429 = sin(_7313);
        float _7432 = cos(_7313);
        float _7436 = 1.0 - _7432;
        float _7439 = _7235.x;
        float _7440 = _7436 * _7439;
        float _7452 = _7235.y;
        float _7453 = _7440 * _7452;
        float _7457 = _7235.z;
        float _7458 = _7429 * _7457;
        float _7466 = _7440 * _7457;
        float _7471 = _7429 * _7452;
        float _7489 = _7436 * _7452;
        float _7502 = _7489 * _7457;
        float _7507 = _7429 * _7439;
        vec3 _7319 = cross(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _7235);
        float _7324 = clamp(dot(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _7235), -1.0, 1.0);
        vec3 _12090 = _7319;
        _12090.y = _7319.y + _7324;
        vec3 _7331 = normalize(_12090);
        float _7348 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.z + _7278;
        vec4 _7600 = abs((fract(vec4(_7348 + (_5662 * _5662), (0.87000000476837158203125 * _7348) + _5662, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _7591 = (((_7600 * _7600) * (vec4(3.0) - (_7600 * 2.0))) - vec4(0.5)) * 2.0;
        float _7569 = _7591.y;
        float _7365 = _7050 * (((acos(_7324) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.w) + ((_7304 - (_7302 * _7302)) * 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((((_7591.x * _7569) * _7569) + 1.0) * 0.5, 0.0, 1.0), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.y)));
        float _7614 = sin(_7365);
        float _7617 = cos(_7365);
        float _7621 = 1.0 - _7617;
        float _7624 = _7331.x;
        float _7625 = _7621 * _7624;
        float _7637 = _7331.y;
        float _7638 = _7625 * _7637;
        float _7642 = _7331.z;
        float _7643 = _7614 * _7642;
        float _7651 = _7625 * _7642;
        float _7656 = _7614 * _7637;
        float _7674 = _7621 * _7637;
        float _7687 = _7674 * _7642;
        float _7692 = _7614 * _7624;
        _12331 = ((normalize((mat3(vec3((_7440 * _7439) + _7432, _7453 - _7458, _7466 + _7471), vec3(_7453 + _7458, (_7489 * _7452) + _7432, _7502 - _7507), vec3(_7466 - _7471, _7502 + _7507, ((_7436 * _7457) * _7457) + _7432)) * mat3(vec3((_7625 * _7624) + _7617, _7638 - _7643, _7651 + _7656), vec3(_7638 + _7643, (_7674 * _7637) + _7617, _7687 - _7692), vec3(_7651 - _7656, _7687 + _7692, ((_7621 * _7642) * _7642) + _7617))) * _7298) * length(_7298)) + vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z)) - _5671;
    }
    vec3 _5981 = _5884 + _5905;
    vec3 _5986 = _12331 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z;
    vec3 _5987 = _5981 + _5986;
    vec3 _5989 = _5671 + _5987;
    float _8595 = _5989.x;
    float _8596 = _5989.y;
    float _8597 = _5989.z;
    vec4 _8598 = vec4(_8595, _8596, _8597, 1.0);
    vec4 _8599 = _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView * _8598;
    vec4 _8618 = _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelViewProj * _8598;
    vec4 _12370;
    if (_3500.g_cbPass._uDepthClamp == 4294967295u)
    {
        float _8652 = _8618.w;
        vec4 _12371;
        if ((_8618.z / _8652) > 1.0)
        {
            vec4 _12372;
            if (_8599.z > _3500.g_cbPass._fNearPlane)
            {
                vec4 _12261 = _8618;
                _12261.z = _8652;
                _12372 = _12261;
            }
            else
            {
                _12372 = _8618;
            }
            _12371 = _12372;
        }
        else
        {
            _12371 = _8618;
        }
        _12370 = _12371;
    }
    else
    {
        _12370 = _8618;
    }
    interp_instanceID = float(_3243) + 0.5;
    float _5021 = _8599.x;
    float _5022 = _8599.y;
    float _5023 = _8599.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 = _8599.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 = _12370;
}

