PDA

View Full Version : FBO and manual mipmap generation



chlorinedreams
05-15-2010, 04:15 PM
Hey all,

I currently have my RTT (using FBO) generating mipmaps but I need a better filter than the default box-filter openGL provides. Does anybody know of some example code that shows how to use a shader to define the various mipmap levels for a FBO render target texture?

Thanks in advance

mfort
05-15-2010, 11:47 PM
Read the spec:
http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt

Usage Example #5


// custom-generate successive mipmap levels
glBindTexture(GL_TEXTURE_2D, color_tex);
foreach (level > 0, in order of increasing values of level) {
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, color_tex, level);
glTexParameteri(TEXTURE_2D, TEXTURE_BASE_LEVEL, level-1);
glTexParameteri(TEXTURE_2D, TEXTURE_MAX_LEVEL, level-1);

<draw to level>
}
glTexParameteri(TEXTURE_2D, TEXTURE_BASE_LEVEL, 0);
glTexParameteri(TEXTURE_2D, TEXTURE_MAX_LEVEL, max);

chlorinedreams
11-09-2010, 12:09 PM
Ok, does anybody have any example code on how the shader would write to mipmap level n while sampling from level n-1? I assumed that I could simply use textureLod( blah, blah, n-1 ), but that doesn't seem to be working.

Thanks again