Original Post
Hi, I am going to implement bloom effect as a postprocess shader. In order to do that I need to render the scene into a texture, and then do a second pass to perform a gaussian blur (rendering a quad that fills the screen with the texture rendered in first pass). I have measured FPS under various conditions (with no bloom effect yet but a dummy shader that just renders the image created in the first pass): No multisampling = 510 FPS Multisampling 4x = 510 FPS Multisampling 8x = 285 FPS FBO (not using glRenderbufferStorageMultisampleEXT) = 292 FPS FBO (using glRenderbufferStorageMultisampleEXT with 1 sample) = 230 FPS FBO + Multisampling 4x = 195 FPS What I do for FBO + multisampling is rendering into a renderbuffer with multisample support and then blit this into a texture: So various questions arise from those results: 1. This FPS drop is normal? 2. The blitting between buffers eat 292-230=62 FPS. There is some way to use a framebuffer directly as a texture? 3. What pixel format has the multisample framebuffer? It will be floating point format? I need floating point because HDR is needed for bloom effect. If someone is so kind to help me with some of them I will really appreciate it =] Thanks!
// Multi sample colorbuffer
glGenRenderbuffersEXT(1, &colorBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorBuffer);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, GL_RGBA8, width, height);
// Multi sample depth buffer
glGenRenderbuffersEXT(1, &depthBuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthBuffer);
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples, GL_DEPTH_COMPONENT, width, height);
// Attach them
glGenFramebuffersEXT(1, &mfbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mfbo);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorBuffer);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthBuffer);
// Final framebuffer color buffer
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, format, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Attach it
glGenFramebuffersEXT(1, &fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texture, 0);
// Drawing code
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mfbo);
// Draw
//...
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, mfbo);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo);
glBlitFramebufferEXT(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);