















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Multipass rendering, a technique used in computer graphics to combine the results of multiple rendering passes to achieve various effects such as antialiasing, motion blur, depth-of-field, and soft shadows. The document also covers the use of framebuffer objects (fbos) in opengl, which enable offscreen rendering and storage of intermediate results for multipass rendering. Topics include creating and using fbos, renderbuffers, and handling multiple color attachments.
Typology: Study notes
1 / 23
This page cannot be seen from the preview
Don't miss anything!
















Antialiasing Motion blur Depth-of-field Soft shadows
๎
๎
glGenRenderbuffersEXT(1, &Depthbuffer_ID); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, Depthbuffer_ID); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, 256, 256); glGenFramebuffersEXT(1, &FBO_ID); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBO_ID); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, TexID, 0); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, Depthbuffer_ID); CheckFramebufferStatus(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //unbind FBO
glPushAttrib(GL_VIEWPORT_BIT); //push old viewport onto attribute stack glViewport(0, 0, 256, 256); //set viewport to size of attachedtexture glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBO_ID); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); //select which attachment to render into glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear attached texture and renderbuffer glEnable(GL_DEPTH_TEST); //draw objects into FBO glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //unbind FBO glDrawBuffer(GL_BACK); //resume drawing to back buffer glPopAttrib(); //restore viewport
//Create cubemap glBindTexture(GL_TEXTURE_CUBE_MAP, CubeID); for(int i=0; i<6; i++) { glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); // note: cubemap image targets are sequential, so we can use a loop here. // note: pointer is 0 so texture image is allocated, but not initialized. } //set cubemap parameters glTexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glBindTexture(GL_TEXTURE_CUBE_MAP, 0); //Create renderbuffer for depth glGenRenderbuffersEXT(1, &Depthbuffer_ID); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, Depthbuffer_ID); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, 256, 256); //note: size is the same as color textures Creation
//Create FBO glGenFramebuffersEXT(1, &FBO_ID); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBO_ID); //attach cube faces to the FBO color attachments for(int i=0; i<6; i++) { glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT+i, GL_TEXTURE_CUBE_MAP_POSITIVE_X+i, CubeID, 0); // note: FBO attachments are sequential, so we can use a loop here. } //attach depth renderbuffer to FBO glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, Depthbuffer_ID); CheckFramebufferStatus(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); Creation (cont'd)