//3
#version 460
 #extension GL_EXT_multiview : enable
// Vk3DVision SinglePass
///////////////////////////////////////////////////////////////////////////////

#define STEREO 1


#define VIEW gl_LaunchIDEXT.z / (gl_LaunchSizeEXT.z / 2)
#define LaunchIDEXT uvec3(gl_LaunchIDEXT.x, gl_LaunchIDEXT.y, (gl_LaunchIDEXT.z < (gl_LaunchSizeEXT.z + 1) / 2 ? gl_LaunchIDEXT.z : gl_LaunchIDEXT.z - (gl_LaunchSizeEXT.z + 1) / 2))
#define LaunchSizeEXT uvec3(gl_LaunchSizeEXT.x, gl_LaunchSizeEXT.y, (gl_LaunchSizeEXT.z + 1) / 2)

// Stereo and Mono Texture Sampling
#if(STEREO == 1)
	#define SAMPLER_2D sampler2DArray
	#define USAMPLER_2D usampler2DArray
	#define ISAMPLER_2D isampler2DArray
	#define IMAGE_2D image2DArray
	#define UIMAGE_2D uimage2DArray
	#define UTEXTURE_2D utexture2DArray
	#define TEXTURE_2D texture2DArray
	#define SAMPLE_TEXTURE(Sampler, uv) texture(Sampler, vec3(uv, VIEW))
	#define SAMPLE_TEXTURE1(Sampler, uv, bias) texture(Sampler, vec3(uv, VIEW), bias)
	#define IMAGE_LOAD(Image2D, pos) imageLoad(Image2D, ivec3(pos, VIEW))
	#define IMAGE_STORE(Image2D, pos, result) imageStore(Image2D, ivec3(pos, VIEW), result)
	#define TEXEL_FETCH(Sampler, uv, lod) texelFetch(Sampler, ivec3(uv, VIEW), lod)
	#define TEXEL_FETCH_OFFSET(Sampler, uv, lod, offset) texelFetchOffset(Sampler, ivec3(uv, VIEW), lod, offset)
	#define TEXTURE_LOD(Sampler, uv, lod) textureLod(Sampler, vec3(uv, VIEW), lod)
	#define TEXTURE_LOD_OFFSET(Sampler, uv, lod, offset) textureLodOffset(Sampler, vec3(uv, VIEW), lod, offset)
	#define TEXTURE_GATHER(Sampler, uv, comp) textureGather(Sampler, vec3(uv, VIEW), comp)
	#define TEXTURE_GATHER1(Sampler, uv) textureGather(Sampler, vec3(uv, VIEW))
	#define TEXTURE_GATHER_OFFSET(Sampler, uv, offset, comp) textureGatherOffset(Sampler, vec3(uv, VIEW), offset, comp)
	#define TEXTURE_GATHER_OFFSETS(Sampler, uv, offset) textureGatherOffsets(Sampler, vec3(uv, VIEW), offset)
	#define TEXTURE_GATHER_OFFSETS1(Sampler, uv, offset, comp) textureGatherOffsets(Sampler, vec3(uv, VIEW), offset, comp)
	#define TEXTURE_SIZE(Sampler, lod) textureSize(Sampler, lod).xy
	#define TEXTURE_GRAD(Sampler, P, dPdx, dPdy) textureGrad(Sampler, vec3(P, VIEW), dPdx, dPdy)
#else
	#define SAMPLER_2D sampler2D
	#define USAMPLER_2D usampler2D
	#define ISAMPLER_2D isampler2D
	#define IMAGE_2D image2D
	#define UIMAGE_2D uimage2D
	#define UTEXTURE_2D utexture2D
	#define TEXTURE_2D texture2D
	#define SAMPLE_TEXTURE(Sampler, uv) texture(Sampler, uv)
	#define SAMPLE_TEXTURE1(Sampler, uv, bias) texture(Sampler, uv, bias)
	#define IMAGE_LOAD(Image2D, pos) imageLoad(Image2D, pos)
	#define IMAGE_STORE(Image2D, pos, result) imageStore(Image2D, pos, result)
	#define TEXEL_FETCH(Sampler, uv, lod) texelFetch(Sampler, uv, lod)
	#define TEXEL_FETCH_OFFSET(Sampler, uv, lod, offset) texelFetchOffset(Sampler, uv, lod, offset)
	#define TEXTURE_LOD(Sampler, uv, lod) textureLod(Sampler, uv, lod)
	#define TEXTURE_LOD_OFFSET(Sampler, uv, lod, offset) textureLodOffset(Sampler, uv, lod, offset)
	#define TEXTURE_GATHER(Sampler, uv, comp) textureGather(Sampler, uv, comp)
	#define TEXTURE_GATHER1(Sampler, uv, comp) textureGather(Sampler, uv)
	#define TEXTURE_GATHER_OFFSET(Sampler, uv, offset, comp) textureGatherOffset(Sampler, uv, offset, comp)
	#define TEXTURE_GATHER_OFFSETS(Sampler, uv, offset) textureGatherOffsets(Sampler, uv, offset)
	#define TEXTURE_GATHER_OFFSETS1(Sampler, uv, offset, comp) textureGatherOffsets(Sampler, uv, offset, comp)
	#define TEXTURE_SIZE(Sampler, lod) textureSize(Sampler, lod)
	#define TEXTURE_GRAD(Sampler, P, dPdx, dPdy) textureGrad(Sampler, P, dPdx, dPdy)
#endif 
 ///////////////////////////////////////////////////////////////////////////////
#extension GL_EXT_ray_tracing : require

struct _663
{
    vec3 _m0;
    vec3 _m1;
    float _m2;
    float _m3;
};

struct _680
{
    uint _m0;
    float _m1;
    uint _m2;
};

struct _724
{
    uint _m0;
    uint _m1;
};


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

layout(set = 0, binding = 0, std140) uniform _187_189
{
    vec4 _m0;
    vec4 _m1;
    vec4 _m2;
    vec4 _m3;
    vec4 _m4;
    vec4 _m5;
    vec4 _m6;
    vec4 _m7;
    vec4 _m8;
    vec4 _m9;
    vec4 _m10;
    vec4 _m11;
    vec4 _m12;
    vec4 _m13;
    vec4 _m14;
    vec4 _m15;
    vec4 _m16;
    vec4 _m17;
    vec4 _m18;
    vec4 _m19;
    vec4 _m20;
    vec4 _m21;
    vec4 _m22;
    vec4 _m23;
    vec4 _m24;
    vec4 _m25;
    vec4 _m26;
    vec4 _m27;
    vec4 _m28;
    vec4 _m29;
    vec4 _m30;
    vec4 _m31;
    vec4 _m32;
    vec4 _m33;
    vec4 _m34;
    vec4 _m35;
    vec4 _m36;
    vec4 _m37;
    vec4 _m38;
    vec4 _m39;
    vec4 _m40;
    vec4 _m41;
    vec4 _m42;
    vec4 _m43;
    vec4 _m44;
    vec4 _m45;
    vec4 _m46;
    vec4 _m47;
    vec4 _m48;
    vec4 _m49;
    vec4 _m50;
    vec4 _m51;
    float _m52;
    float _m53;
    float _m54;
    float _m55;
    float _m56;
    float _m57;
    float _m58;
    float _m59;
    float _m60;
    float _m61;
    float _m62;
    float _m63;
    float _m64;
    float _m65;
    float _m66;
    float _m67;
    float _m68;
    float _m69;
    float _m70;
    float _m71;
    float _m72;
    float _m73;
    float _m74;
    float _m75;
    uint _m76;
    float _m77;
    float _m78;
    float _m79;
    float _m80;
    float _m81;
    float _m82;
    float _m83;
    float _m84;
    float _m85;
    float _m86;
    float _m87;
    float _m88;
    float _m89;
    float _m90;
    float _m91;
    float _m92;
    float _m93;
    float _m94;
    float _m95;
    uint _m96;
    float _m97;
    float _m98;
    float _m99;
    float _m100;
    float _m101;
    float _m102;
    float _m103;
    float _m104;
    float _m105;
    float _m106;
    float _m107;
    float _m108;
    float _m109;
    float _m110;
    float _m111;
    float _m112;
    float _m113;
    float _m114;
    float _m115;
} _189;

layout(set = 0, binding = 30, std140) uniform _858_860
{
    vec4 _m0[64];
} _860;

layout(set = 0, binding = 64, std140) uniform _878_880
{
    vec4 _m0[4095];
} _880;

layout(set = 0, binding = 58) uniform TEXTURE_2D _367;
layout(set = 0, binding = 43) uniform sampler _371;
layout(set = 0, binding = 72) uniform TEXTURE_2D _401;
layout(set = 0, binding = 5) uniform TEXTURE_2D _433;
layout(set = 0, binding = 75) uniform TEXTURE_2D _475;
layout(set = 0, binding = 7) uniform TEXTURE_2D _493;
layout(set = 0, binding = 37) uniform sampler _495;
layout(set = 0, binding = 8) uniform TEXTURE_2D _572;
layout(set = 0, binding = 56) uniform TEXTURE_2D _609;
layout(location = 0) rayPayloadEXT _680 _682;
layout(set = 0, binding = 68) uniform accelerationStructureEXT _704;
layout(location = 1) rayPayloadEXT _724 _726;
layout(set = 0, binding = 6) uniform accelerationStructureEXT _735;
layout(set = 0, binding = 57) uniform TEXTURE_2D _784;
layout(set = 0, binding = 24, r11f_g11f_b10f) uniform writeonly IMAGE_2D _816;
layout(set = 0, binding = 26, rg8) uniform writeonly IMAGE_2D _826;
layout(set = 2, binding = 0) uniform texture2D _836[34816];
layout(set = 0, binding = 1) uniform sampler _837;
layout(set = 0, binding = 2) uniform texture3D _840;
layout(set = 0, binding = 3) uniform texture3D _841;
layout(set = 0, binding = 9) uniform sampler _842;
layout(set = 0, binding = 10, r11f_g11f_b10f) uniform readonly writeonly IMAGE_2D _843;
layout(set = 0, binding = 11) uniform sampler _844;
layout(set = 0, binding = 12) uniform sampler _845;
layout(set = 0, binding = 13) uniform TEXTURE_2D _846;
layout(set = 0, binding = 15) uniform textureCubeArray _849;
layout(set = 0, binding = 23) uniform sampler _850;
layout(set = 0, binding = 25, r32f) uniform readonly writeonly IMAGE_2D _853;
layout(set = 0, binding = 27, rg8) uniform readonly writeonly IMAGE_2D _854;
layout(set = 0, binding = 28, r11f_g11f_b10f) uniform readonly writeonly IMAGE_2D _855;
layout(set = 0, binding = 36) uniform sampler _861;
layout(set = 0, binding = 38) uniform sampler _862;
layout(set = 0, binding = 39) uniform TEXTURE_2D _863;
layout(set = 0, binding = 40) uniform sampler _864;
layout(set = 0, binding = 41) uniform sampler _865;
layout(set = 0, binding = 44) uniform sampler _866;
layout(set = 0, binding = 45) uniform sampler _867;
layout(set = 0, binding = 46) uniform texture2DArray _870;
layout(set = 0, binding = 50) uniform TEXTURE_2D _871;
layout(set = 0, binding = 54) uniform TEXTURE_2D _872;
layout(set = 0, binding = 60) uniform TEXTURE_2D _873;
layout(set = 0, binding = 62) uniform TEXTURE_2D _874;
layout(set = 0, binding = 63) uniform sampler _875;
layout(set = 0, binding = 65) uniform sampler _881;
layout(set = 0, binding = 66) uniform sampler _882;
layout(set = 0, binding = 70) uniform sampler _883;
layout(set = 0, binding = 71) uniform TEXTURE_2D _884;
layout(set = 0, binding = 73) uniform TEXTURE_2D _885;
layout(set = 0, binding = 74) uniform TEXTURE_2D _886;
layout(set = 0, binding = 76) uniform sampler _887;
layout(set = 0, binding = 77) uniform TEXTURE_2D _888;

uint _84;
uint _86;
uint _88;
uint _90;
uint _92;
uint _94;
uint _96;
uint _97;
uint _99;
uint _100;
uint _102;
uint _104;
uint _106;
uint _108;
uint _110;
uint _112;
uint _114;
uint _116;
uint _118;

float _37(float _36)
{
    return _36 * _36;
}

vec2 _81(float _80)
{
    float _327 = (_80 * 2.0) - 1.0;
    float _331 = _327;
    return vec2(_37(_331), float(_327 > 0.0));
}

float _10(float _9)
{
    return clamp(_9, 0.0, 1.0);
}

vec3 _34(vec3 _33)
{
    return _33 * _33;
}

float _28(float _25, float _26, float _27)
{
    return max(_25, max(_26, _27));
}

vec2 _72(vec2 _71)
{
    return (vec2(1.0) - abs(_71.yx)) * vec2((_71.x >= 0.0) ? 1.0 : (-1.0), (_71.y >= 0.0) ? 1.0 : (-1.0));
}

vec3 _77(inout vec2 _75, bool _76)
{
    if (_76)
    {
        _75 = (_75 * 2.0) - vec2(1.0);
    }
    vec3 _298;
    _298.z = (1.0 - abs(_75.x)) - abs(_75.y);
    vec2 _311;
    if (_298.z >= 0.0)
    {
        _311 = _75;
    }
    else
    {
        vec2 _316 = _75;
        _311 = _72(_316);
    }
    _298 = vec3(_311.x, _311.y, _298.z);
    _298 = normalize(_298);
    return _298;
}

float _59(inout float _57, bool _58)
{
    if (_58)
    {
        _57 += (float(_57 < _189._m54) * _189._m53);
    }
    float _206 = _57;
    return _189._m34.w / (_10(_206) + _189._m34.z);
}

vec3 _63(vec2 _62)
{
    return (vec3(_189._m63, _189._m64, _189._m65) + (vec3(_189._m57, _189._m58, _189._m59) * _62.x)) + (vec3(_189._m60, _189._m61, _189._m62) * _62.y);
}

vec3 _68(vec2 _66, float _67)
{
    vec3 _255 = _63(_66);
    return vec3(_189._m69, _189._m70, _189._m71) + (_255 * _67);
}

float _43(float _42)
{
    return sqrt(_42);
}

vec4 _48(uint _47)
{
    return unpackUnorm4x8(_47).wzyx;
}

float _40(float _39)
{
    return exp2(_39);
}

vec3 _52(uint _51)
{
    uint _166 = _51;
    vec4 _165 = _48(_166);
    float _178 = (_165.w * 255.0) - 128.0;
    return _165.xyz * _40(_178);
}

uint _17(vec2 _16)
{
    return packHalf2x16(_16);
}

vec2 _22(uint _21)
{
    return unpackHalf2x16(_21);
}

void main()
{
    _84 = 2147483648u;
    _86 = 1073741824u;
    _88 = 0u;
    _90 = 268435456u;
    _92 = 536870912u;
    _94 = 805306368u;
    _96 = 1073741824u;
    _97 = 1342177280u;
    _99 = 0u;
    _100 = 16777216u;
    _102 = 33554432u;
    _104 = 50331648u;
    _106 = 67108864u;
    _108 = 83886080u;
    _110 = 100663296u;
    _112 = 117440512u;
    _114 = 134217728u;
    _116 = 150994944u;
    _118 = 167772160u;
    ivec2 _342 = ivec2(LaunchIDEXT.xy);
    vec2 _350 = (vec2(_342) + vec2(0.5)) / vec2(_189._m91, _189._m92);

    float stereo = 0.09097;
    float convergence = 0.5;
    
    if (VIEW == 0)
    stereo = -1 * stereo;

    _350.x -= stereo * 0.5;

    vec2 _364 = TEXTURE_LOD(SAMPLER_2D(_367, _371), vec4(_350, 0.0, 0.0).xy, vec4(_350, 0.0, 0.0).w).xy;
    float _387 = _364.x;
    uint _390 = uint((_364.y * 255.0) + 0.5);
    float _396 = 1.0;
    if (_390 == 1u)
    {
        _396 = 1.0 - TEXTURE_LOD(SAMPLER_2D(_401, _371), vec4(_350, 0.0, 0.0).xy, vec4(_350, 0.0, 0.0).w).x;
        _396 += (float(_396 < _189._m54) * _189._m53);
    }
    else
    {
        if (_390 == 2u)
        {
            _396 = 1.0 - TEXTURE_LOD(SAMPLER_2D(_433, _371), vec4(_350, 0.0, 0.0).xy, vec4(_350, 0.0, 0.0).w).x;
            _396 += (float(_396 < _189._m54) * _189._m53);
        }
        else
        {
            if (_390 == 3u)
            {
                vec2 _465 = vec2(_350.x * _189._m109, _350.y);
                _396 = 1.0 - TEXTURE_LOD(SAMPLER_2D(_475, _371), vec4(_465, 0.0, 0.0).xy, vec4(_465, 0.0, 0.0).w).x;
            }
        }
    }
    vec4 _492 = TEXTURE_LOD(SAMPLER_2D(_493, _495), vec4(_350, 0.0, 0.0).xy, vec4(_350, 0.0, 0.0).w);
    float _510 = _492.w;
    vec2 _509 = _81(_510);
    float _514 = float(_509.y > 0.0) * _509.x;
    float _522 = _189._m38.z;
    float _533 = 1.0 - ((1.0 - _514) / (1.0 - _522));
    float _526 = _10(_533);
    vec3 _536 = _492.xyz;
    vec3 _535 = _34(_536);
    float _541 = _535.x;
    float _544 = _535.y;
    float _547 = _535.z;
    float _540 = _28(_541, _544, _547);
    float _553 = 0.01568627543747425079345703125;
    float _551 = _37(_553);
    if ((((_396 < 1.0) && (_540 >= _551)) && (_387 < _526)) && (_514 > _522))
    {
        vec2 _588 = TEXTURE_LOD(SAMPLER_2D(_572, _371), vec4(_350, 0.0, 0.0).xy, vec4(_350, 0.0, 0.0).w).xy;
        bool _590 = false;
        vec3 _591 = _77(_588, _590);
        vec3 _571 = _591;
        float _593 = _396;
        bool _595 = false;
        float _596 = _59(_593, _595);
        float _592 = _596;
        vec3 _597 = _68(_350 + (_189._m39.xy * 0.5), _592);

    //

        float _608 = TEXTURE_LOD(SAMPLER_2D(_609, _371), vec4(_350, 0.0, 0.0).xy, vec4(_350, 0.0, 0.0).w).x;
        uint _625 = uint(((_390 == 1u) && (_608 == 0.0)) ? 254 : 255);
        vec3 _635 = vec3(0.0);
        float _637 = 0.0;
        float _638 = 1000000015047466219876688855040.0;

        // _597 is most likely to be the position
        vec3 _640 = -normalize(_597 - vec3(_189._m69, _189._m70, _189._m71));
        vec3 _652 = normalize(reflect(-_640, _571));
        float _658 = 0.001000000047497451305389404296875 / (1.0 - _396);
        _663 _665;
        
        // Pos is here
        _665._m0 = _597 + (_571 * _658);
        _665._m1 = _652;
        _665._m2 = 0.0;
        _665._m3 = 1000000015047466219876688855040.0;
        _682._m0 = 0u;
        _682._m1 = 1000000015047466219876688855040.0;
        float _688 = _514;
        float _691 = _43(_688);
        uint _687 = uint(_10(_691) * 127.0);
        _682._m2 = 256u | (_687 << uint(9));
        traceRayEXT(_704, 16u, _625, 0u, 2u, 0u, _665._m0, _665._m2, _665._m1, _665._m3, 0);
        uint _716 = _682._m0;
        _635 = _52(_716);
        bool _720 = !(_682._m1 == 1000000015047466219876688855040.0);
        _726._m0 = 0u;
        vec2 _729 = vec2(0.0, 1.0);
        _726._m1 = _17(_729);
        _665._m3 = _682._m1;
        traceRayEXT(_735, 24u, _625, 1u, 2u, 1u, _665._m0, _665._m2, _665._m1, _665._m3, 1);
        uint _748 = _726._m1;
        vec2 _747 = _22(_748);
        uint _753 = _726._m0;
        vec3 _752 = _52(_753) / vec3(clamp(_747.x, 9.9999997473787516355514526367188e-05, 1000.0));
        float _764 = _747.y;
        _635 = mix(_752, _635, vec3(_764 * float(_720)));
        _637 = 1.0 - (float(!_720) * _764);
        _638 = _682._m1;
        vec3 _783 = TEXTURE_LOD(SAMPLER_2D(_784, _371), vec4(_350, 0.0, 0.0).xy, vec4(_350, 0.0, 0.0).w).xyz;
        float _800 = _637 * (_526 - _387);
        _783 += (_635 * _800);
        _387 += _800;
        IMAGE_STORE(_816, _342, vec4(_783, 0.0));
        IMAGE_STORE(_826, _342, vec4(_387, _364.y, 0.0, 0.0));
    }
}


