Reducing texture resolution "on the run"

Started by
7 comments, last by _the_phantom_ 17 years, 8 months ago
I was wondering does OpenGL have any trick to reduce size of a loaded texture "on-the-run"? What I'm trying to do is blur effect with low-end hardware; Capture the screen to texture, reduce texture size to half, and then render it in original size with mipmapping. Thanks!
Advertisement
You can always use some sort of image manipulation library to get the image size in half. Problem I always had with downscaling a image is making it look good since what do you sample when u are reducing the image size.
Do you have the SGIS_generate_mipmap extension? Depending on how you render to texture it's possible to enable fast automatic hardware mipmap generation. Just use LOD 1 and blur it (it will be half the width/height).
You might not have to scale the image down, I'm doing blurring by translating and blending the texture again. You can repeat the translate/blending operation as often as you want.

If you still want to scale your image and your hardware doesn't support automated mimapping, take a look at gluScaleImage.

Cheers,
Shadx
Quote:Original post by deavik
Do you have the SGIS_generate_mipmap extension? Depending on how you render to texture it's possible to enable fast automatic hardware mipmap generation. Just use LOD 1 and blur it (it will be half the width/height).


I found that generate_mipmap was very slow, regardless of how good the hardware was.

necrophilissimo: You can do a good blur by rendering the texture multiple times to the framebuffer and copying the result into a final texture. As an optimisation this rendering can be done at half or a quater of the original texture size, and gives good quality results if you set your blend weights up well.
Thank you all :) I'll try all the methods and analyze what's best for my tiny little game.
Quote:Original post by OrangyTang
Quote:Original post by deavik
Do you have the SGIS_generate_mipmap extension? Depending on how you render to texture it's possible to enable fast automatic hardware mipmap generation. Just use LOD 1 and blur it (it will be half the width/height).


I found that generate_mipmap was very slow, regardless of how good the hardware was.

necrophilissimo: You can do a good blur by rendering the texture multiple times to the framebuffer and copying the result into a final texture. As an optimisation this rendering can be done at half or a quater of the original texture size, and gives good quality results if you set your blend weights up well.


As a sidenote to this, if you have the FBO extension present then you shouldn't really use this, instead you should use it's supplied glGenerateMipMapsARB() function (might want to check that function name) to do it at a time when it's usefull for you, the automatic mipmap generation extension doesn't garentee when it will happen, just that it will.
Quote:Original post by phantom
As a sidenote to this, if you have the FBO extension present then you shouldn't really use this, instead you should use it's supplied glGenerateMipMapsARB() function (might want to check that function name) to do it at a time when it's usefull for you, the automatic mipmap generation extension doesn't garentee when it will happen, just that it will.

Is that much different from the old GL_GENERATE_MIPMAP_SGIS extension though? When I last tried it the SGIS version was very slow, and the quality was poor (just a regular box filter, you can get much better results using the above method).

Although obviously if FBOs are available you'd be using them instead of doing copies from the framebuffer.
I don't know about performance differences, or even the filter used, the main advantage is the fact the process is determinate as it can occur at a set time, the mipmap generation via automatic generation can occur at undetermined time in the future which is very bad thing when you are copying to the base level of a texture as there is no way to know when the mipmap chain will be updated.

This topic is closed to new replies.

Advertisement