
// 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 _12227;
float _12228;

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 _12229;
    if (_5190 > 512)
    {
        _12229 = _5190 | (-1024);
    }
    else
    {
        _12229 = _5190;
    }
    int _12231;
    if (_5193 > 512)
    {
        _12231 = _5193 | (-1024);
    }
    else
    {
        _12231 = _5193;
    }
    int _12233;
    if (_5196 > 512)
    {
        _12233 = _5196 | (-1024);
    }
    else
    {
        _12233 = _5196;
    }
    vec3 _5249 = vec3(float(_12229), float(_12231), float(_12233)) * 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 _12235;
    if (_5258 > 512)
    {
        _12235 = _5258 | (-1024);
    }
    else
    {
        _12235 = _5258;
    }
    int _12237;
    if (_5261 > 512)
    {
        _12237 = _5261 | (-1024);
    }
    else
    {
        _12237 = _5261;
    }
    int _12239;
    if (_5264 > 512)
    {
        _12239 = _5264 | (-1024);
    }
    else
    {
        _12239 = _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(_12235), float(_12237), float(_12239)) * 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 _12248;
    if (_6103 != 0.0)
    {
        _12248 = pow(abs(_6103), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindGlobal.w);
    }
    else
    {
        _12248 = _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 * _12248;
    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 _12262;
    if (_6482)
    {
        _12262 = -_6479;
    }
    else
    {
        _12262 = _6479;
    }
    float _12333 = _6482 ? (-1.0) : 1.0;
    float _6492 = mix(_6479, _12333, _12262);
    float _6496 = mix(_6492, _12333, _12262);
    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 _12275;
    if (_6793)
    {
        _12275 = -_6790;
    }
    else
    {
        _12275 = _6790;
    }
    float _12334 = _6793 ? (-1.0) : 1.0;
    float _6803 = mix(_6790, _12334, _12275);
    float _6807 = mix(_6803, _12334, _12275);
    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 _12287;
    if (in_windExtraDataFlag.w > 0.0)
    {
        vec2 _7865 = (vec3(in_LeafAnchorHint.x, -in_LeafAnchorHint.z, _12228).xy - _6024) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
        vec2 _7913 = cos(_7865);
        float _7908 = abs(sin((((3.1415927410125732421875 * _7865.x) * _6048) + (_7865.y * _6048)) + (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_7913.x + _7913.y))));
        float _7875 = _7908 * _7908;
        float _7878 = _7875 * _7875;
        vec4 _7973 = 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 _8002 = (fract(vec3(in_windExtraDataFlag.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0);
        float _7817 = in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.y, 1.0, _7878), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
        vec3 _8037 = fract((vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z) + vec3(_5662)) * 30.299999237060546875);
        float _8045 = (_8037.x + _8037.y) + _8037.z;
        vec4 _8182 = abs((fract(vec4(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.x + _8045, (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.x * 0.75) - _8045, _12228, _12228) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _8173 = (((_8182 * _8182) * (vec4(3.0) - (_8182 * 2.0))) - vec4(0.5)) * 2.0;
        vec3 _8065 = (_5671 + ((_5249 * (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Ripple.y * ((((_7973 * _7973) * (vec4(3.0) - (_7973 * 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, _7878), 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 _8069 = _8173.x;
        float _8071 = _8173.y;
        float _8080 = (_7817 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.z) * (_8069 + (_8071 * _8071));
        float _8196 = sin(_8080);
        float _8199 = cos(_8080);
        float _8203 = 1.0 - _8199;
        float _8206 = _8002.x;
        float _8207 = _8203 * _8206;
        float _8219 = _8002.y;
        float _8220 = _8207 * _8219;
        float _8224 = _8002.z;
        float _8225 = _8196 * _8224;
        float _8233 = _8207 * _8224;
        float _8238 = _8196 * _8219;
        float _8256 = _8203 * _8219;
        float _8269 = _8256 * _8224;
        float _8274 = _8196 * _8206;
        vec3 _8086 = cross(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _8002);
        float _8091 = clamp(dot(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _8002), -1.0, 1.0);
        vec3 _12162 = _8086;
        _12162.y = _8086.y + _8091;
        vec3 _8098 = normalize(_12162);
        float _8115 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.z + _8045;
        vec4 _8367 = abs((fract(vec4(_8115 + (_5662 * _5662), (0.87000000476837158203125 * _8115) + _5662, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _8358 = (((_8367 * _8367) * (vec4(3.0) - (_8367 * 2.0))) - vec4(0.5)) * 2.0;
        float _8336 = _8358.y;
        float _8132 = _7817 * (((acos(_8091) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Tumble.w) + ((_8071 - (_8069 * _8069)) * 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((((_8358.x * _8336) * _8336) + 1.0) * 0.5, 0.0, 1.0), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf2Twitch.y)));
        float _8381 = sin(_8132);
        float _8384 = cos(_8132);
        float _8388 = 1.0 - _8384;
        float _8391 = _8098.x;
        float _8392 = _8388 * _8391;
        float _8404 = _8098.y;
        float _8405 = _8392 * _8404;
        float _8409 = _8098.z;
        float _8410 = _8381 * _8409;
        float _8418 = _8392 * _8409;
        float _8423 = _8381 * _8404;
        float _8441 = _8388 * _8404;
        float _8454 = _8441 * _8409;
        float _8459 = _8381 * _8391;
        _12287 = ((normalize((mat3(vec3((_8207 * _8206) + _8199, _8220 - _8225, _8233 + _8238), vec3(_8220 + _8225, (_8256 * _8219) + _8199, _8269 - _8274), vec3(_8233 - _8238, _8269 + _8274, ((_8203 * _8224) * _8224) + _8199)) * mat3(vec3((_8392 * _8391) + _8384, _8405 - _8410, _8418 + _8423), vec3(_8405 + _8410, (_8441 * _8404) + _8384, _8454 - _8459), vec3(_8418 - _8423, _8454 + _8459, ((_8388 * _8409) * _8409) + _8384))) * _8065) * length(_8065)) + vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z)) - _5671;
    }
    else
    {
        vec2 _7077 = (vec3(in_LeafAnchorHint.x, -in_LeafAnchorHint.z, _12228).xy - _6024) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.y;
        vec2 _7125 = cos(_7077);
        float _7120 = abs(sin((((3.1415927410125732421875 * _7077.x) * _6048) + (_7077.y * _6048)) + (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingNoise.w * (_7125.x + _7125.y))));
        float _7087 = _7120 * _7120;
        float _7090 = _7087 * _7087;
        vec4 _7185 = 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 _7214 = (fract(vec3(in_windExtraDataFlag.y) * vec3(0.0625, -1.0, 16.0)).xzy * 2.0) - vec3(1.0);
        float _7029 = in_windExtraDataFlag.x * mix(1.0, mix(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vRollingLeafOffset.y, 1.0, _7090), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z);
        vec3 _7249 = fract((vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z) + vec3(_5662)) * 30.299999237060546875);
        float _7257 = (_7249.x + _7249.y) + _7249.z;
        vec4 _7394 = abs((fract(vec4(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.x + _7257, (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.x * 0.75) - _7257, _12228, _12228) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _7385 = (((_7394 * _7394) * (vec4(3.0) - (_7394 * 2.0))) - vec4(0.5)) * 2.0;
        vec3 _7277 = (_5671 + ((_5249 * (g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Ripple.y * ((((_7185 * _7185) * (vec4(3.0) - (_7185 * 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, _7090), 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 _7281 = _7385.x;
        float _7283 = _7385.y;
        float _7292 = (_7029 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.z) * (_7281 + (_7283 * _7283));
        float _7408 = sin(_7292);
        float _7411 = cos(_7292);
        float _7415 = 1.0 - _7411;
        float _7418 = _7214.x;
        float _7419 = _7415 * _7418;
        float _7431 = _7214.y;
        float _7432 = _7419 * _7431;
        float _7436 = _7214.z;
        float _7437 = _7408 * _7436;
        float _7445 = _7419 * _7436;
        float _7450 = _7408 * _7431;
        float _7468 = _7415 * _7431;
        float _7481 = _7468 * _7436;
        float _7486 = _7408 * _7418;
        vec3 _7298 = cross(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _7214);
        float _7303 = clamp(dot(g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindVector.xyz, _7214), -1.0, 1.0);
        vec3 _12047 = _7298;
        _12047.y = _7298.y + _7303;
        vec3 _7310 = normalize(_12047);
        float _7327 = g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.z + _7257;
        vec4 _7579 = abs((fract(vec4(_7327 + (_5662 * _5662), (0.87000000476837158203125 * _7327) + _5662, 0.0, 0.0) + vec4(0.5)) * 2.0) - vec4(1.0));
        vec4 _7570 = (((_7579 * _7579) * (vec4(3.0) - (_7579 * 2.0))) - vec4(0.5)) * 2.0;
        float _7548 = _7570.y;
        float _7344 = _7029 * (((acos(_7303) * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Tumble.w) + ((_7283 - (_7281 * _7281)) * 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((((_7570.x * _7548) * _7548) + 1.0) * 0.5, 0.0, 1.0), g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vWindLeaf1Twitch.y)));
        float _7593 = sin(_7344);
        float _7596 = cos(_7344);
        float _7600 = 1.0 - _7596;
        float _7603 = _7310.x;
        float _7604 = _7600 * _7603;
        float _7616 = _7310.y;
        float _7617 = _7604 * _7616;
        float _7621 = _7310.z;
        float _7622 = _7593 * _7621;
        float _7630 = _7604 * _7621;
        float _7635 = _7593 * _7616;
        float _7653 = _7600 * _7616;
        float _7666 = _7653 * _7621;
        float _7671 = _7593 * _7603;
        _12287 = ((normalize((mat3(vec3((_7419 * _7418) + _7411, _7432 - _7437, _7445 + _7450), vec3(_7432 + _7437, (_7468 * _7431) + _7411, _7481 - _7486), vec3(_7445 - _7450, _7481 + _7486, ((_7415 * _7436) * _7436) + _7411)) * mat3(vec3((_7604 * _7603) + _7596, _7617 - _7622, _7630 + _7635), vec3(_7617 + _7622, (_7653 * _7616) + _7596, _7666 - _7671), vec3(_7630 - _7635, _7666 + _7671, ((_7600 * _7621) * _7621) + _7596))) * _7277) * length(_7277)) + vec3(in_LeafAnchorHint.x, in_LeafAnchorHint.y, in_LeafAnchorHint.z)) - _5671;
    }
    vec3 _5981 = _5884 + _5905;
    vec3 _5986 = _12287 * g_rbObjects_Buffer[_3253.g_cbMainArray._aMain[_3244]._Indices._uiObjectIndex].g_rbObjects[0]._vTreeRotation.z;
    vec3 _5987 = _5981 + _5986;
    vec3 _5989 = _5671 + _5987;
    float _8553 = _5989.x;
    float _8554 = _5989.y;
    float _8555 = _5989.z;
    vec4 _8556 = vec4(_8553, _8554, _8555, 1.0);
    vec4 _8557 = _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelView * _8556;
    vec4 _8576 = _426.g_rbMatrices[_3253.g_cbMainArray._aMain[_3244]._Indices._uiMatricesIndex]._mModelViewProj * _8556;
    vec4 _12326;
    if (_3500.g_cbPass._uDepthClamp == 4294967295u)
    {
        float _8610 = _8576.w;
        vec4 _12327;
        if ((_8576.z / _8610) > 1.0)
        {
            vec4 _12328;
            if (_8557.z > _3500.g_cbPass._fNearPlane)
            {
                vec4 _12217 = _8576;
                _12217.z = _8610;
                _12328 = _12217;
            }
            else
            {
                _12328 = _8576;
            }
            _12327 = _12328;
        }
        else
        {
            _12327 = _8576;
        }
        _12326 = _12327;
    }
    else
    {
        _12326 = _8576;
    }
    interp_instanceID = float(_3243) + 0.5;
    float _5021 = _8557.x;
    float _5022 = _8557.y;
    float _5023 = _8557.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 = _8557.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 = _12326;
}

