#version 400
#extension GL_EXT_gpu_shader4 : enable

// We do NOT use glEnable( GL_COLOR_LOGIC_OP ) during up scans!
#pragma IGLU_DISABLE COLOR_LOGIC_OP

// The fragment's texture coordinate
in vec2 fragCoord;

// The voxel buffers to upsample
uniform usampler2D voxels0, voxels1, voxels2, voxels3;

// The width of the input voxel buffers inVoxels[i]
uniform int width;   
uniform vec2 padScaleCoef;

// Output (so we can output to an integer framebuffer)
layout(location = 0) out uvec4 fragOutput0;
layout(location = 1) out uvec4 fragOutput1;
layout(location = 2) out uvec4 fragOutput2;
layout(location = 3) out uvec4 fragOutput3;

void main(void)
{
	float xLoc = floor(fragCoord.x*width);
	vec2 coord0 = vec2( (xLoc-1) / width, fragCoord.y );
	vec2 coord1 = vec2( (xLoc+0) / width, fragCoord.y );

	fragOutput0 = texture( voxels0, coord0 ) | texture( voxels0, coord1 );
	fragOutput1 = texture( voxels1, coord0 ) | texture( voxels1, coord1 );
	fragOutput2 = texture( voxels2, coord0 ) | texture( voxels2, coord1 );
	fragOutput3 = texture( voxels3, coord0 ) | texture( voxels3, coord1 );
}
