Sorry for not being clear enough.
I am not changing the attachments during rendering, i do all the assigning at the fbo initiations, and my problem still persists.
My initiation code for the first fbo:
glGenFramebuffers(1, &frameBufferMainId);
glBindFramebuffer(GL_FRAMEBUFFER, frameBufferMainId);
GLuint depthBuffer;
glGenRenderbuffers(1, &depthBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer);
glRenderbufferStorage(GL_RENDERBUFFER,GL_DEPTH_COMPONENT,1000,800);
glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_RENDERBUFFER, depthBuffer);
glGenTextures(1,&mainColorTextureId);
glBindTexture(GL_TEXTURE_2D,mainColorTextureId);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB32F,1000,800,0,GL_RGB,GL_UNSIGNED_BYTE,NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,mainColorTextureId,0);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glGenTextures(1,&mainNormalTextureId);
glBindTexture(GL_TEXTURE_2D,mainNormalTextureId);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB32F,1000,800,0,GL_RGB,GL_FLOAT,NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT1,GL_TEXTURE_2D,mainNormalTextureId,0);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
//i attach 2 more textures, but the code is almost identical to the code above, so no point in showing it
And the initiation code for the second fbo:
glGenBuffers(1, &frameBufferSubId);
glBindFramebuffer(GL_FRAMEBUFFER, frameBufferSubId);
glGenTextures(1,&subTextureId);
glBindTexture(GL_TEXTURE_2D,subColorTextureId);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,1000,800,0,GL_RGB,GL_UNSIGNED_BYTE,NULL);
//if i remove this line...
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,subTextureId,0);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glGenTextures(1,&subAmbientOcclusionId);
glBindTexture(GL_TEXTURE_2D,subAmbientOcclusionTextureId);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,1000,800,0,GL_RGB,GL_UNSIGNED_BYTE,NULL);
//...and this line the rendering seems to be doing ok
glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT1,GL_TEXTURE_2D,subAmbientOcclusionTextureId,0);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);