
// 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_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];
    float _fLocalExposureCompensation;
    float _fLocalExposureCompensationEV100;
};

struct S_MATERIAL
{
    vec4 _vErrorColor;
    float _fDepthBias;
    float _fDummy0;
    float _fDummy1;
    float _fDummy2;
    float c0;
    float c1;
    float c2;
    float c3;
    float c4;
    float c5;
    float c6;
    float c7;
    float c8;
    float c9;
    float c10;
    float c11;
    float c12;
    float c13;
    float c14;
    float c15;
    uint s0;
    uint s1;
    uint s2;
    uint s3;
};

struct S_MATERIAL_INSTANCE
{
    float c0;
    float c1;
    float c2;
    float c3;
    float c4;
    float c5;
    float c6;
    float c7;
    float _fGloubiboulga;
};

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[];
} _165;

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

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

layout(set = 1, binding = 34, std430) readonly buffer g_rbMaterials_Layout
{
    S_MATERIAL g_rbMaterials[];
} g_rbMaterials_Buffer[];

layout(set = 1, binding = 35, std430) readonly buffer g_rbMaterialInstances_Layout
{
    S_MATERIAL_INSTANCE g_rbMaterialInstances[];
} g_rbMaterialInstances_Buffer[];

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

layout(location = 3) in vec4 in_color;
layout(location = 8) in vec2 in_uv0;
layout(location = 8) out vec2 interp_uv0;
layout(location = 21) out vec3 interp_vfVsPosition;
layout(location = 14) out vec3 interp_vfVsTangent;
layout(location = 15) out vec3 interp_vfVsBinormal;
layout(location = 13) out vec3 interp_vfVsNormal;
layout(location = 23) out float interp_instanceID;

float _11116;
vec3 _11140;

void main()
{
    int _2530 = gl_InstanceIndex + gl_DrawIDARB;
    int _2531 = readFirstInvocationARB(_2530);
    uint _4480 = uint(gl_VertexIndex);
    uint _4483 = _4480 + _2540.g_cbMainArray._aMain[_2531]._Indices._uiPositionOffset;
    vec4 _4496 = vec4(g_rbVertices_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiPositionsBufferIndex].g_rbVertices[_4483].x, g_rbVertices_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiPositionsBufferIndex].g_rbVertices[_4483].y, g_rbVertices_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiPositionsBufferIndex].g_rbVertices[_4483].z, 1.0);
    uint _4503 = _4480 + _2540.g_cbMainArray._aMain[_2531]._Indices._uiNormalOffset;
    int _4532 = g_rbTBNs_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiNormalsBufferIndex].g_rbTBNs[_4503]._iNormal & 1023;
    int _4535 = (g_rbTBNs_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiNormalsBufferIndex].g_rbTBNs[_4503]._iNormal >> 10) & 1023;
    int _4538 = (g_rbTBNs_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiNormalsBufferIndex].g_rbTBNs[_4503]._iNormal >> 20) & 1023;
    int _11118;
    if (_4532 > 512)
    {
        _11118 = _4532 | (-1024);
    }
    else
    {
        _11118 = _4532;
    }
    int _11120;
    if (_4535 > 512)
    {
        _11120 = _4535 | (-1024);
    }
    else
    {
        _11120 = _4535;
    }
    int _11122;
    if (_4538 > 512)
    {
        _11122 = _4538 | (-1024);
    }
    else
    {
        _11122 = _4538;
    }
    vec3 _4591 = vec3(float(_11118), float(_11120), float(_11122)) * vec3(0.001956947147846221923828125);
    int _4600 = g_rbTBNs_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiNormalsBufferIndex].g_rbTBNs[_4503]._iTangent & 1023;
    int _4603 = (g_rbTBNs_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiNormalsBufferIndex].g_rbTBNs[_4503]._iTangent >> 10) & 1023;
    int _4606 = (g_rbTBNs_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiNormalsBufferIndex].g_rbTBNs[_4503]._iTangent >> 20) & 1023;
    int _11124;
    if (_4600 > 512)
    {
        _11124 = _4600 | (-1024);
    }
    else
    {
        _11124 = _4600;
    }
    int _11126;
    if (_4603 > 512)
    {
        _11126 = _4603 | (-1024);
    }
    else
    {
        _11126 = _4603;
    }
    int _11128;
    if (_4606 > 512)
    {
        _11128 = _4606 | (-1024);
    }
    else
    {
        _11128 = _4606;
    }
    float _4664 = float((g_rbTBNs_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiNormalsBufferIndex].g_rbTBNs[_4503]._iTangent >> 30) != 0);
    vec3 _4681 = _4496.xyz;
    vec4 _4717 = g_rbObjects_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiObjectIndex].g_rbObjects[0]._mModel * _4496;
    vec3 _4718 = _4717.xyz;
    vec3 _4789 = vec4(vec3(float(_11124), float(_11126), float(_11128)) * vec3(0.001956947147846221923828125), _4664).xyz;
    vec3 _5306 = _4681 * 1.0;
    vec4 _5339 = vec4(g_rbMaterialInstances_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMaterialInstanceIndex].g_rbMaterialInstances[0].c0, g_rbMaterialInstances_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMaterialInstanceIndex].g_rbMaterialInstances[0].c1, g_rbMaterialInstances_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMaterialInstanceIndex].g_rbMaterialInstances[0].c2, 1.0);
    vec4 _5340 = g_rbObjects_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiObjectIndex].g_rbObjects[0]._mInvModel * _5339;
    vec3 _5341 = _5340.xyz;
    vec3 _5353 = _5306 + in_color.xyz;
    vec3 _5357 = _5341 - _5353;
    vec3 _5361 = cross(_5357, vec3(0.0, 1.0, 0.0));
    vec3 _5368 = normalize(_5361);
    float _5373 = length(_5357);
    float _5384 = _5373 * 0.999989986419677734375;
    float _5385 = clamp(_5384, 0.0, 1.0);
    float _5387 = pow(_5385, 0.5);
    float _5388 = mix(1.0, 0.0, _5387);
    vec3 _10881 = _11140;
    _10881.x = _5388;
    vec3 _10883 = _11140;
    _10883.x = mix(0.0, 1.0, pow(clamp((_5373 - 0.4000000059604644775390625) * 1.66663873195648193359375, 0.0, 1.0), 2.0));
    vec3 _10885 = _11140;
    _10885.x = mix(1.0, 0.0, pow(clamp((_5373 - 1.0) * 0.999989986419677734375, 0.0, 1.0), 0.5));
    vec3 _10888 = _11140;
    _10888.x = (_10883 * _10885).x;
    vec3 _10891 = _11140;
    _10891.x = (_10888 * vec3(-0.25, 0.0, 0.0)).x;
    vec3 _10894 = _11140;
    _10894.x = (_10881 + _10891).x;
    vec3 _5445 = _10894 * vec3(0.25, 0.0, 0.0);
    float _5447 = _5445.x;
    float _5449 = cos(_5447);
    float _5451 = sin(_5447);
    float _5453 = 1.0 - _5449;
    float _5456 = _5368.x;
    float _5457 = _5453 * _5456;
    float _5460 = _5457 * _5456;
    float _5462 = _5460 + _5449;
    float _5468 = _5368.y;
    float _5469 = _5457 * _5468;
    float _5471 = _5368.z;
    float _5473 = _5471 * _5451;
    float _5474 = _5469 + _5473;
    float _5481 = _5457 * _5471;
    float _5485 = _5468 * _5451;
    float _5486 = _5481 - _5485;
    float _5498 = _5469 - _5473;
    float _5502 = _5453 * _5468;
    float _5505 = _5502 * _5468;
    float _5507 = _5505 + _5449;
    float _5514 = _5502 * _5471;
    float _5518 = _5456 * _5451;
    float _5519 = _5514 + _5518;
    float _5531 = _5481 + _5485;
    float _5543 = _5514 - _5518;
    float _5547 = _5453 * _5471;
    float _5550 = _5547 * _5471;
    float _5552 = _5550 + _5449;
    float _5554 = _5353.x;
    float _5556 = _5353.y;
    float _5558 = _5353.z;
    vec4 _5559 = vec4(_5462, _5474, _5486, 0.0);
    vec4 _5560 = vec4(_5498, _5507, _5519, 0.0);
    vec4 _5561 = vec4(_5531, _5543, _5552, 0.0);
    vec4 _5562 = vec4(_5554, _5556, _5558, 1.0);
    mat4 _5563 = mat4(_5559, _5560, _5561, _5562);
    vec3 _5567 = _5306 - _5353;
    float _5568 = _5567.x;
    float _5569 = _5567.y;
    float _5570 = _5567.z;
    vec4 _5571 = vec4(_5568, _5569, _5570, 1.0);
    vec4 _5572 = _5563 * _5571;
    vec3 _5573 = _5572.xyz;
    vec3 _5702 = _5573 - _5306;
    float _5708 = length(in_color.xyz);
    float _5714 = _5708 - 0.100000001490116119384765625;
    float _5719 = _5714 * 0.526313006877899169921875;
    float _5720 = clamp(_5719, 0.0, 1.0);
    float _5722 = pow(_5720, 2.0);
    float _5723 = mix(0.0, 3.0, _5722);
    vec3 _5725 = vec3(_5723);
    vec3 _5729 = _5357 * vec3(-1.0);
    vec3 _5732 = vec3(_5388);
    vec3 _5735 = _5729 * _5732;
    vec3 _5739 = _5725 * _5735;
    vec3 _5743 = _5702 + _5739;
    float _5750 = _5373 - 0.100000001490116119384765625;
    float _5755 = _5750 * 2.4999372959136962890625;
    float _5756 = clamp(_5755, 0.0, 1.0);
    float _5758 = pow(_5756, 0.100000001490116119384765625);
    float _5759 = mix(0.89999997615814208984375, 1.0, _5758);
    vec3 _5774 = in_color.xyz + _5306;
    vec3 _5778 = in_color.xyz + _5774;
    vec3 _5783 = _5778 - _5306;
    vec3 _5788 = vec3(_5759);
    vec3 _5789 = mix(_5783, _5743, _5788);
    vec4 _5827 = vec4(g_rbMaterialInstances_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMaterialInstanceIndex].g_rbMaterialInstances[0].c3, g_rbMaterialInstances_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMaterialInstanceIndex].g_rbMaterialInstances[0].c4, g_rbMaterialInstances_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMaterialInstanceIndex].g_rbMaterialInstances[0].c5, 1.0);
    vec4 _5828 = g_rbObjects_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiObjectIndex].g_rbObjects[0]._mInvModel * _5827;
    vec3 _5829 = _5828.xyz;
    vec3 _5845 = _5829 - _5353;
    vec3 _5849 = cross(_5845, vec3(0.0, 1.0, 0.0));
    vec3 _5856 = normalize(_5849);
    float _5861 = length(_5845);
    float _5872 = _5861 * 0.999989986419677734375;
    float _5873 = clamp(_5872, 0.0, 1.0);
    float _5875 = pow(_5873, 0.5);
    float _5876 = mix(1.0, 0.0, _5875);
    vec3 _10957 = _11140;
    _10957.x = _5876;
    vec3 _10959 = _11140;
    _10959.x = mix(0.0, 1.0, pow(clamp((_5861 - 0.4000000059604644775390625) * 1.66663873195648193359375, 0.0, 1.0), 2.0));
    vec3 _10961 = _11140;
    _10961.x = mix(1.0, 0.0, pow(clamp((_5861 - 1.0) * 0.999989986419677734375, 0.0, 1.0), 0.5));
    vec3 _10964 = _11140;
    _10964.x = (_10959 * _10961).x;
    vec3 _10967 = _11140;
    _10967.x = (_10964 * vec3(-0.25, 0.0, 0.0)).x;
    vec3 _10970 = _11140;
    _10970.x = (_10957 + _10967).x;
    vec3 _5933 = _10970 * vec3(0.25, 0.0, 0.0);
    float _5935 = _5933.x;
    float _5937 = cos(_5935);
    float _5939 = sin(_5935);
    float _5941 = 1.0 - _5937;
    float _5944 = _5856.x;
    float _5945 = _5941 * _5944;
    float _5948 = _5945 * _5944;
    float _5950 = _5948 + _5937;
    float _5956 = _5856.y;
    float _5957 = _5945 * _5956;
    float _5959 = _5856.z;
    float _5961 = _5959 * _5939;
    float _5962 = _5957 + _5961;
    float _5969 = _5945 * _5959;
    float _5973 = _5956 * _5939;
    float _5974 = _5969 - _5973;
    float _5986 = _5957 - _5961;
    float _5990 = _5941 * _5956;
    float _5993 = _5990 * _5956;
    float _5995 = _5993 + _5937;
    float _6002 = _5990 * _5959;
    float _6006 = _5944 * _5939;
    float _6007 = _6002 + _6006;
    float _6019 = _5969 + _5973;
    float _6031 = _6002 - _6006;
    float _6035 = _5941 * _5959;
    float _6038 = _6035 * _5959;
    float _6040 = _6038 + _5937;
    vec4 _6047 = vec4(_5950, _5962, _5974, 0.0);
    vec4 _6048 = vec4(_5986, _5995, _6007, 0.0);
    vec4 _6049 = vec4(_6019, _6031, _6040, 0.0);
    mat4 _6051 = mat4(_6047, _6048, _6049, _5562);
    vec4 _6060 = _6051 * _5571;
    vec3 _6061 = _6060.xyz;
    vec3 _6190 = _6061 - _5306;
    vec3 _6217 = _5845 * vec3(-1.0);
    vec3 _6220 = vec3(_5876);
    vec3 _6223 = _6217 * _6220;
    vec3 _6227 = _5725 * _6223;
    vec3 _6231 = _6190 + _6227;
    float _6238 = _5861 - 0.100000001490116119384765625;
    float _6243 = _6238 * 2.4999372959136962890625;
    float _6244 = clamp(_6243, 0.0, 1.0);
    float _6246 = pow(_6244, 0.100000001490116119384765625);
    float _6247 = mix(0.89999997615814208984375, 1.0, _6246);
    vec3 _6276 = vec3(_6247);
    vec3 _6277 = mix(_5783, _6231, _6276);
    vec3 _6281 = _5789 + _6277;
    vec3 _11027 = vec3(_11116);
    _11027.x = g_rbMaterials_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMaterialIndex].g_rbMaterials[0].c9;
    vec3 _11029 = _11027;
    _11029.y = g_rbMaterials_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMaterialIndex].g_rbMaterials[0].c10;
    vec3 _11031 = _11029;
    _11031.z = g_rbMaterials_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMaterialIndex].g_rbMaterials[0].c11;
    vec3 _6314 = normalize(_11031);
    vec3 _6331 = vec3(g_rbMaterials_Buffer[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMaterialIndex].g_rbMaterials[0].c12);
    vec3 _6335 = _4718 * 1.0;
    vec3 _6339 = _6335 * vec3(3.0, 1.0, 3.0);
    vec3 _6343 = _6331 + _6339;
    vec3 _6346 = cos(_6343);
    vec3 _6354 = _6346 * vec3(0.062799997627735137939453125, 0.0, 0.0);
    float _6356 = _6354.x;
    float _6358 = cos(_6356);
    float _6360 = sin(_6356);
    float _6362 = 1.0 - _6358;
    float _6365 = _6314.x;
    float _6366 = _6362 * _6365;
    float _6369 = _6366 * _6365;
    float _6371 = _6369 + _6358;
    float _6377 = _6314.y;
    float _6378 = _6366 * _6377;
    float _6380 = _6314.z;
    float _6382 = _6380 * _6360;
    float _6383 = _6378 + _6382;
    float _6390 = _6366 * _6380;
    float _6394 = _6377 * _6360;
    float _6395 = _6390 - _6394;
    float _6407 = _6378 - _6382;
    float _6411 = _6362 * _6377;
    float _6414 = _6411 * _6377;
    float _6416 = _6414 + _6358;
    float _6423 = _6411 * _6380;
    float _6427 = _6365 * _6360;
    float _6428 = _6423 + _6427;
    float _6440 = _6390 + _6394;
    float _6452 = _6423 - _6427;
    float _6456 = _6362 * _6380;
    float _6459 = _6456 * _6380;
    float _6461 = _6459 + _6358;
    vec4 _6468 = vec4(_6371, _6383, _6395, 0.0);
    vec4 _6469 = vec4(_6407, _6416, _6428, 0.0);
    vec4 _6470 = vec4(_6440, _6452, _6461, 0.0);
    mat4 _6472 = mat4(_6468, _6469, _6470, _5562);
    vec4 _6481 = _6472 * _5571;
    vec3 _6482 = _6481.xyz;
    vec3 _6611 = _6482 - _5306;
    float _6628 = _5708 * 0.49999749660491943359375;
    float _6629 = clamp(_6628, 0.0, 1.0);
    float _6631 = pow(_6629, 2.0);
    float _6632 = mix(0.0, 2.0, _6631);
    vec3 _6634 = vec3(_6632);
    vec3 _6639 = _6314 * _6354;
    vec3 _6643 = _6634 * _6639;
    vec3 _6647 = _6611 + _6643;
    vec3 _6657 = _6281 + _6647;
    vec3 _6681 = _4681 + _6657;
    float _6807 = _6681.x;
    float _6808 = _6681.y;
    float _6809 = _6681.z;
    vec4 _6810 = vec4(_6807, _6808, _6809, 1.0);
    vec4 _6811 = _165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelView * _6810;
    vec4 _6830 = _165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelViewProj * _6810;
    vec4 _11137;
    if (_2816.g_cbPass._uDepthClamp == 4294967295u)
    {
        float _6864 = _6830.w;
        vec4 _11138;
        if ((_6830.z / _6864) > 1.0)
        {
            vec4 _11139;
            if (_6811.z > _2816.g_cbPass._fNearPlane)
            {
                vec4 _11094 = _6830;
                _11094.z = _6864;
                _11139 = _11094;
            }
            else
            {
                _11139 = _6830;
            }
            _11138 = _11139;
        }
        else
        {
            _11138 = _6830;
        }
        _11137 = _11138;
    }
    else
    {
        _11137 = _6830;
    }
    interp_instanceID = float(_2530) + 0.5;
    float _4363 = _6811.x;
    float _4364 = _6811.y;
    float _4365 = _6811.z;
    vec4 _4366 = vec4(_4363, _4364, _4365, 1.0);
    float _4367 = dot(_2816.g_cbPass._vfVsClippingPlane[0], _4366);
    float _4368 = -_4367;
    gl_ClipDistance[0] = _4368;
    interp_uv0 = in_uv0;
    interp_vfVsPosition = _6811.xyz;
    interp_vfVsTangent = mat3(_165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelView[0].xyz, _165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelView[1].xyz, _165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelView[2].xyz) * _4789;
    interp_vfVsBinormal = mat3(_165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelView[0].xyz, _165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelView[1].xyz, _165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelView[2].xyz) * (cross(_4591, _4789) * ((_4664 != 0.0) ? (-1.0) : 1.0));
    interp_vfVsNormal = mat3(_165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelView[0].xyz, _165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelView[1].xyz, _165.g_rbMatrices[_2540.g_cbMainArray._aMain[_2531]._Indices._uiMatricesIndex]._mModelView[2].xyz) * _4591;
    gl_Position = _11137;
}

