#define DIRECT 0
#define INDIRECT_AND_AO 1
#define SPECULAR_AND_CENTER_DIST 2
#define LUM_MOMENTS 2
#define VARIANCE 3
#define RAYHITPOS_AND_LUM 3

#define TOP 0
#define BOTTOM 1

#ifdef WORKING_PASS
void workingLightBufferWrite(ivec2 coord, int location, vec4 data) {
    imageStore(colorimg4, coord + ivec2(resolution.x*0.5*location, 0), data);
}

void workingLightBufferWrite(ivec2 coord, int location, int layer, vec4 data) {
    imageStore(colorimg4, coord + ivec2(resolution.x*0.5*location, resolution.y*0.5*layer), data);
}

#ifdef READ
vec4 workingLightBufferRead(ivec2 coord, int location, int layer) {
    return texelFetch(colortex4, coord + ivec2(resolution.x*0.5*location, resolution.y*0.5*layer), 0);
}
#endif

#endif

#ifdef HISTORY_PASS
void historyLightBufferWrite(ivec2 coord, int location, vec4 data) {
    imageStore(colorimg1, coord + ivec2(resolution.x*0.5*location, 0), data);
}

#ifdef READ
vec4 historyLightBufferRead(ivec2 coord, int location) {
    return texelFetch(colortex1, coord + ivec2(resolution.x*0.5*location, 0), 0);
}
#endif
#endif

#ifdef READ
vec4 lightBufferRead(sampler2D tex, ivec2 coord, int location, int layer) {
    return texelFetch(tex, coord + ivec2(resolution.x*0.5*location, resolution.y*0.5*layer), 0);
}
#endif