// RT1
#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 _304
{
    vec3 _m0;
    vec3 _m1;
    float _m2;
    float _m3;
};

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

struct _358
{
    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 _209_211
{
    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;
} _211;

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

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

layout(location = 0) rayPayloadEXT _329 _331;
layout(set = 0, binding = 68) uniform accelerationStructureEXT _341;
layout(location = 1) rayPayloadEXT _358 _360;
layout(set = 0, binding = 6) uniform accelerationStructureEXT _369;
layout(set = 0, binding = 10, r11f_g11f_b10f) uniform writeonly IMAGE_2D _405;
layout(set = 2, binding = 0) uniform texture2D _421[34816];
layout(set = 0, binding = 1) uniform sampler _424;
layout(set = 0, binding = 2) uniform texture3D _427;
layout(set = 0, binding = 3) uniform texture3D _428;
layout(set = 0, binding = 5) uniform TEXTURE_2D _430;
layout(set = 0, binding = 7) uniform TEXTURE_2D _431;
layout(set = 0, binding = 8) uniform TEXTURE_2D _432;
layout(set = 0, binding = 9) uniform sampler _433;
layout(set = 0, binding = 11) uniform sampler _434;
layout(set = 0, binding = 12) uniform sampler _435;
layout(set = 0, binding = 13) uniform TEXTURE_2D _436;
layout(set = 0, binding = 15) uniform textureCubeArray _439;
layout(set = 0, binding = 23) uniform sampler _440;
layout(set = 0, binding = 24, r11f_g11f_b10f) uniform readonly writeonly IMAGE_2D _441;
layout(set = 0, binding = 25, r32f) uniform readonly writeonly IMAGE_2D _444;
layout(set = 0, binding = 26, rg8) uniform readonly writeonly IMAGE_2D _447;
layout(set = 0, binding = 27, rg8) uniform readonly writeonly IMAGE_2D _448;
layout(set = 0, binding = 28, r11f_g11f_b10f) uniform readonly writeonly IMAGE_2D _449;
layout(set = 0, binding = 36) uniform sampler _455;
layout(set = 0, binding = 37) uniform sampler _456;
layout(set = 0, binding = 38) uniform sampler _457;
layout(set = 0, binding = 39) uniform TEXTURE_2D _458;
layout(set = 0, binding = 40) uniform sampler _459;
layout(set = 0, binding = 41) uniform sampler _460;
layout(set = 0, binding = 43) uniform sampler _461;
layout(set = 0, binding = 44) uniform sampler _462;
layout(set = 0, binding = 45) uniform sampler _463;
layout(set = 0, binding = 46) uniform texture2DArray _466;
layout(set = 0, binding = 50) uniform TEXTURE_2D _467;
layout(set = 0, binding = 54) uniform TEXTURE_2D _468;
layout(set = 0, binding = 56) uniform TEXTURE_2D _469;
layout(set = 0, binding = 57) uniform TEXTURE_2D _470;
layout(set = 0, binding = 58) uniform TEXTURE_2D _471;
layout(set = 0, binding = 60) uniform TEXTURE_2D _472;
layout(set = 0, binding = 62) uniform TEXTURE_2D _473;
layout(set = 0, binding = 63) uniform sampler _474;
layout(set = 0, binding = 65) uniform sampler _480;
layout(set = 0, binding = 66) uniform sampler _481;
layout(set = 0, binding = 70) uniform sampler _482;
layout(set = 0, binding = 71) uniform TEXTURE_2D _483;
layout(set = 0, binding = 72) uniform TEXTURE_2D _484;
layout(set = 0, binding = 73) uniform TEXTURE_2D _485;
layout(set = 0, binding = 74) uniform TEXTURE_2D _486;
layout(set = 0, binding = 75) uniform TEXTURE_2D _487;
layout(set = 0, binding = 76) uniform sampler _488;
layout(set = 0, binding = 77) uniform TEXTURE_2D _489;

uint _45;
uint _47;
uint _49;
uint _51;
uint _53;
uint _55;
uint _57;
uint _58;
uint _60;
uint _61;
uint _63;
uint _65;
uint _67;
uint _69;
uint _71;
uint _73;
uint _75;
uint _77;
uint _79;

vec4 _29(vec3 _24, vec4 _25, vec4 _26, vec4 _27, vec4 _28)
{
    return vec4((_24.x * _25.x) + ((_24.y * _25.y) + ((_24.z * _25.z) + _25.w)), (_24.x * _26.x) + ((_24.y * _26.y) + ((_24.z * _26.z) + _26.w)), (_24.x * _27.x) + ((_24.y * _27.y) + ((_24.z * _27.z) + _27.w)), (_24.x * _28.x) + ((_24.y * _28.y) + ((_24.z * _28.z) + _28.w)));
}

vec4 _38(uint _37)
{
    return unpackUnorm4x8(_37).wzyx;
}

float _34(float _33)
{
    return exp2(_33);
}

vec3 _42(uint _41)
{
    uint _185 = _41;
    vec4 _184 = _38(_185);
    float _196 = (_184.w * 255.0) - 128.0;
    return _184.xyz * _34(_196);
}

uint _12(vec2 _11)
{
    return packHalf2x16(_11);
}

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

void main()
{
    _45 = 2147483648u;
    _47 = 1073741824u;
    _49 = 0u;
    _51 = 268435456u;
    _53 = 536870912u;
    _55 = 805306368u;
    _57 = 1073741824u;
    _58 = 1342177280u;
    _60 = 0u;
    _61 = 16777216u;
    _63 = 33554432u;
    _65 = 50331648u;
    _67 = 67108864u;
    _69 = 83886080u;
    _71 = 100663296u;
    _73 = 117440512u;
    _75 = 134217728u;
    _77 = 150994944u;
    _79 = 167772160u;
    vec2 _201 = (vec2(float(LaunchIDEXT.x) / _211._m36.x, float(LaunchIDEXT.y) / _211._m36.y) * 2.0) - vec2(1.0);
    _201.y = -_201.y;
    _201 += _211._m39.xy;
    vec3 _241 = vec3(_201, 0.0);
    vec3 _252 = _241;
    vec4 _254 = _211._m26;
    vec4 _257 = _211._m27;
    vec4 _260 = _211._m28;
    vec4 _263 = _211._m25;
    vec4 _247 = _29(_252, _254, _257, _260, _263);

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

    _247.x += stereo * (_247.w - convergence);

    vec3 _272 = _247.xyz / vec3(_247.w);
    _247 = vec4(_272.x, _272.y, _272.z, _247.w);
    vec3 _275 = vec3(_201, 1.0);
    vec3 _281 = _275;
    vec4 _283 = _211._m26;
    vec4 _286 = _211._m27;
    vec4 _289 = _211._m28;
    vec4 _292 = _211._m25;
    vec4 _280 = _29(_281, _283, _286, _289, _292);
    vec3 _301 = _280.xyz / vec3(_280.w);
    _280 = vec4(_301.x, _301.y, _301.z, _280.w);
    _304 _306;
    _306._m0 = _247.xyz;
    _306._m1 = normalize(_280.xyz - _247.xyz);
    _306._m2 = 0.0;
    _306._m3 = length(_280.xyz - _247.xyz);
    _331._m0 = 0u;
    _331._m1 = 1000000015047466219876688855040.0;
    _331._m2 = 65024u;
    traceRayEXT(_341, 16u, 255u, 0u, 2u, 0u, _306._m0, _306._m2, _306._m1, _306._m3, 0);
    uint _354 = _331._m0;
    vec3 _353 = _42(_354);
    _360._m0 = 0u;
    vec2 _363 = vec2(0.0, 1.0);
    _360._m1 = _12(_363);
    _306._m3 = _331._m1;
    traceRayEXT(_369, 8u, 255u, 1u, 2u, 1u, _306._m0, _306._m2, _306._m1, _306._m3, 1);
    uint _381 = _360._m1;
    vec2 _380 = _17(_381);
    uint _386 = _360._m0;
    vec3 _385 = _42(_386) / vec3(clamp(_380.x, 9.9999997473787516355514526367188e-05, 1000.0));
    _353 = mix(_385, _353, vec3(_380.y));
    IMAGE_STORE(_405, ivec2(LaunchIDEXT.xy), vec4(_353, 0.0));
}



