#version 450
 #extension GL_EXT_multiview : enable
// Vk3DVision SinglePass
///////////////////////////////////////////////////////////////////////////////

#define STEREO 1

#define VIEW gl_ViewIndex

// 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 
 ///////////////////////////////////////////////////////////////////////////////
// Laser un Burnable surfaces

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


   

layout(set = 0, binding = 0, std140) uniform _47_49
{
    vec4 _m0;
    vec4 _m1;
    vec4 _m2;
    vec4 _m3;
    vec4 _m4;
} _49;

layout(set = 1, binding = 0, std140) uniform _117_119
{
    vec4 _m0;
    vec4 _m1;
    vec4 _m2;
    vec4 _m3;
    vec4 _m4;
    vec4 _m5;
    vec4 _m6;
} _119;

layout(set = 2, binding = 0, std140) uniform _176_178
{
    vec4 _m0;
    vec4 _m1;
    vec4 _m2;
} _178;

layout(set = 0, binding = 1, std430) restrict readonly buffer _246_248
{
    vec4 _m0[];
} _248;

layout(push_constant, std430) uniform _242_244
{
    int _m0;
    int _m1;
} _244;

layout(set = 2, binding = 1) uniform SAMPLER_2D _112;

layout(location = 2) in vec4 _114;
layout(location = 0) out vec4 _240;

float _21(vec4 _19, vec4 _20)
{
    return dot(_19, _20);
}

float _14(float _13)
{
    return clamp(_13, 0.0, 1.0);
}

void _10(float _9)
{
    if (_9 < 0.0)
    {
        discard;
    }
}

void main()
{
    vec2 _42 = gl_FragCoord.xy * _49._m0.xy;
    
    _42.x -= vk3d_params[VIEW].stereo.x*0.5;
    
    _42.y = 1.0 - _42.y;
    vec4 _63 = vec4((_42.x * 2.0) - 1.0, (_42.y * 2.0) - 1.0, gl_FragCoord.z, 1.0);
    vec3 _81;
    _81.x = dot(_63, _49._m1);
    _81.y = dot(_63, _49._m2);
    _81.z = dot(_63, _49._m3);
    _81 /= vec3(dot(_63, _49._m4));
    float _108 = SAMPLE_TEXTURE(_112, _114.xy * vec2(_119._m3.w)).y;
    vec4 _136 = vec4(_119._m1.xyz, 1.0);
    vec4 _137 = _119._m4;
    vec3 _128;
    _128.x = _21(_136, _137);
    vec4 _150 = vec4(_119._m1.xyz, 1.0);
    vec4 _151 = _119._m5;
    _128.y = _21(_150, _151);
    vec4 _164 = vec4(_119._m1.xyz, 1.0);
    vec4 _165 = _119._m6;
    _128.z = _21(_164, _165);
    vec3 _170 = _128 - _81;
    float _174 = (_108 * _178._m2.x) + (1.0 - _178._m2.x);
    float _186 = length(_170) * _174;
    vec2 _191 = vec2(6.666666507720947265625, 10.0);
    float _195 = _186 - _119._m2.w;
    float _205 = _195 * _191.x;
    float _200 = _14(_205);
    float _212 = _195 * _191.y;
    float _207 = _14(_212);
    float _222 = (1.0 - _207) * _108;
    vec3 _214 = _119._m3.xyz * _14(_222);
    float _225 = _200;
    float _232 = ceil(_225 - 0.001000000047497451305389404296875);
    float _227 = _14(_232);
    float _237 = _227 - 9.9999997473787516355514526367188e-05;
    _10(_237);
    _240 = vec4(0.0);
}


