iam doing 4 passes to render the final image, but i want to reuse one Gbuffer wich is written in the 1st and read in the 2nd pass to be written in the 3rd and read in the 4th pass

that rendertarget stores the indirect illumination color and the ao.

however since my good old ATI 4650M isnt that fast, i compute the SSGI on a 4 times smaller resolution.

so after the third pass, some of the rendertarget holds the new SSGI data, while some part still stores the data written in the 1st pass wich is not needed anymore.

it would look like this:

OOOO

OOOO

NNOO

NNOO

where O is old data and N new data

the problem is that now when i read the SSGI data (N) in the 4th pass, i get some artifacts when i read data from the right or top border, because im actually reading 'O' data, wich is not what i want...

the shader for the fourth pass looks like this:

uniform sampler2D ssdiMap; uniform sampler2D ssgiMap; varying vec2 texCoord0; varying vec2 texCoord1; vec4 getGI(in vec2 coord) { coord = clamp(coord, 0.0, 0.25); return texture2D(ssgiMap, coord); } void main() { float rad = 0.0005; vec2 offsets[8] = vec2[8](vec2(rad,rad),vec2(-rad,rad),vec2(-rad,-rad),vec2(rad,-rad), vec2(0.0,rad),vec2(0.0,-rad),vec2(rad,0.0),vec2(-rad,0.0)); vec4 gi = vec4(0.0); for(int i = 0; i < 8; i++) gi += getGI(texCoord1 + offsets[i]); for(int i = 0; i < 8; i++) gi += getGI(texCoord1 + offsets[i] * 2.0); gi /= 16.0; vec4 di = texture2D(ssdiMap, texCoord0); vec3 final = (di.xyz*gi.w) + gi.xyz; //gi.xyz is GI color, gi.w is AO gl_FragColor = vec4(final, 1.0); }