Jump to content
  • Advertisement
Sign in to follow this  
underthesun

extracting downsampled mipmap textures

This topic is 4110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know how to extract downsampled mipmap textures so that you can use them later? I'm thinking it could be used as a very cheap blur, but yeah.. would it be expensive creating a mipmap for every frame for this purpose? thankes

Share this post


Link to post
Share on other sites
Advertisement
As you might already know, mip-maps are already downsampled versions of the previous MIP level.

If you start with a texture having a resolution of 256x256, the next step would be 128x128, followed by 64x64, 32x32, 16x16 ... all the way down to 1x1.

The downsampling is simple enough, most (all?) systems simply average each 2x2 texel quad to generate the texels of the next smallest Mip level, though I suppose more advanced filters could be used (whether they might be of any benefit, I don't know.)


The answer to your question depends on what context you intend by the word frame. Do you mean "frame" in the sense of framerate, or do you mean "frame" in the sense of frames of an animation? Something else?

If the former, and you want to apply a post-processing blur to the entire screen then yes, this would work and be fine (though you'd get nearly the same results as setting the resolution to 1/2 the current resolution in each axis, which would render faster.)

If the latter, and you want to blur the frames of an animation, then it would be a poor idea to generate it as needed. Presumably, such textures would (or could) already have its Mip levels generated. What you'd want to do is artificially knock the selected mip-level to the next smaller version, which will give you blurry results presumably.

Share this post


Link to post
Share on other sites
Quote:
Original post by underthesun
Thanks for that. How do I knock the selected mip level down?


Use texture LOD bias:

glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, bias)

Where bias is a float that changes the calculation of which mipmap to use. 0.0 is the default.

I should point out that I've never used it so I don't know what value of bias would be suitable. Just draw 3 textured quads side by side with biases of -1, 0 and +1 to find which gives the effect you want and fine tune from there.

Share this post


Link to post
Share on other sites
again, thanks for the help.

Another related question : suppose you have a texture (that you got from glCopyTexImage2D). How do you get that sample out of opengl so you can perform calculations on it, say, blur out the stuff?

What I've really been trying to do this far is to get whatever's on the screen into a texture (let's call this the "screenshot"), then take it out, then blur it (I was hoping for something cheap that uses opengl stuff, like some downsampling trick and then using gl_linear to get a cheap blur-ish thing, or something like that..)

I've just been trying to get a bloom filter working.. so I guess I also need to do some sort of bright filter going, but that could be done by the shader I guess?

And the last thing is, whats' the most efficient way to "average" the colour of the screenshot? That is, find out how "bright" the screen is.. if that makes any sense at all..

Thanks again

edit : this is what I'm trying to do : http://harkal.sylphis3d.com/2006/05/20/how-to-do-good-bloom-for-hdr-rendering/

[Edited by - underthesun on March 24, 2007 7:41:20 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!