#version 400
#extension GL_EXT_gpu_shader4 : enable

// We DO use glEnable( GL_COLOR_LOGIC_OP ) during down scans!
#pragma IGLU_ENABLE 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 output voxel buffers fragOutput[]
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 = ceil(fragCoord.x*width) - 2.0f;	
	vec2 coord0 = vec2( (xLoc) / width, fragCoord.y );

	fragOutput0 = (coord0.x >= 0 ? texture( voxels0, coord0 ) : uvec4( 0u ) );
	fragOutput1 = (coord0.x >= 0 ? texture( voxels1, coord0 ) : uvec4( 0u ) );
	fragOutput2 = (coord0.x >= 0 ? texture( voxels2, coord0 ) : uvec4( 0u ) );
	fragOutput3 = (coord0.x >= 0 ? texture( voxels3, coord0 ) : uvec4( 0u ) );
}
