#version 450
layout(early_fragment_tests) in;

// Vk3DVision (http://3dsurroundgaming.com/) - Stereo Injection
layout(set = 0, binding = 30, std140) uniform Vk3DParams
{
    vec4 stereo;
    vec4 custom_params;
} vk3d_params;

struct lightingInput_t
{
    vec3 albedo;
    vec3 colorMask;
    vec3 specular;
    float smoothness;
    float maskSSS;
    float thickness;
    vec3 normal;
    vec3 normalTS;
    vec3 normalSSS;
    vec3 lightmap;
    vec3 emissive;
    float alpha;
    float ssdoDiffuseMul;
    vec3 view;
    vec3 position;
    vec4 texCoords;
    vec4 fragCoord;
    mat3 invTS;
    vec3 ambient_lighting;
    vec3 diffuse_lighting;
    vec3 specular_lighting;
    vec3 output_lighting;
    uint albedo_packed;
    uint specular_packed;
    uint diffuse_lighting_packed;
    uint specular_lighting_packed;
    uint normal_packed;
    uvec4 ticksDecals;
    uvec4 ticksProbes;
    uvec4 ticksLights;
};

struct clusternumlights_t
{
    int offset;
    int numItems;
};

struct light_t
{
    vec3 pos;
    uint lightParms;
    vec4 posShadow;
    vec4 falloffR;
    vec4 projS;
    vec4 projT;
    vec4 projQ;
    uvec4 scaleBias;
    vec4 boxMin;
    vec4 boxMax;
    vec4 areaPlane;
    uint lightParms2;
    uint colorPacked;
    float specMultiplier;
    float shadowBleedReduce;
};

struct shadowparms_t
{
    vec4 shadowLightS;
    vec4 shadowLightT;
    vec4 shadowLightR;
    vec4 shadowLightQ;
    vec4 shadowAtlasScaleBias;
};

layout(set = 0, binding = 6, std140) uniform freqLow_fragmentUniforms_ubo
{
    vec4 globalvieworigin;
    vec4 vmtrfeedbackfloat;
    vec4 virtualtextureoptions;
    vec4 vmtrphysicalpagesaspectratio;
    vec4 resolutionscale;
    vec4 projectionmatrixz;
    vec4 clusteredlighting;
    vec4 envirradiancescale;
    vec4 pbrdebugparms;
    vec4 parallellightslicescale;
    vec4 shadowatlasresolution;
    vec4 time;
    vec4 rendermode;
    vec4 highlightcolor;
} freqLow_fragmentUniforms;

layout(set = 0, binding = 5, std140) uniform freqHigh_fragmentUniforms_ubo
{
    vec4 usevirtualmapping;
    vec4 virtualmapping;
    vec4 physicalfilterparms;
    vec4 positiontoviewtexture;
    vec4 sssblurradius;
    vec4 sssmaskscale;
    vec4 packedspec;
    vec4 ssdodiffuseocclusionmultiplier;
    vec4 bloommaskscale;
    vec4 colorscale;
    vec4 color;
    vec4 bloomcolor;
    vec4 bloodcolorlerp;
    vec4 bloodcolor;
    vec4 staticmodel;
    vec4 sssblurscale;
    vec4 ssscattering;
    vec4 pulseparms;
    vec4 renderpositiontoviewtexture;
    vec4 pulsefreq;
    vec4 pulseinfo;
    vec4 pulsecolor;
    vec4 hdrcolorfilter;
    vec4 bfgdeathexplosion;
    vec4 siphondamage;
    vec4 deathfadeopacity;
    vec4 tiling;
} freqHigh_fragmentUniforms;

layout(set = 0, binding = 20, std430) restrict readonly buffer clusternumlights_b
{
    clusternumlights_t clusternumlights[];
} _2526;

layout(set = 0, binding = 21, std430) restrict readonly buffer clusterlightsid_b
{
    uint clusterlightsid[];
} _2783;

layout(set = 0, binding = 7, std140) uniform lightparms1_ubo
{
    vec4 lightparms1[4096];
} _2811;

layout(set = 0, binding = 8, std140) uniform lightparms2_ubo
{
    vec4 lightparms2[4096];
} _2850;

layout(set = 0, binding = 9, std140) uniform lightparms3_ubo
{
    vec4 lightparms3[4096];
} _2918;

layout(set = 0, binding = 10, std140) uniform shadowsparmsubo_ubo
{
    vec4 shadowsparmsubo[4095];
} _3249;

layout(set = 0, binding = 11) uniform sampler2D samp_vmtrpagetablemap;
layout(set = 0, binding = 12) uniform sampler2D samp_vmtrphysicalmappingsmap;
layout(set = 0, binding = 13) uniform sampler2DArray samp_vmtrphysicalpagesmaparray0;
layout(set = 0, binding = 14) uniform sampler2D samp_vmtrphysicalpagesmap3;
layout(set = 0, binding = 22, r32f) uniform writeonly image2D ib_feedbackbuffer;
layout(set = 0, binding = 15) uniform sampler2D samp_woundtexture;
layout(set = 0, binding = 16) uniform sampler2D samp_lightsatlasmap;
layout(set = 0, binding = 17) uniform sampler2DShadow samp_shadowatlasdepthcomparemap;
layout(set = 0, binding = 18) uniform sampler2D samp_echodithermap;
layout(set = 0, binding = 19) uniform sampler2D samp_magnificationclouds;

layout(location = 2) in vec4 vofi_TexCoord0;
layout(location = 6) in vec4 vofi_TexCoord4;
layout(location = 3) in vec4 vofi_TexCoord1;
layout(location = 4) in vec4 vofi_TexCoord2;
layout(location = 5) in vec4 vofi_TexCoord3;
layout(location = 9) in vec4 vofi_TexCoord7;
layout(location = 8) in vec4 vofi_TexCoord6;
layout(location = 10) in vec4 vofi_TexCoord8;
layout(location = 11) in vec4 vofi_TexCoord9;
layout(location = 12) in vec4 vofi_TexCoord10;
layout(location = 0) out vec4 out_FragColor0;
layout(location = 1) out vec4 out_FragColor1;
layout(location = 2) out vec4 out_FragColor2;

float _414;

float dot2(vec2 a, vec2 b)
{
    return dot(a, b);
}

vec4 tex2Dlod(sampler2D image, vec4 texcoord)
{
    return textureLod(image, texcoord.xy, texcoord.w);
}

vec4 tex2D(sampler2D image, vec2 texcoord)
{
    return texture(image, texcoord);
}

vec4 tex2DARRAY(sampler2DArray image, vec3 texcoord, vec2 dx, vec2 dy)
{
    return textureGrad(image, texcoord, dx, dy);
}

vec4 tex2DArrayGrad(sampler2DArray image, float slice, vec2 texcoord, vec2 dx, vec2 dy)
{
    vec3 param = vec3(texcoord, slice);
    vec2 param_1 = dx;
    vec2 param_2 = dy;
    return tex2DARRAY(image, param, param_1, param_2);
}

vec4 texPhysArray(sampler2DArray image, float slice, vec2 texcoord, vec2 dx, vec2 dy)
{
    float param = slice;
    vec2 param_1 = texcoord;
    vec2 param_2 = dx;
    vec2 param_3 = dy;
    return tex2DArrayGrad(image, param, param_1, param_2, param_3);
}

vec4 tex2D(sampler2D image, vec2 texcoord, vec2 dx, vec2 dy)
{
    return textureGrad(image, texcoord, dx, dy);
}

vec4 texPhys(sampler2D image, vec2 texcoord, vec2 dx, vec2 dy)
{
    vec2 param = texcoord;
    vec2 param_1 = dx;
    vec2 param_2 = dy;
    return tex2D(image, param, param_1, param_2);
}

float SRGBlinear(float value)
{
    if (value <= 0.040449999272823333740234375)
    {
        return value / 12.9200000762939453125;
    }
    else
    {
        return pow((value / 1.05499994754791259765625) + 0.0521326996386051177978515625, 2.400000095367431640625);
    }
}

float DeGamma(float value)
{
    float param = value;
    return SRGBlinear(param);
}

float saturate(float v)
{
    return clamp(v, 0.0, 1.0);
}

vec2 screenPosToTexcoord(vec2 pos, vec4 bias_scale)
{
    return (pos * bias_scale.zw) + bias_scale.xy;
}

float asfloat(uint x)
{
    return uintBitsToFloat(x);
}

float GetLinearDepth(float ndcZ, vec4 projectionMatrixZ, float rcpFarZ, bool bFirstPersonArmsRescale)
{
    float linearZ = projectionMatrixZ.w / (ndcZ + projectionMatrixZ.z);
    if (bFirstPersonArmsRescale)
    {
        float _859;
        if (linearZ < 1.0)
        {
            _859 = 10.0;
        }
        else
        {
            _859 = 1.0;
        }
        linearZ *= _859;
    }
    return linearZ * rcpFarZ;
}

vec3 saturate(vec3 v)
{
    return clamp(v, vec3(0.0), vec3(1.0));
}

uint packR10G10B10(inout vec3 value)
{
    vec3 param = value;
    value = saturate(param);
    return ((uint(value.x * 1023.0) << uint(20)) | (uint(value.y * 1023.0) << uint(10))) | uint(value.z * 1023.0);
}

vec3 ReconstructNormal(vec3 normalTS, bool isFrontFacing)
{
    vec3 N = (normalTS * 2.0) - vec3(1.0);
    float param = (1.0 - (N.x * N.x)) - (N.y * N.y);
    N.z = sqrt(saturate(param));
    if (isFrontFacing == false)
    {
        N.z = -N.z;
    }
    return N;
}

vec3 TransformNormal(vec3 normal, mat3 mat)
{
    return normalize(vec3(dot(normal, mat[0]), dot(normal, mat[1]), dot(normal, mat[2])));
}

vec3 GetWorldSpaceNormal(vec3 normalTS, mat3 invTS, bool isFrontFacing)
{
    vec3 param = normalTS;
    bool param_1 = isFrontFacing;
    vec3 N = ReconstructNormal(param, param_1);
    vec3 param_2 = N;
    mat3 param_3 = invTS;
    return TransformNormal(param_2, param_3);
}

float GetLuma(vec3 c)
{
    return dot(c, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875));
}

uint asuint(float x)
{
    return floatBitsToUint(x);
}

float ApproxLog2(float f)
{
    float param = f;
    return (float(asuint(param)) / 8388608.0) - 127.0;
}

float ApproxExp2(float f)
{
    uint param = uint((f + 127.0) * 8388608.0);
    return asfloat(param);
}

vec4 saturate(vec4 v)
{
    return clamp(v, vec4(0.0), vec4(1.0));
}

uint packR8G8B8A8(inout vec4 value)
{
    vec4 param = value;
    value = saturate(param);
    return (((uint(value.x * 255.0) << uint(24)) | (uint(value.y * 255.0) << uint(16))) | (uint(value.z * 255.0) << uint(8))) | uint(value.w * 255.0);
}

uint packRGBE(vec3 value)
{
    float param = max(max(value.x, value.y), value.z);
    float sharedExp = ceil(ApproxLog2(param));
    float param_1 = sharedExp;
    vec4 param_2 = vec4(value / vec3(ApproxExp2(param_1)), (sharedExp + 128.0) / 255.0);
    vec4 param_3 = saturate(param_2);
    uint _664 = packR8G8B8A8(param_3);
    return _664;
}

float fmin3(float f1, float f2, float f3)
{
    return min(f1, min(f2, f3));
}

float fmax3(float f1, float f2, float f3)
{
    return max(f1, max(f2, f3));
}

vec4 unpackR15G15B15A15(uvec2 value)
{
    return vec4(float((value.x >> uint(16)) & 65535u), float(value.x & 65535u), float((value.y >> uint(16)) & 65535u), float(value.y & 65535u)) * 3.0518509447574615478515625e-05;
}

uint getCubeMapFaceID(float x, float y, float z)
{
    bool _344 = abs(z) >= abs(x);
    bool _352;
    if (_344)
    {
        _352 = abs(z) >= abs(y);
    }
    else
    {
        _352 = _344;
    }
    if (_352)
    {
        int _355;
        if (z < 0.0)
        {
            _355 = 5;
        }
        else
        {
            _355 = 4;
        }
        return uint(_355);
    }
    if (abs(y) >= abs(x))
    {
        int _373;
        if (y < 0.0)
        {
            _373 = 3;
        }
        else
        {
            _373 = 2;
        }
        return uint(_373);
    }
    int _384;
    if (x < 0.0)
    {
        _384 = 1;
    }
    else
    {
        _384 = 0;
    }
    return uint(_384);
}

float shadow2Ddepth(sampler2DShadow image, vec3 texcoord)
{
    return textureLod(image, vec3(texcoord.xy, texcoord.z), 0.0);
}

vec4 unpackR8G8B8A8(uint value)
{
    return vec4(float((value >> uint(24)) & 255u), float((value >> uint(16)) & 255u), float((value >> uint(8)) & 255u), float(value & 255u)) / vec4(255.0);
}

vec3 unpackRGBE(uint value)
{
    uint param = value;
    vec4 rgbe = unpackR8G8B8A8(param);
    float param_1 = (rgbe.w * 255.0) - 128.0;
    return rgbe.xyz * ApproxExp2(param_1);
}

vec2 saturate(vec2 v)
{
    return clamp(v, vec2(0.0), vec2(1.0));
}

vec3 unpackR10G10B10(uint value)
{
    return vec3(float((value >> uint(20)) & 1023u), float((value >> uint(10)) & 1023u), float(value & 1023u)) / vec3(1023.0);
}

float ApproxPow(float fBase, float fPower)
{
    float param = fBase;
    uint param_1 = uint((fPower * float(asuint(param))) - (((fPower - 1.0) * 127.0) * 8388608.0));
    return asfloat(param_1);
}

vec3 fresnelSchlick(vec3 f0, float costheta)
{
    float param = 50.0 * dot(f0, vec3(0.33329999446868896484375));
    float baked_spec_occl = saturate(param);
    float param_1 = 1.0 - costheta;
    float param_2 = saturate(param_1);
    float param_3 = 5.0;
    vec3 param_4 = f0 + ((vec3(baked_spec_occl) - f0) * ApproxPow(param_2, param_3));
    return saturate(param_4);
}

vec3 specBRDF(vec3 N, vec3 V, vec3 L, vec3 f0, float smoothness)
{
    vec3 H = normalize(V + L);
    float m = 1.0 - (smoothness * 0.800000011920928955078125);
    m *= m;
    m *= m;
    float m2 = m * m;
    float param = dot(N, H);
    float NdotH = saturate(param);
    float spec = ((NdotH * NdotH) * (m2 - 1.0)) + 1.0;
    spec = m2 / ((spec * spec) + 9.9999999392252902907785028219223e-09);
    float param_1 = dot(N, V);
    float Gv = (saturate(param_1) * (1.0 - m)) + m;
    float param_2 = dot(N, L);
    float Gl = (saturate(param_2) * (1.0 - m)) + m;
    spec /= (((4.0 * Gv) * Gl) + 9.9999999392252902907785028219223e-09);
    vec3 param_3 = f0;
    float param_4 = dot(L, H);
    return fresnelSchlick(param_3, param_4) * spec;
}

vec3 SRGBlinear(vec3 sRGB)
{
    float param = sRGB.x;
    vec3 outLinear;
    outLinear.x = SRGBlinear(param);
    float param_1 = sRGB.y;
    outLinear.y = SRGBlinear(param_1);
    float param_2 = sRGB.z;
    outLinear.z = SRGBlinear(param_2);
    return outLinear;
}

vec4 SRGBlinear(vec4 sRGBA)
{
    vec3 param = sRGBA.xyz;
    vec4 outLinear = vec4(SRGBlinear(param), 1.0);
    float param_1 = sRGBA.w;
    outLinear.w = SRGBlinear(param_1);
    return outLinear;
}

vec4 DeGamma(vec4 color)
{
    vec4 param = color;
    return SRGBlinear(param);
}

vec2 OctWrap(vec2 v)
{
    float _942;
    if (v.x >= 0.0)
    {
        _942 = 1.0;
    }
    else
    {
        _942 = -1.0;
    }
    float _951;
    if (v.y >= 0.0)
    {
        _951 = 1.0;
    }
    else
    {
        _951 = -1.0;
    }
    return (vec2(1.0) - abs(v.yx)) * vec2(_942, _951);
}

vec2 NormalOctEncode(inout vec3 n, bool compress_range)
{
    n /= vec3((abs(n.x) + abs(n.y)) + abs(n.z));
    vec2 _977;
    if (n.z >= 0.0)
    {
        _977 = n.xy;
    }
    else
    {
        vec2 param = n.xy;
        _977 = OctWrap(param);
    }
    n = vec3(_977.x, _977.y, n.z);
    if (compress_range)
    {
        vec2 _1001 = (n.xy * 0.5) + vec2(0.5);
        n = vec3(_1001.x, _1001.y, n.z);
    }
    return n.xy;
}

int asint(float x)
{
    return floatBitsToInt(x);
}

float asfloat(int x)
{
    return intBitsToFloat(x);
}

float sqrtIEEEIntApproximation(float inX, int inSqrtConst)
{
    float param = inX;
    int x = asint(param);
    x = inSqrtConst + (x >> 1);
    int param_1 = x;
    return asfloat(param_1);
}

float fastSqrtNR0(float inX)
{
    float param = inX;
    int param_1 = 532487669;
    return sqrtIEEEIntApproximation(param, param_1);
}

float SmoothnessEncode(float s)
{
    float param = abs(s);
    float s1 = fastSqrtNR0(param);
    float _1013;
    if (s > 0.0)
    {
        _1013 = s1;
    }
    else
    {
        _1013 = -s1;
    }
    return (_1013 * 0.5) + 0.5;
}

void main()
{
    lightingInput_t inputs = lightingInput_t(vec3(0.0), vec3(0.0), vec3(0.0), 0.0, 0.0, 0.0, vec3(0.0), vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, 1.0), vec3(0.0), vec3(0.0), 1.0, 1.0, vec3(0.0), vec3(0.0), vec4(0.0), vec4(0.0), mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0)), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), 0u, 0u, 0u, 0u, 0u, uvec4(0u), uvec4(0u), uvec4(0u));
    inputs.texCoords = vofi_TexCoord0;
    inputs.fragCoord = gl_FragCoord;
    inputs.position = freqLow_fragmentUniforms.globalvieworigin.xyz + vofi_TexCoord4.xyz;
    inputs.view = normalize(-vofi_TexCoord4.xyz);
    inputs.invTS = mat3(vec3(vofi_TexCoord1.xyz), vec3(vofi_TexCoord2.xyz), vec3(vofi_TexCoord3.xyz));
    uint feedback = 0u;
    vec4 sampleLightmap = vec4(0.0);
    vec4 sampleColorMask = vec4(0.0);
    vec4 sampleDiffuse = vec4(0.0);
    vec4 sampleSpecular = vec4(0.0);
    vec4 sampleNormal = vec4(0.0);
    vec2 texCoords = inputs.texCoords.xy;
    vec2 texCoordsLOD = inputs.texCoords.xy;
    if (freqHigh_fragmentUniforms.usevirtualmapping.x > 0.0)
    {
        texCoords = (fract(inputs.texCoords.xy) * freqHigh_fragmentUniforms.virtualmapping.xy) + freqHigh_fragmentUniforms.virtualmapping.zw;
        texCoordsLOD = inputs.texCoords.xy * freqHigh_fragmentUniforms.virtualmapping.xy;
    }
    float widthInTexels = freqLow_fragmentUniforms.vmtrfeedbackfloat.z;
    float maxAnisoLog2 = freqHigh_fragmentUniforms.physicalfilterparms.z;
    vec2 texelCoords = texCoordsLOD * widthInTexels;
    vec2 dx = dFdx(texelCoords);
    vec2 dy = dFdy(texelCoords);
    vec2 param = dx;
    vec2 param_1 = dx;
    float px = dot2(param, param_1);
    vec2 param_2 = dy;
    vec2 param_3 = dy;
    float py = dot2(param_2, param_3);
    float maxLod = 0.5 * log2(max(px, py));
    float minLod = 0.5 * log2(min(px, py));
    float anisoLOD = maxLod - min(maxAnisoLog2, maxLod - minLod);
    float sampleLOD = anisoLOD;
    float widthInPages = freqLow_fragmentUniforms.vmtrfeedbackfloat.y;
    float feedbackBias = freqHigh_fragmentUniforms.physicalfilterparms.y;
    uvec2 feedbackPageUV = uvec2(texCoords * widthInPages);
    uint feedbackLOD = uint(min(freqHigh_fragmentUniforms.physicalfilterparms.w, max(0.0, anisoLOD) + feedbackBias));
    uint feedbackPageSource = uint(freqLow_fragmentUniforms.vmtrfeedbackfloat.x);
    feedback = feedbackPageUV.x & 255u;
    feedback |= ((feedbackPageUV.y & 255u) << uint(8));
    feedback |= ((feedbackPageUV.x >> uint(8)) << uint(16));
    feedback |= ((feedbackPageUV.y >> uint(8)) << uint(24));
    feedback |= (feedbackLOD << uint(19));
    feedback |= (feedbackPageSource << uint(27));
    sampleLOD += 0.0;
    vec3 physCoords;
    if (freqLow_fragmentUniforms.virtualtextureoptions.y != 0.0)
    {
        float trilinearFraction = fract(sampleLOD);
        float triStart = 0.375;
        float triEnd = 0.625;
        bool twoSamples;
        float sampleLOD1;
        float sampleLOD2;
        if (trilinearFraction <= triStart)
        {
            twoSamples = false;
            sampleLOD1 = sampleLOD - 0.5;
            sampleLOD2 = 0.0;
        }
        else
        {
            if (trilinearFraction >= triEnd)
            {
                twoSamples = false;
                sampleLOD1 = sampleLOD + 0.5;
                sampleLOD2 = 0.0;
            }
            else
            {
                twoSamples = true;
                sampleLOD1 = sampleLOD - 0.5;
                sampleLOD2 = sampleLOD + 0.5;
            }
        }
        vec4 virtCoordsLod = vec4(texCoords.x, texCoords.y, 0.0, sampleLOD1);
        vec4 param_4 = virtCoordsLod;
        vec2 physPage = tex2Dlod(samp_vmtrpagetablemap, param_4).xy;
        vec2 param_5 = physPage;
        vec4 xform = tex2D(samp_vmtrphysicalmappingsmap, param_5);
        physCoords.x = (texCoords.x * xform.x) + xform.z;
        physCoords.y = (texCoords.y * (xform.x * freqLow_fragmentUniforms.vmtrphysicalpagesaspectratio.x)) + xform.w;
        physCoords.z = xform.y;
        vec2 dx_1 = dFdx(texCoordsLOD) * physCoords.z;
        vec2 dy_1 = dFdy(texCoordsLOD) * physCoords.z;
        float param_6 = 0.0;
        vec2 param_7 = physCoords.xy;
        vec2 param_8 = dx_1;
        vec2 param_9 = dy_1;
        sampleDiffuse = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_6, param_7, param_8, param_9);
        float param_10 = 1.0;
        vec2 param_11 = physCoords.xy;
        vec2 param_12 = dx_1;
        vec2 param_13 = dy_1;
        sampleSpecular = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_10, param_11, param_12, param_13);
        float param_14 = 2.0;
        vec2 param_15 = physCoords.xy;
        vec2 param_16 = dx_1;
        vec2 param_17 = dy_1;
        sampleLightmap = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_14, param_15, param_16, param_17);
        vec2 param_18 = physCoords.xy;
        vec2 param_19 = dx_1;
        vec2 param_20 = dy_1;
        sampleColorMask = texPhys(samp_vmtrphysicalpagesmap3, param_18, param_19, param_20);
        sampleNormal = vec4(0.0);
        float cover = sampleLightmap.z;
        float param_21 = sampleLightmap.w;
        float power = DeGamma(param_21);
        sampleNormal.y = sampleSpecular.w;
        sampleNormal.w = sampleDiffuse.w;
        sampleSpecular.w = cover;
        sampleLightmap.w = power;
        if (twoSamples)
        {
            vec4 virtCoordsLod_1 = vec4(texCoords.x, texCoords.y, 0.0, sampleLOD2);
            vec4 param_22 = virtCoordsLod_1;
            vec2 physPage_1 = tex2Dlod(samp_vmtrpagetablemap, param_22).xy;
            vec2 param_23 = physPage_1;
            vec4 xform_1 = tex2D(samp_vmtrphysicalmappingsmap, param_23);
            physCoords.x = (texCoords.x * xform_1.x) + xform_1.z;
            physCoords.y = (texCoords.y * (xform_1.x * freqLow_fragmentUniforms.vmtrphysicalpagesaspectratio.x)) + xform_1.w;
            physCoords.z = xform_1.y;
            vec2 dx_2 = dFdx(texCoordsLOD) * physCoords.z;
            vec2 dy_2 = dFdy(texCoordsLOD) * physCoords.z;
            float param_24 = 0.0;
            vec2 param_25 = physCoords.xy;
            vec2 param_26 = dx_2;
            vec2 param_27 = dy_2;
            vec4 sampleDiffuse2 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_24, param_25, param_26, param_27);
            float param_28 = 1.0;
            vec2 param_29 = physCoords.xy;
            vec2 param_30 = dx_2;
            vec2 param_31 = dy_2;
            vec4 sampleSpecular2 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_28, param_29, param_30, param_31);
            float param_32 = 2.0;
            vec2 param_33 = physCoords.xy;
            vec2 param_34 = dx_2;
            vec2 param_35 = dy_2;
            vec4 sampleLightmap2 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_32, param_33, param_34, param_35);
            vec2 param_36 = physCoords.xy;
            vec2 param_37 = dx_2;
            vec2 param_38 = dy_2;
            vec4 sampleColorMask2 = texPhys(samp_vmtrphysicalpagesmap3, param_36, param_37, param_38);
            vec4 samplePower2 = vec4(0.0);
            float cover_1 = sampleLightmap2.z;
            float param_39 = sampleLightmap2.w;
            float power_1 = DeGamma(param_39);
            samplePower2.y = sampleSpecular2.w;
            samplePower2.w = sampleDiffuse2.w;
            sampleSpecular2.w = cover_1;
            sampleLightmap2.w = power_1;
            float lerpFactor = 0.0;
            float triStart_1 = 0.375;
            float param_40 = (trilinearFraction - triStart_1) * 4.0;
            lerpFactor = saturate(param_40);
            sampleSpecular = mix(sampleSpecular, sampleSpecular2, vec4(lerpFactor));
            sampleDiffuse = mix(sampleDiffuse, sampleDiffuse2, vec4(lerpFactor));
            sampleNormal = mix(sampleNormal, samplePower2, vec4(lerpFactor));
            sampleLightmap = mix(sampleLightmap, sampleLightmap2, vec4(lerpFactor));
            sampleColorMask = mix(sampleColorMask, sampleColorMask2, vec4(lerpFactor));
        }
    }
    else
    {
        vec4 virtCoordsLod_2 = vec4(texCoords.x, texCoords.y, 0.0, sampleLOD - 0.5);
        vec4 param_41 = virtCoordsLod_2;
        vec2 physPage_2 = tex2Dlod(samp_vmtrpagetablemap, param_41).xy;
        vec2 param_42 = physPage_2;
        vec4 xform_2 = tex2D(samp_vmtrphysicalmappingsmap, param_42);
        physCoords.x = (texCoords.x * xform_2.x) + xform_2.z;
        physCoords.y = (texCoords.y * (xform_2.x * freqLow_fragmentUniforms.vmtrphysicalpagesaspectratio.x)) + xform_2.w;
        physCoords.z = xform_2.y;
        vec2 dx_3 = dFdx(texCoordsLOD) * physCoords.z;
        vec2 dy_3 = dFdy(texCoordsLOD) * physCoords.z;
        float param_43 = 0.0;
        vec2 param_44 = physCoords.xy;
        vec2 param_45 = dx_3;
        vec2 param_46 = dy_3;
        sampleDiffuse = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_43, param_44, param_45, param_46);
        float param_47 = 1.0;
        vec2 param_48 = physCoords.xy;
        vec2 param_49 = dx_3;
        vec2 param_50 = dy_3;
        sampleSpecular = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_47, param_48, param_49, param_50);
        float param_51 = 2.0;
        vec2 param_52 = physCoords.xy;
        vec2 param_53 = dx_3;
        vec2 param_54 = dy_3;
        sampleLightmap = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_51, param_52, param_53, param_54);
        vec2 param_55 = physCoords.xy;
        vec2 param_56 = dx_3;
        vec2 param_57 = dy_3;
        sampleColorMask = texPhys(samp_vmtrphysicalpagesmap3, param_55, param_56, param_57);
        sampleNormal = vec4(0.0);
        float cover_2 = sampleLightmap.z;
        float param_58 = sampleLightmap.w;
        float power_2 = DeGamma(param_58);
        sampleNormal.y = sampleSpecular.w;
        sampleNormal.w = sampleDiffuse.w;
        sampleSpecular.w = cover_2;
        sampleLightmap.w = power_2;
    }
    vec2 TEXTURE_RESOLUTION = vec2(160.0, 120.0);
    vec2 FRAMEBUFFER_PIXEL_SIZE = TEXTURE_RESOLUTION * freqHigh_fragmentUniforms.positiontoviewtexture.zw;
    vec2 param_59 = gl_FragCoord.xy;
    vec4 param_60 = freqHigh_fragmentUniforms.positiontoviewtexture;
    vec2 tc = screenPosToTexcoord(param_59, param_60) * TEXTURE_RESOLUTION;
    float offsetMultiplier = floor(mod(tc.x + 0.25, 4.0));
    float xOffset = offsetMultiplier * FRAMEBUFFER_PIXEL_SIZE.x;
    bool _1677 = fract(tc.x - xOffset) < FRAMEBUFFER_PIXEL_SIZE.x;
    bool _1686;
    if (_1677)
    {
        _1686 = fract(tc.y) < FRAMEBUFFER_PIXEL_SIZE.y;
    }
    else
    {
        _1686 = _1677;
    }
    if (_1686)
    {
        uint param_61 = feedback;
        imageStore(ib_feedbackbuffer, ivec2(tc), vec4(asfloat(param_61), 0.0, 0.0, 0.0));
    }
    uint feedback2 = 0u;
    vec4 sampleDiffuse2_1 = vec4(0.0);
    vec4 sampleSpecular2_1 = vec4(0.0);
    vec4 sampleNormal2 = vec4(0.0);
    vec4 sampleLightmap2_1 = vec4(0.0);
    vec4 sampleColorMask2_1 = vec4(0.0);
    vec2 texCoords_1 = inputs.texCoords.xy;
    vec2 texCoordsLOD_1 = inputs.texCoords.xy;
    if (freqHigh_fragmentUniforms.usevirtualmapping.x > 0.0)
    {
        texCoords_1 = (fract(inputs.texCoords.xy) * freqHigh_fragmentUniforms.virtualmapping.xy) + freqHigh_fragmentUniforms.virtualmapping.zw;
        texCoordsLOD_1 = inputs.texCoords.xy * freqHigh_fragmentUniforms.virtualmapping.xy;
    }
    float widthInTexels_1 = freqLow_fragmentUniforms.vmtrfeedbackfloat.z;
    float maxAnisoLog2_1 = freqHigh_fragmentUniforms.physicalfilterparms.z;
    vec2 texelCoords_1 = texCoordsLOD_1 * widthInTexels_1;
    vec2 dx_4 = dFdx(texelCoords_1);
    vec2 dy_4 = dFdy(texelCoords_1);
    vec2 param_62 = dx_4;
    vec2 param_63 = dx_4;
    float px_1 = dot2(param_62, param_63);
    vec2 param_64 = dy_4;
    vec2 param_65 = dy_4;
    float py_1 = dot2(param_64, param_65);
    float maxLod_1 = 0.5 * log2(max(px_1, py_1));
    float minLod_1 = 0.5 * log2(min(px_1, py_1));
    float anisoLOD_1 = maxLod_1 - min(maxAnisoLog2_1, maxLod_1 - minLod_1);
    float sampleLOD_1 = anisoLOD_1;
    float widthInPages_1 = freqLow_fragmentUniforms.vmtrfeedbackfloat.y;
    float feedbackBias_1 = freqHigh_fragmentUniforms.physicalfilterparms.y;
    uvec2 feedbackPageUV_1 = uvec2(texCoords_1 * widthInPages_1);
    uint feedbackLOD_1 = uint(min(freqHigh_fragmentUniforms.physicalfilterparms.w, max(0.0, anisoLOD_1) + feedbackBias_1));
    uint feedbackPageSource_1 = uint(freqLow_fragmentUniforms.vmtrfeedbackfloat.x);
    feedback2 = feedbackPageUV_1.x & 255u;
    feedback2 |= ((feedbackPageUV_1.y & 255u) << uint(8));
    feedback2 |= ((feedbackPageUV_1.x >> uint(8)) << uint(16));
    feedback2 |= ((feedbackPageUV_1.y >> uint(8)) << uint(24));
    feedback2 |= (feedbackLOD_1 << uint(19));
    feedback2 |= (feedbackPageSource_1 << uint(27));
    sampleLOD_1 += freqHigh_fragmentUniforms.sssblurradius.x;
    vec3 physCoords_1;
    if (freqLow_fragmentUniforms.virtualtextureoptions.y != 0.0)
    {
        float trilinearFraction_1 = fract(sampleLOD_1);
        float triStart_2 = 0.375;
        float triEnd_1 = 0.625;
        bool twoSamples_1;
        float sampleLOD1_1;
        float sampleLOD2_1;
        if (trilinearFraction_1 <= triStart_2)
        {
            twoSamples_1 = false;
            sampleLOD1_1 = sampleLOD_1 - 0.5;
            sampleLOD2_1 = 0.0;
        }
        else
        {
            if (trilinearFraction_1 >= triEnd_1)
            {
                twoSamples_1 = false;
                sampleLOD1_1 = sampleLOD_1 + 0.5;
                sampleLOD2_1 = 0.0;
            }
            else
            {
                twoSamples_1 = true;
                sampleLOD1_1 = sampleLOD_1 - 0.5;
                sampleLOD2_1 = sampleLOD_1 + 0.5;
            }
        }
        vec4 virtCoordsLod_3 = vec4(texCoords_1.x, texCoords_1.y, 0.0, sampleLOD1_1);
        vec4 param_66 = virtCoordsLod_3;
        vec2 physPage_3 = tex2Dlod(samp_vmtrpagetablemap, param_66).xy;
        vec2 param_67 = physPage_3;
        vec4 xform_3 = tex2D(samp_vmtrphysicalmappingsmap, param_67);
        physCoords_1.x = (texCoords_1.x * xform_3.x) + xform_3.z;
        physCoords_1.y = (texCoords_1.y * (xform_3.x * freqLow_fragmentUniforms.vmtrphysicalpagesaspectratio.x)) + xform_3.w;
        physCoords_1.z = xform_3.y;
        vec2 dx_5 = dFdx(texCoordsLOD_1) * physCoords_1.z;
        vec2 dy_5 = dFdy(texCoordsLOD_1) * physCoords_1.z;
        float param_68 = 0.0;
        vec2 param_69 = physCoords_1.xy;
        vec2 param_70 = dx_5;
        vec2 param_71 = dy_5;
        sampleDiffuse2_1 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_68, param_69, param_70, param_71);
        float param_72 = 1.0;
        vec2 param_73 = physCoords_1.xy;
        vec2 param_74 = dx_5;
        vec2 param_75 = dy_5;
        sampleSpecular2_1 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_72, param_73, param_74, param_75);
        float param_76 = 2.0;
        vec2 param_77 = physCoords_1.xy;
        vec2 param_78 = dx_5;
        vec2 param_79 = dy_5;
        sampleLightmap2_1 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_76, param_77, param_78, param_79);
        vec2 param_80 = physCoords_1.xy;
        vec2 param_81 = dx_5;
        vec2 param_82 = dy_5;
        sampleColorMask2_1 = texPhys(samp_vmtrphysicalpagesmap3, param_80, param_81, param_82);
        sampleNormal2 = vec4(0.0);
        float cover_3 = sampleLightmap2_1.z;
        float param_83 = sampleLightmap2_1.w;
        float power_3 = DeGamma(param_83);
        sampleNormal2.y = sampleSpecular2_1.w;
        sampleNormal2.w = sampleDiffuse2_1.w;
        sampleSpecular2_1.w = cover_3;
        sampleLightmap2_1.w = power_3;
        if (twoSamples_1)
        {
            vec4 virtCoordsLod_4 = vec4(texCoords_1.x, texCoords_1.y, 0.0, sampleLOD2_1);
            vec4 param_84 = virtCoordsLod_4;
            vec2 physPage_4 = tex2Dlod(samp_vmtrpagetablemap, param_84).xy;
            vec2 param_85 = physPage_4;
            vec4 xform_4 = tex2D(samp_vmtrphysicalmappingsmap, param_85);
            physCoords_1.x = (texCoords_1.x * xform_4.x) + xform_4.z;
            physCoords_1.y = (texCoords_1.y * (xform_4.x * freqLow_fragmentUniforms.vmtrphysicalpagesaspectratio.x)) + xform_4.w;
            physCoords_1.z = xform_4.y;
            vec2 dx_6 = dFdx(texCoordsLOD_1) * physCoords_1.z;
            vec2 dy_6 = dFdy(texCoordsLOD_1) * physCoords_1.z;
            float param_86 = 0.0;
            vec2 param_87 = physCoords_1.xy;
            vec2 param_88 = dx_6;
            vec2 param_89 = dy_6;
            vec4 sampleDiffuse2_2 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_86, param_87, param_88, param_89);
            float param_90 = 1.0;
            vec2 param_91 = physCoords_1.xy;
            vec2 param_92 = dx_6;
            vec2 param_93 = dy_6;
            vec4 sampleSpecular2_2 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_90, param_91, param_92, param_93);
            float param_94 = 2.0;
            vec2 param_95 = physCoords_1.xy;
            vec2 param_96 = dx_6;
            vec2 param_97 = dy_6;
            vec4 sampleLightmap2_2 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_94, param_95, param_96, param_97);
            vec2 param_98 = physCoords_1.xy;
            vec2 param_99 = dx_6;
            vec2 param_100 = dy_6;
            vec4 sampleColorMask2_2 = texPhys(samp_vmtrphysicalpagesmap3, param_98, param_99, param_100);
            vec4 samplePower2_1 = vec4(0.0);
            float cover_4 = sampleLightmap2_2.z;
            float param_101 = sampleLightmap2_2.w;
            float power_4 = DeGamma(param_101);
            samplePower2_1.y = sampleSpecular2_2.w;
            samplePower2_1.w = sampleDiffuse2_2.w;
            sampleSpecular2_2.w = cover_4;
            sampleLightmap2_2.w = power_4;
            float lerpFactor_1 = 0.0;
            float triStart_3 = 0.375;
            float param_102 = (trilinearFraction_1 - triStart_3) * 4.0;
            lerpFactor_1 = saturate(param_102);
            sampleSpecular2_2 = mix(sampleSpecular2_2, sampleSpecular2_2, vec4(lerpFactor_1));
            sampleDiffuse2_2 = mix(sampleDiffuse2_2, sampleDiffuse2_2, vec4(lerpFactor_1));
            sampleNormal2 = mix(sampleNormal2, samplePower2_1, vec4(lerpFactor_1));
            sampleLightmap2_2 = mix(sampleLightmap2_2, sampleLightmap2_2, vec4(lerpFactor_1));
            sampleColorMask2_2 = mix(sampleColorMask2_2, sampleColorMask2_2, vec4(lerpFactor_1));
        }
    }
    else
    {
        vec4 virtCoordsLod_5 = vec4(texCoords_1.x, texCoords_1.y, 0.0, sampleLOD_1 - 0.5);
        vec4 param_103 = virtCoordsLod_5;
        vec2 physPage_5 = tex2Dlod(samp_vmtrpagetablemap, param_103).xy;
        vec2 param_104 = physPage_5;
        vec4 xform_5 = tex2D(samp_vmtrphysicalmappingsmap, param_104);
        physCoords_1.x = (texCoords_1.x * xform_5.x) + xform_5.z;
        physCoords_1.y = (texCoords_1.y * (xform_5.x * freqLow_fragmentUniforms.vmtrphysicalpagesaspectratio.x)) + xform_5.w;
        physCoords_1.z = xform_5.y;
        vec2 dx_7 = dFdx(texCoordsLOD_1) * physCoords_1.z;
        vec2 dy_7 = dFdy(texCoordsLOD_1) * physCoords_1.z;
        float param_105 = 0.0;
        vec2 param_106 = physCoords_1.xy;
        vec2 param_107 = dx_7;
        vec2 param_108 = dy_7;
        sampleDiffuse2_1 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_105, param_106, param_107, param_108);
        float param_109 = 1.0;
        vec2 param_110 = physCoords_1.xy;
        vec2 param_111 = dx_7;
        vec2 param_112 = dy_7;
        sampleSpecular2_1 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_109, param_110, param_111, param_112);
        float param_113 = 2.0;
        vec2 param_114 = physCoords_1.xy;
        vec2 param_115 = dx_7;
        vec2 param_116 = dy_7;
        sampleLightmap2_1 = texPhysArray(samp_vmtrphysicalpagesmaparray0, param_113, param_114, param_115, param_116);
        vec2 param_117 = physCoords_1.xy;
        vec2 param_118 = dx_7;
        vec2 param_119 = dy_7;
        sampleColorMask2_1 = texPhys(samp_vmtrphysicalpagesmap3, param_117, param_118, param_119);
        sampleNormal2 = vec4(0.0);
        float cover_5 = sampleLightmap2_1.z;
        float param_120 = sampleLightmap2_1.w;
        float power_5 = DeGamma(param_120);
        sampleNormal2.y = sampleSpecular2_1.w;
        sampleNormal2.w = sampleDiffuse2_1.w;
        sampleSpecular2_1.w = cover_5;
        sampleLightmap2_1.w = power_5;
    }
    inputs.normalSSS = sampleNormal2.wyz;
    float param_121 = sampleLightmap.y * freqHigh_fragmentUniforms.sssmaskscale.x;
    inputs.maskSSS = saturate(param_121);
    float _2248;
    if (freqHigh_fragmentUniforms.packedspec.x > 0.0)
    {
        _2248 = sampleSpecular.x;
    }
    else
    {
        _2248 = 0.0;
    }
    inputs.thickness = _2248;
    vec3 _2260;
    if (freqHigh_fragmentUniforms.packedspec.x > 0.0)
    {
        _2260 = vec3(sampleSpecular.y);
    }
    else
    {
        _2260 = sampleSpecular.xyz;
    }
    sampleSpecular = vec4(_2260.x, _2260.y, _2260.z, sampleSpecular.w);
    float param_122 = (1.0 - inputs.maskSSS) * freqHigh_fragmentUniforms.ssdodiffuseocclusionmultiplier.x;
    inputs.ssdoDiffuseMul = saturate(param_122);
    inputs.emissive = (vec3(((freqHigh_fragmentUniforms.bloommaskscale.x * sampleLightmap.x) * sampleLightmap.x) * freqHigh_fragmentUniforms.colorscale.x) * freqHigh_fragmentUniforms.color.xyz) * freqHigh_fragmentUniforms.bloomcolor.xyz;
    inputs.albedo = sampleDiffuse.xyz;
    inputs.specular = sampleSpecular.xyz;
    inputs.colorMask = sampleColorMask.xyz;
    inputs.lightmap = sampleLightmap.xyz;
    inputs.smoothness = sampleLightmap.w;
    inputs.normal = sampleNormal.wyz;
    vec2 param_123 = vofi_TexCoord7.xy;
    vec4 woundMap = tex2D(samp_woundtexture, param_123);
    vec3 _2337 = woundMap.xyz - vec3(0.5);
    woundMap = vec4(_2337.x, _2337.y, _2337.z, woundMap.w);
    float param_124 = vofi_TexCoord6.x * 0.5;
    float param_125 = ((1.0 - saturate(param_124)) - (1.0 - woundMap.w)) * 3.0;
    float woundMask = saturate(param_125);
    vec3 diffuseBloodLerp = mix(inputs.albedo, freqHigh_fragmentUniforms.bloodcolorlerp.xyz, vec3(woundMask));
    inputs.albedo *= mix(vec3(1.0), freqHigh_fragmentUniforms.bloodcolor.xyz, vec3(woundMask));
    inputs.albedo = mix(inputs.albedo, diffuseBloodLerp, vec3(0.5));
    inputs.specular = mix(inputs.specular, vec3(0.0199999995529651641845703125), vec3(woundMask));
    inputs.smoothness = mix(inputs.smoothness, 0.64999997615814208984375, woundMask);
    vec2 _2409 = inputs.normal.xy + mix(woundMap.xy * vec2(woundMask), vec2(0.0), vec2(freqHigh_fragmentUniforms.bloodcolor.w));
    inputs.normal = vec3(_2409.x, _2409.y, inputs.normal.z);
    int _2414;
    if (freqHigh_fragmentUniforms.staticmodel.x > 0.0)
    {
        _2414 = 8;
    }
    else
    {
        _2414 = 0;
    }
    uint skipStaticModel = uint(_2414);
    float NUM_CLUSTERS_X = 16.0;
    float NUM_CLUSTERS_Y = 8.0;
    float NUM_CLUSTERS_Z = 24.0;
    vec2 param_126 = inputs.fragCoord.xy;
    vec4 param_127 = freqHigh_fragmentUniforms.positiontoviewtexture;
    vec2 _2441 = screenPosToTexcoord(param_126, param_127) * freqLow_fragmentUniforms.resolutionscale.zw;    
    vec3 clusterCoordinate;
    clusterCoordinate = vec3(_2441.x, _2441.y, clusterCoordinate.z);
    clusterCoordinate.y = 1.0 - clusterCoordinate.y;

        // FIX FOR DECALS CLIPPING
    clusterCoordinate.x -= vk3d_params.stereo.x * 0.5;
    
    
    vec2 _2454 = floor(clusterCoordinate.xy * vec2(NUM_CLUSTERS_X, NUM_CLUSTERS_Y));
    clusterCoordinate = vec3(_2454.x, _2454.y, clusterCoordinate.z);
    float param_128 = inputs.fragCoord.z;
    vec4 param_129 = freqLow_fragmentUniforms.projectionmatrixz;
    float param_130 = 1.0;
    bool param_131 = false;
    float curr_z = GetLinearDepth(param_128, param_129, param_130, param_131);
    float slice = log2(max(1.0, curr_z / freqLow_fragmentUniforms.clusteredlighting.z)) * freqLow_fragmentUniforms.clusteredlighting.w;
    clusterCoordinate.z = min(NUM_CLUSTERS_Z - 1.0, floor(slice));
    uint clusterOffset = uint((clusterCoordinate.x + (clusterCoordinate.y * NUM_CLUSTERS_X)) + ((clusterCoordinate.z * NUM_CLUSTERS_X) * NUM_CLUSTERS_Y));
    vec3 param_132 = inputs.albedo;
    uint _2503 = packR10G10B10(param_132);
    inputs.albedo_packed = _2503;
    vec3 param_133 = inputs.specular;
    uint _2509 = packR10G10B10(param_133);
    inputs.specular_packed = _2509;
    uint lightsMin = 0u;
    uint lightsMax = 0u;
    uint decalsMin = 0u;
    uint decalsMax = 0u;
    uint probesMin = 0u;
    uint probesMax = 0u;
    int MAX_LIGHTS_PER_CLUSTER = 256;
    clusternumlights_t cluster;
    cluster.offset = _2526.clusternumlights[clusterOffset].offset;
    cluster.numItems = _2526.clusternumlights[clusterOffset].numItems;
    int dataOffset = cluster.offset & (~(cluster.offset >> 31));
    int numItems = cluster.numItems & (~(cluster.numItems >> 31));
    lightsMin = uint((dataOffset >> 16) * MAX_LIGHTS_PER_CLUSTER);
    lightsMax = lightsMin + uint(numItems & 255);
    decalsMin = lightsMin;
    decalsMax = decalsMin + uint((numItems >> 8) & 255);
    probesMin = lightsMin;
    probesMax = probesMin + uint((numItems >> 16) & 255);
    bool isFrontFacing = true;
    vec3 param_134 = inputs.normal;
    bool param_135 = isFrontFacing;
    inputs.normalTS = ReconstructNormal(param_134, param_135);
    vec3 param_136 = inputs.normal;
    mat3 param_137 = inputs.invTS;
    bool param_138 = isFrontFacing;
    inputs.normal = GetWorldSpaceNormal(param_136, param_137, param_138);
    vec3 param_139 = inputs.normalSSS;
    mat3 param_140 = inputs.invTS;
    bool param_141 = isFrontFacing;
    inputs.normalSSS = GetWorldSpaceNormal(param_139, param_140, param_141);
    vec3 ambient = vec3(0.0);
    vec3 shc0 = vec3(vofi_TexCoord8.x, vofi_TexCoord8.y, vofi_TexCoord8.z);
    vec3 shc1 = vec3(vofi_TexCoord8.w, vofi_TexCoord9.x, vofi_TexCoord9.y);
    vec3 shc2 = vec3(vofi_TexCoord9.z, vofi_TexCoord9.w, vofi_TexCoord10.x);
    vec3 shc3 = vec3(vofi_TexCoord10.y, vofi_TexCoord10.z, vofi_TexCoord10.w);
    vec3 indirectDiffuse = ((shc0 - (shc1 * inputs.normal.y)) + (shc2 * inputs.normal.z)) - (shc3 * inputs.normal.x);
    float param_142 = freqLow_fragmentUniforms.envirradiancescale.x;
    ambient += max((indirectDiffuse * vec3(1.0)) * saturate(param_142), vec3(0.0));
    vec3 ambientSSS = vec3(0.0);
    vec3 shc0_1 = vec3(vofi_TexCoord8.x, vofi_TexCoord8.y, vofi_TexCoord8.z);
    vec3 shc1_1 = vec3(vofi_TexCoord8.w, vofi_TexCoord9.x, vofi_TexCoord9.y);
    vec3 shc2_1 = vec3(vofi_TexCoord9.z, vofi_TexCoord9.w, vofi_TexCoord10.x);
    vec3 shc3_1 = vec3(vofi_TexCoord10.y, vofi_TexCoord10.z, vofi_TexCoord10.w);
    vec3 indirectDiffuse_1 = ((shc0_1 - (shc1_1 * inputs.normalSSS.y)) + (shc2_1 * inputs.normalSSS.z)) - (shc3_1 * inputs.normalSSS.x);
    float param_143 = freqLow_fragmentUniforms.envirradiancescale.x;
    ambientSSS += max((indirectDiffuse_1 * vec3(1.0)) * saturate(param_143), vec3(0.0));
    ambient = mix(ambient, ambientSSS, vec3(inputs.maskSSS));
    ambient += inputs.emissive;
    float _2738;
    if (dot(inputs.emissive, vec3(1.0)) > 0.0)
    {
        _2738 = -inputs.smoothness;
    }
    else
    {
        _2738 = inputs.smoothness;
    }
    inputs.smoothness = _2738;
    vec3 param_144 = ambient;
    ambient = mix(vec3(GetLuma(param_144)), ambient, freqLow_fragmentUniforms.pbrdebugparms.www);
    inputs.ambient_lighting = ambient;
    vec3 param_145 = ambient;
    inputs.diffuse_lighting_packed = packRGBE(param_145);
    uint lightIdx = lightsMin;
    light_t lightParms;
    shadowparms_t shadow_parms;
    shadowparms_t shadow_parms_1;
    shadowparms_t shadow_parms_2;
    int _3517;
    shadowparms_t shadow_parms_3;
    float _4007;
    float _4152;
    vec3 _4263;
    while (lightIdx < lightsMax)
    {
        uint temp = _2783.clusterlightsid[lightIdx];
        uint divergentLightId = temp & 4095u;
        uint light_id = divergentLightId;
        if (light_id >= divergentLightId)
        {
            lightIdx++;
        }
        int lightParms1Size = 4;
        int lightParms2Size = 4;
        int lightParms3Size = 3;
        lightParms.pos = _2811.lightparms1[(uint(lightParms1Size) * light_id) + 0u].xyz;
        float param_146 = _2811.lightparms1[(uint(lightParms1Size) * light_id) + 0u].w;
        lightParms.lightParms = asuint(param_146);
        lightParms.posShadow = _2811.lightparms1[(uint(lightParms1Size) * light_id) + 1u];
        lightParms.falloffR = _2811.lightparms1[(uint(lightParms1Size) * light_id) + 2u];
        lightParms.projS = _2850.lightparms2[(uint(lightParms2Size) * light_id) + 0u];
        lightParms.projT = _2850.lightparms2[(uint(lightParms2Size) * light_id) + 1u];
        lightParms.projQ = _2850.lightparms2[(uint(lightParms2Size) * light_id) + 2u];
        float param_147 = _2811.lightparms1[(uint(lightParms1Size) * light_id) + 3u].x;
        lightParms.scaleBias.x = asuint(param_147);
        float param_148 = _2811.lightparms1[(uint(lightParms1Size) * light_id) + 3u].y;
        lightParms.scaleBias.y = asuint(param_148);
        float param_149 = _2811.lightparms1[(uint(lightParms1Size) * light_id) + 3u].z;
        lightParms.scaleBias.z = asuint(param_149);
        float param_150 = _2811.lightparms1[(uint(lightParms1Size) * light_id) + 3u].w;
        lightParms.scaleBias.w = asuint(param_150);
        lightParms.boxMin = _2918.lightparms3[(uint(lightParms3Size) * light_id) + 0u];
        lightParms.boxMax = _2918.lightparms3[(uint(lightParms3Size) * light_id) + 1u];
        lightParms.areaPlane = _2918.lightparms3[(uint(lightParms3Size) * light_id) + 2u];
        float param_151 = _2850.lightparms2[(uint(lightParms2Size) * light_id) + 3u].x;
        lightParms.lightParms2 = asuint(param_151);
        float param_152 = _2850.lightparms2[(uint(lightParms2Size) * light_id) + 3u].y;
        lightParms.colorPacked = asuint(param_152);
        lightParms.specMultiplier = _2850.lightparms2[(uint(lightParms2Size) * light_id) + 3u].z;
        lightParms.shadowBleedReduce = _2850.lightparms2[(uint(lightParms2Size) * light_id) + 3u].w;
        float clip_min = 0.0039215688593685626983642578125;
        vec3 projTC = vec3((inputs.position.x * lightParms.projS.x) + ((inputs.position.y * lightParms.projS.y) + ((inputs.position.z * lightParms.projS.z) + lightParms.projS.w)), (inputs.position.x * lightParms.projT.x) + ((inputs.position.y * lightParms.projT.y) + ((inputs.position.z * lightParms.projT.z) + lightParms.projT.w)), (inputs.position.x * lightParms.projQ.x) + ((inputs.position.y * lightParms.projQ.y) + ((inputs.position.z * lightParms.projQ.z) + lightParms.projQ.w)));
        vec2 _3048 = projTC.xy / vec2(projTC.z);
        projTC = vec3(_3048.x, _3048.y, projTC.z);
        projTC.z = (inputs.position.x * lightParms.falloffR.x) + ((inputs.position.y * lightParms.falloffR.y) + ((inputs.position.z * lightParms.falloffR.z) + lightParms.falloffR.w));
        uint light_parms = lightParms.lightParms;
        uint light_flags = skipStaticModel;
        light_flags |= 64u;
        float param_153 = projTC.x;
        float param_154 = projTC.y;
        float param_155 = projTC.z;
        bool _3091 = fmin3(param_153, param_154, param_155) <= clip_min;
        bool _3108;
        if (!_3091)
        {
            float param_156 = projTC.x;
            float param_157 = projTC.y;
            float param_158 = projTC.z;
            _3108 = fmax3(param_156, param_157, param_158) >= (1.0 - clip_min);
        }
        else
        {
            _3108 = _3091;
        }
        bool _3116;
        if (!_3108)
        {
            _3116 = (light_parms & light_flags) != 0u;
        }
        else
        {
            _3116 = _3108;
        }
        if (_3116)
        {
            continue;
        }
        vec3 light_position = lightParms.pos;
        vec3 light_vector = light_position - inputs.position;
        float param_159 = dot(inputs.normal, light_vector);
        float NdotL = saturate(param_159);
        uvec2 param_160 = lightParms.scaleBias.xy;
        vec4 falloffScaleBias = unpackR15G15B15A15(param_160);
        uvec2 param_161 = lightParms.scaleBias.zw;
        vec4 projFilterScaleBias = unpackR15G15B15A15(param_161);
        vec4 param_162 = vec4((projTC.xy * projFilterScaleBias.xy) + projFilterScaleBias.zw, 0.0, 0.0);
        float projFilter = tex2Dlod(samp_lightsatlasmap, param_162).x;
        vec4 param_163 = vec4((vec2(projTC.z, 0.5) * falloffScaleBias.xy) + falloffScaleBias.zw, 0.0, 0.0);
        float falloff = tex2Dlod(samp_lightsatlasmap, param_163).x;
        float light_attenuation = (falloff * falloff) * (projFilter * projFilter);
        if (light_attenuation <= (clip_min / 256.0))
        {
            continue;
        }
        float shadow = 1.0;
        if ((light_parms & 4u) != 0u)
        {
            float normal_bias_scale = 0.100000001490116119384765625;
            vec3 pos = inputs.position + (inputs.normal * normal_bias_scale);
            

            
            uint idx = 0u;
            if ((light_parms & 3u) == 0u)
            {
                vec3 light_dir = pos - lightParms.posShadow.xyz;
                float param_164 = light_dir.x;
                float param_165 = light_dir.y;
                float param_166 = light_dir.z;
                idx = getCubeMapFaceID(param_164, param_165, param_166);
            }
            else
            {
                if ((light_parms & 3u) == 2u)
                {
                    float border = 1.0;
                    int shadowParmSize = 5;
                    shadow_parms.shadowLightS = _3249.shadowsparmsubo[(uint(shadowParmSize) * (light_parms >> uint(22))) + 0u];
                    shadow_parms.shadowLightT = _3249.shadowsparmsubo[(uint(shadowParmSize) * (light_parms >> uint(22))) + 1u];
                    shadow_parms.shadowLightR = _3249.shadowsparmsubo[(uint(shadowParmSize) * (light_parms >> uint(22))) + 2u];
                    shadow_parms.shadowLightQ = _3249.shadowsparmsubo[(uint(shadowParmSize) * (light_parms >> uint(22))) + 3u];
                    shadow_parms.shadowAtlasScaleBias = _3249.shadowsparmsubo[(uint(shadowParmSize) * (light_parms >> uint(22))) + 4u];
                    vec2 shadowTC = vec2(dot(pos, shadow_parms.shadowLightS.xyz) + shadow_parms.shadowLightS.w, dot(pos, shadow_parms.shadowLightT.xyz) + shadow_parms.shadowLightT.w);
                    shadowTC = abs((shadowTC * 2.0) - vec2(1.0));
                    bool _3321 = shadowTC.x >= border;
                    bool _3329;
                    if (!_3321)
                    {
                        _3329 = shadowTC.y >= border;
                    }
                    else
                    {
                        _3329 = _3321;
                    }
                    if (_3329)
                    {
                        idx = 1u;
                        int shadowParmSize_1 = 5;
                        shadow_parms_1.shadowLightS = _3249.shadowsparmsubo[(uint(shadowParmSize_1) * ((light_parms >> uint(22)) + 1u)) + 0u];
                        shadow_parms_1.shadowLightT = _3249.shadowsparmsubo[(uint(shadowParmSize_1) * ((light_parms >> uint(22)) + 1u)) + 1u];
                        shadow_parms_1.shadowLightR = _3249.shadowsparmsubo[(uint(shadowParmSize_1) * ((light_parms >> uint(22)) + 1u)) + 2u];
                        shadow_parms_1.shadowLightQ = _3249.shadowsparmsubo[(uint(shadowParmSize_1) * ((light_parms >> uint(22)) + 1u)) + 3u];
                        shadow_parms_1.shadowAtlasScaleBias = _3249.shadowsparmsubo[(uint(shadowParmSize_1) * ((light_parms >> uint(22)) + 1u)) + 4u];
                        shadowTC = vec2(dot(pos, shadow_parms_1.shadowLightS.xyz) + shadow_parms_1.shadowLightS.w, dot(pos, shadow_parms_1.shadowLightT.xyz) + shadow_parms_1.shadowLightT.w);
                        shadowTC = abs((shadowTC * 2.0) - vec2(1.0));
                        bool _3409 = shadowTC.x >= border;
                        bool _3417;
                        if (!_3409)
                        {
                            _3417 = shadowTC.y >= border;
                        }
                        else
                        {
                            _3417 = _3409;
                        }
                        if (_3417)
                        {
                            idx = 2u;
                            int shadowParmSize_2 = 5;
                            shadow_parms_2.shadowLightS = _3249.shadowsparmsubo[(uint(shadowParmSize_2) * ((light_parms >> uint(22)) + 2u)) + 0u];
                            shadow_parms_2.shadowLightT = _3249.shadowsparmsubo[(uint(shadowParmSize_2) * ((light_parms >> uint(22)) + 2u)) + 1u];
                            shadow_parms_2.shadowLightR = _3249.shadowsparmsubo[(uint(shadowParmSize_2) * ((light_parms >> uint(22)) + 2u)) + 2u];
                            shadow_parms_2.shadowLightQ = _3249.shadowsparmsubo[(uint(shadowParmSize_2) * ((light_parms >> uint(22)) + 2u)) + 3u];
                            shadow_parms_2.shadowAtlasScaleBias = _3249.shadowsparmsubo[(uint(shadowParmSize_2) * ((light_parms >> uint(22)) + 2u)) + 4u];
                            shadowTC = vec2(dot(pos, shadow_parms_2.shadowLightS.xyz) + shadow_parms_2.shadowLightS.w, dot(pos, shadow_parms_2.shadowLightT.xyz) + shadow_parms_2.shadowLightT.w);
                            shadowTC = abs((shadowTC * 2.0) - vec2(1.0));
                        }
                    }
                    float fraction = (1.0 - max(shadowTC.x, shadowTC.y)) * freqLow_fragmentUniforms.parallellightslicescale.w;
                    vec2 screenNoise = fract(gl_FragCoord.xy * 0.5);
                    screenNoise.x = fract((screenNoise.x * 0.5) + screenNoise.y);
                    if (screenNoise.x > fraction)
                    {
                        _3517 = 1;
                    }
                    else
                    {
                        _3517 = 0;
                    }
                    idx += uint(_3517);
                }
            }
            int shadowParmSize_3 = 5;
            shadow_parms_3.shadowLightS = _3249.shadowsparmsubo[(uint(shadowParmSize_3) * ((light_parms >> uint(22)) + idx)) + 0u];
            shadow_parms_3.shadowLightT = _3249.shadowsparmsubo[(uint(shadowParmSize_3) * ((light_parms >> uint(22)) + idx)) + 1u];
            shadow_parms_3.shadowLightR = _3249.shadowsparmsubo[(uint(shadowParmSize_3) * ((light_parms >> uint(22)) + idx)) + 2u];
            shadow_parms_3.shadowLightQ = _3249.shadowsparmsubo[(uint(shadowParmSize_3) * ((light_parms >> uint(22)) + idx)) + 3u];
            shadow_parms_3.shadowAtlasScaleBias = _3249.shadowsparmsubo[(uint(shadowParmSize_3) * ((light_parms >> uint(22)) + idx)) + 4u];
            vec4 shadowTC_1 = vec4((pos.x * shadow_parms_3.shadowLightS.x) + ((pos.y * shadow_parms_3.shadowLightS.y) + ((pos.z * shadow_parms_3.shadowLightS.z) + shadow_parms_3.shadowLightS.w)), (pos.x * shadow_parms_3.shadowLightT.x) + ((pos.y * shadow_parms_3.shadowLightT.y) + ((pos.z * shadow_parms_3.shadowLightT.z) + shadow_parms_3.shadowLightT.w)), (pos.x * shadow_parms_3.shadowLightR.x) + ((pos.y * shadow_parms_3.shadowLightR.y) + ((pos.z * shadow_parms_3.shadowLightR.z) + shadow_parms_3.shadowLightR.w)), (pos.x * shadow_parms_3.shadowLightQ.x) + ((pos.y * shadow_parms_3.shadowLightQ.y) + ((pos.z * shadow_parms_3.shadowLightQ.z) + shadow_parms_3.shadowLightQ.w)));
            vec3 _3673 = shadowTC_1.xyz / vec3(shadowTC_1.w);
            shadowTC_1 = vec4(_3673.x, _3673.y, _3673.z, shadowTC_1.w);
            bool _3678 = shadowTC_1.x > 0.0;
            bool _3684;
            if (_3678)
            {
                _3684 = shadowTC_1.x < 1.0;
            }
            else
            {
                _3684 = _3678;
            }
            bool _3690;
            if (_3684)
            {
                _3690 = shadowTC_1.y > 0.0;
            }
            else
            {
                _3690 = _3684;
            }
            bool _3696;
            if (_3690)
            {
                _3696 = shadowTC_1.y < 1.0;
            }
            else
            {
                _3696 = _3690;
            }
            if (_3696)
            {
                vec2 _3708 = (shadowTC_1.xy * shadow_parms_3.shadowAtlasScaleBias.xy) + shadow_parms_3.shadowAtlasScaleBias.zw;
                shadowTC_1 = vec4(_3708.x, _3708.y, shadowTC_1.z, shadowTC_1.w);
                
                //shadowTC_1.x -= vk3d_params.stereo.x; 
                
                if (false)
                {
                    vec3 param_167 = shadowTC_1.xyz;
                    shadow = shadow2Ddepth(samp_shadowatlasdepthcomparemap, param_167);
                }
                else
                {
                    vec2 uv = shadowTC_1.xy * freqLow_fragmentUniforms.shadowatlasresolution.xy;
                    vec2 shadowMapSizeInv = freqLow_fragmentUniforms.shadowatlasresolution.zw;
                    vec2 base_uv = vec2(floor(uv.x + 0.5), floor(uv.y + 0.5));
                    float s = (uv.x + 0.5) - base_uv.x;
                    float t = (uv.y + 0.5) - base_uv.y;
                    base_uv -= vec2(0.5);
                    base_uv *= shadowMapSizeInv;
                    float uw0 = 4.0 - (3.0 * s);
                    float uw1 = 7.0;
                    float uw2 = 1.0 + (3.0 * s);
                    float u0 = ((3.0 - (2.0 * s)) / uw0) - 2.0;
                    float u1 = (3.0 + s) / uw1;
                    float u2 = (s / uw2) + 2.0;
                    float vw0 = 4.0 - (3.0 * t);
                    float v0 = ((3.0 - (2.0 * t)) / vw0) - 2.0;
                    vec3 param_168 = vec3(base_uv + (vec2(u0, v0) * shadowMapSizeInv), shadowTC_1.z);
                    float s0 = (uw0 * vw0) * shadow2Ddepth(samp_shadowatlasdepthcomparemap, param_168);
                    vec3 param_169 = vec3(base_uv + (vec2(u1, v0) * shadowMapSizeInv), shadowTC_1.z);
                    float s1 = (uw1 * vw0) * shadow2Ddepth(samp_shadowatlasdepthcomparemap, param_169);
                    vec3 param_170 = vec3(base_uv + (vec2(u2, v0) * shadowMapSizeInv), shadowTC_1.z);
                    float s2 = (uw2 * vw0) * shadow2Ddepth(samp_shadowatlasdepthcomparemap, param_170);
                    shadow = (s0 + s1) + s2;
                    float vw1 = 7.0;
                    float v1 = (3.0 + t) / vw1;
                    vec3 param_171 = vec3(base_uv + (vec2(u0, v1) * shadowMapSizeInv), shadowTC_1.z);
                    float s0_1 = (uw0 * vw1) * shadow2Ddepth(samp_shadowatlasdepthcomparemap, param_171);
                    vec3 param_172 = vec3(base_uv + (vec2(u1, v1) * shadowMapSizeInv), shadowTC_1.z);
                    float s1_1 = (uw1 * vw1) * shadow2Ddepth(samp_shadowatlasdepthcomparemap, param_172);
                    vec3 param_173 = vec3(base_uv + (vec2(u2, v1) * shadowMapSizeInv), shadowTC_1.z);
                    float s2_1 = (uw2 * vw1) * shadow2Ddepth(samp_shadowatlasdepthcomparemap, param_173);
                    shadow += ((s0_1 + s1_1) + s2_1);
                    float vw2 = 1.0 + (3.0 * t);
                    float v2 = (t / vw2) + 2.0;
                    vec3 param_174 = vec3(base_uv + (vec2(u0, v2) * shadowMapSizeInv), shadowTC_1.z);
                    float s0_2 = (uw0 * vw2) * shadow2Ddepth(samp_shadowatlasdepthcomparemap, param_174);
                    vec3 param_175 = vec3(base_uv + (vec2(u1, v2) * shadowMapSizeInv), shadowTC_1.z);
                    float s1_2 = (uw1 * vw2) * shadow2Ddepth(samp_shadowatlasdepthcomparemap, param_175);
                    vec3 param_176 = vec3(base_uv + (vec2(u2, v2) * shadowMapSizeInv), shadowTC_1.z);
                    float s2_2 = (uw2 * vw2) * shadow2Ddepth(samp_shadowatlasdepthcomparemap, param_176);
                    shadow += ((s0_2 + s1_2) + s2_2);
                    shadow /= 144.0;
                }
            }
            else
            {
                if ((light_parms & 3u) == 2u)
                {
                    _4007 = 1.0;
                }
                else
                {
                    _4007 = 0.0;
                }
                shadow = _4007;
            }
            float shadow_fade = float((light_parms >> uint(16)) & 63u) / 63.0;
            float param_177 = ((shadow * shadow_fade) + 1.0) - shadow_fade;
            shadow = saturate(param_177);
        }
        uint param_178 = lightParms.colorPacked;
        vec3 light_color = (unpackRGBE(param_178) * shadow) * light_attenuation;
        float light_spec_multiplier = lightParms.specMultiplier;
        if ((light_parms & 48u) != 0u)
        {
            vec4 areaLightPlane = lightParms.areaPlane;
            vec4 areaLightPlaneU = lightParms.boxMin;
            vec4 areaLightPlaneV = lightParms.boxMax;
            float projToOrigin = dot(inputs.position, areaLightPlane.xyz) + areaLightPlane.w;
            if (projToOrigin < 0.0)
            {
                continue;
            }
            float falloffDistance = length(areaLightPlane.xyz);
            float param_179 = projToOrigin;
            float falloff_1 = saturate(param_179);
            light_color *= (falloff_1 * falloff_1);
            projToOrigin /= falloffDistance;
            areaLightPlane /= vec4(falloffDistance);
            vec3 mirrorDir = reflect(-inputs.view, inputs.normal);
            if (dot(mirrorDir, areaLightPlane.xyz) > 0.0)
            {
                mirrorDir = reflect(mirrorDir, areaLightPlane.xyz);
            }
            float projToPlane = dot(mirrorDir, areaLightPlane.xyz);
            float projLength = projToOrigin / projToPlane;
            vec3 hitPos = inputs.position - (mirrorDir * projLength);
            vec3 hitDir = hitPos - light_position;
            float u = dot(hitDir, areaLightPlaneU.xyz);
            float v = dot(hitDir, areaLightPlaneV.xyz);
            float lenCircle = length(vec2(u, v));
            float lenRect = max(abs(u), abs(v));
            if ((light_parms & 48u) == 32u)
            {
                _4152 = lenCircle;
            }
            else
            {
                _4152 = lenRect;
            }
            float len = _4152;
            if ((light_parms & 48u) == 48u)
            {
                vec2 param_180 = vec2(u, v);
                vec2 _4172 = saturate(param_180);
                projTC = vec3(_4172.x, _4172.y, projTC.z);
            }
            len = min(1.0, len) / len;
            u *= (len * areaLightPlaneU.w);
            v *= (len * areaLightPlaneV.w);
            hitDir = (areaLightPlaneU.xyz * u) + (areaLightPlaneV.xyz * v);
            light_position += hitDir;
        }
        vec3 light_color_final = light_color;
        vec3 param_181 = light_color_final;
        light_color_final = mix(vec3(GetLuma(param_181)), light_color_final, freqLow_fragmentUniforms.pbrdebugparms.www);
        vec3 light_vector_1 = normalize(light_position - inputs.position);
        float param_182 = dot(inputs.normal, light_vector_1);
        float NdotL_1 = saturate(param_182);
        uint param_183 = inputs.specular_packed;
        vec3 param_184 = inputs.normal;
        vec3 param_185 = inputs.view;
        vec3 param_186 = light_vector_1;
        vec3 param_187 = unpackR10G10B10(param_183);
        float param_188 = abs(inputs.smoothness);
        vec3 spec = specBRDF(param_184, param_185, param_186, param_187, param_188);
        uint param_189 = inputs.specular_lighting_packed;
        vec3 param_190 = (((spec * light_spec_multiplier) * light_color_final) * NdotL_1) + unpackRGBE(param_189);
        inputs.specular_lighting_packed = packRGBE(param_190);
        if ((light_parms & 256u) > 0u)
        {
            _4263 = vec3(0.0);
        }
        else
        {
            _4263 = light_color_final;
        }
        vec3 diffuse_light_color = _4263;
        vec3 normalR = mix(inputs.normal, inputs.normalSSS, freqHigh_fragmentUniforms.sssblurscale.xxx);
        vec3 normalG = mix(inputs.normal, inputs.normalSSS, freqHigh_fragmentUniforms.sssblurscale.yyy);
        vec3 normalB = mix(inputs.normal, inputs.normalSSS, freqHigh_fragmentUniforms.sssblurscale.zzz);
        vec3 param_191 = vec3(dot(normalR, light_vector_1), dot(normalG, light_vector_1), dot(normalB, light_vector_1));
        vec3 bssrdf = saturate(param_191);
        float param_192 = dot(inputs.view, -light_vector_1);
        vec3 param_193 = (freqHigh_fragmentUniforms.ssscattering.xyz * pow(saturate(param_192), freqHigh_fragmentUniforms.ssscattering.w)) * inputs.thickness;
        bssrdf += saturate(param_193);
        bssrdf = mix(vec3(NdotL_1), bssrdf, vec3(inputs.maskSSS));
        uint param_194 = inputs.diffuse_lighting_packed;
        vec3 param_195 = (diffuse_light_color * bssrdf) + unpackRGBE(param_194);
        inputs.diffuse_lighting_packed = packRGBE(param_195);
    }
    uint param_196 = inputs.diffuse_lighting_packed;
    uint param_197 = inputs.albedo_packed;
    inputs.diffuse_lighting = unpackRGBE(param_196) * unpackR10G10B10(param_197);
    uint param_198 = inputs.specular_lighting_packed;
    inputs.specular_lighting = unpackRGBE(param_198);
    inputs.output_lighting = inputs.diffuse_lighting + inputs.specular_lighting;
    if (freqHigh_fragmentUniforms.pulseparms.x > 0.0)
    {
        vec2 resolution = abs(vec2(1.0) / freqHigh_fragmentUniforms.renderpositiontoviewtexture.zw);
        vec2 param_199 = gl_FragCoord.xy * 1.5;
        vec4 param_200 = freqHigh_fragmentUniforms.positiontoviewtexture;
        vec2 screenTexCoord = screenPosToTexcoord(param_199, param_200) * (resolution / vec2(32.0));
        vec4 param_201 = vec4(screenTexCoord * vec2(0.699999988079071044921875), 0.0, 0.0);
        vec4 dither = tex2Dlod(samp_echodithermap, param_201);
        float fresnel = 1.0 - dot(inputs.normal, normalize(-vofi_TexCoord4.xyz));
        float magnitude = 1.0;
        float pulsefrequency = freqHigh_fragmentUniforms.pulsefreq.x;
        if (freqHigh_fragmentUniforms.pulseparms.y >= freqHigh_fragmentUniforms.pulsefreq.z)
        {
            pulsefrequency = freqHigh_fragmentUniforms.pulsefreq.y;
        }
        float width = mix(freqHigh_fragmentUniforms.pulseinfo.x, freqHigh_fragmentUniforms.pulseinfo.y, freqHigh_fragmentUniforms.pulseparms.y);
        float zValue = vofi_TexCoord4.z * width;
        float pulse = (sin(zValue + (freqLow_fragmentUniforms.time.x * pulsefrequency)) * magnitude) + magnitude;
        float power_6 = freqHigh_fragmentUniforms.pulseinfo.z;
        pulse = pow(pulse, power_6);
        pulse *= fresnel;
        float edgeGlow = pow(fresnel, 4.0);
        float param_202 = (dither.x * fresnel) + edgeGlow;
        vec3 finalPulse = (freqHigh_fragmentUniforms.pulsecolor.xyz * saturate(param_202)) * 2.0;
        finalPulse /= freqHigh_fragmentUniforms.hdrcolorfilter.xyz;
        vec3 finalPulseColor = finalPulse * pulse;
        float _4495;
        if (freqLow_fragmentUniforms.rendermode.x == 0.0)
        {
            _4495 = 1.0;
        }
        else
        {
            _4495 = 0.699999988079071044921875;
        }
        float saturation = _4495;
        float _4504;
        if (freqLow_fragmentUniforms.rendermode.x == 0.0)
        {
            _4504 = 1.0;
        }
        else
        {
            _4504 = 0.5;
        }
        float blendScale = _4504;
        vec3 param_203 = finalPulseColor;
        inputs.diffuse_lighting += (max(vec3(0.0), mix(vec3(GetLuma(param_203)), finalPulseColor, vec3(saturation))) * blendScale);
    }
    if (freqHigh_fragmentUniforms.bfgdeathexplosion.w > 0.0)
    {
        vec4 param_204 = vec4((vofi_TexCoord0.xy * vec2(7.0)) + vec2(0.0, freqLow_fragmentUniforms.time.x * 3.0), 0.0, 0.0);
        vec4 _noise = tex2Dlod(samp_magnificationclouds, param_204);
        vec4 param_205 = _noise;
        _noise = DeGamma(param_205);
        float fade = 1.0 - (freqHigh_fragmentUniforms.bfgdeathexplosion.w * freqHigh_fragmentUniforms.bfgdeathexplosion.w);
        inputs.diffuse_lighting += mix(inputs.diffuse_lighting, ((freqHigh_fragmentUniforms.bfgdeathexplosion.xyz * _noise.z) * _noise.z) * 20.0, vec3(freqHigh_fragmentUniforms.bfgdeathexplosion.w));
    }
    if (freqHigh_fragmentUniforms.siphondamage.w > 0.0)
    {
        vec2 resolution_1 = abs(vec2(1.0) / freqHigh_fragmentUniforms.renderpositiontoviewtexture.zw);
        vec2 param_206 = gl_FragCoord.xy * 1.5;
        vec4 param_207 = freqHigh_fragmentUniforms.positiontoviewtexture;
        vec2 screenTexCoord_1 = screenPosToTexcoord(param_206, param_207) * (resolution_1 / vec2(32.0));
        vec4 param_208 = vec4((screenTexCoord_1 * vec2(0.0199999995529651641845703125, 0.00999999977648258209228515625)) + vec2(0.0, (freqLow_fragmentUniforms.time.x * 2.0) * freqHigh_fragmentUniforms.siphondamage.w), 0.0, 0.0);
        vec4 clouds = tex2Dlod(samp_magnificationclouds, param_208);
        vec4 param_209 = vec4((screenTexCoord_1 * vec2(0.00999999977648258209228515625)) + vec2(0.0, (freqLow_fragmentUniforms.time.x * 3.0) * freqHigh_fragmentUniforms.siphondamage.w), 0.0, 0.0);
        vec4 clouds2 = tex2Dlod(samp_magnificationclouds, param_209);
        vec3 _4645 = clouds.xyz * (clouds.xyz * clouds.xyz);
        clouds = vec4(_4645.x, _4645.y, _4645.z, clouds.w);
        vec3 _4655 = clouds2.xyz * (clouds2.xyz * clouds2.xyz);
        clouds2 = vec4(_4655.x, _4655.y, _4655.z, clouds2.w);
        float fresnel_1 = 1.0 - dot(inputs.normal, normalize(-vofi_TexCoord4.xyz));
        float _inverse = 1.0 - fresnel_1;
        float width_1 = mix(freqHigh_fragmentUniforms.pulseinfo.x, freqHigh_fragmentUniforms.pulseinfo.y, freqHigh_fragmentUniforms.pulseparms.y);
        float zValue_1 = (vofi_TexCoord4.z + freqLow_fragmentUniforms.globalvieworigin.z) * width_1;
        fresnel_1 *= ((fresnel_1 * fresnel_1) * fresnel_1);
        vec3 finalPulse_1 = ((clouds2.xxx * vec3((_inverse * _inverse) * _inverse)) * freqHigh_fragmentUniforms.siphondamage.xyz) * 3.0;
        vec3 param_210 = clouds.xxx * vec3(fresnel_1);
        finalPulse_1 += ((saturate(param_210) * freqHigh_fragmentUniforms.siphondamage.xyz) * 3.0);
        inputs.diffuse_lighting += finalPulse_1;
    }
    inputs.diffuse_lighting += (vec3((freqHigh_fragmentUniforms.bloommaskscale.x * inputs.lightmap.x) * inputs.lightmap.x) * freqHigh_fragmentUniforms.bloomcolor.xyz);
    if (freqHigh_fragmentUniforms.deathfadeopacity.x < 1.0)
    {
        vec2 texcoord = gl_FragCoord.xy * 0.00390625;
        vec4 param_211 = vec4(vofi_TexCoord0.xy * freqHigh_fragmentUniforms.tiling.xy, 0.0, 0.0);
        float dither_1 = tex2Dlod(samp_magnificationclouds, param_211).x;
        float param_212 = abs(clamp((freqHigh_fragmentUniforms.deathfadeopacity.x - (dither_1 * 0.5)) - 0.100000001490116119384765625, -1.0, 0.0));
        dither_1 = saturate(param_212);
        dither_1 *= 600.0;
        inputs.diffuse_lighting += (vec3(dither_1) * vec3(1.0, 0.00999999977648258209228515625, 0.0));
    }
    vec3 _4795 = inputs.diffuse_lighting + inputs.specular_lighting;
    out_FragColor0 = vec4(_4795.x, _4795.y, _4795.z, out_FragColor0.w);
    vec3 param_213 = inputs.normal;
    bool param_214 = false;
    vec2 _4803 = NormalOctEncode(param_213, param_214);
    out_FragColor1 = vec4(_4803.x, _4803.y, out_FragColor1.z, out_FragColor1.w);
    float param_215 = inputs.specular.x;
    float param_216 = inputs.specular.y;
    float param_217 = inputs.specular.z;
    float param_218 = inputs.smoothness;
    out_FragColor2 = vec4(fastSqrtNR0(param_215), fastSqrtNR0(param_216), fastSqrtNR0(param_217), SmoothnessEncode(param_218));
    vec3 _4829 = out_FragColor0.xyz + freqLow_fragmentUniforms.highlightcolor.xyz;
    out_FragColor0 = vec4(_4829.x, _4829.y, _4829.z, out_FragColor0.w);
}





