6
$\begingroup$

So I have a game and I am trying to fake glow inside of it by using the hardwares capability to downsize textures causing them to blur.

The texture I wish to do this with is in a render buffer that is the size of the screen (not power of two)

What would be the quickest way to get these lower resolutions created? Tricking the software to make minimaps? Another fbo with the texture rendered on it in smaller size?

$\endgroup$
6
$\begingroup$

I would think rendering to a downsampled FBO would be much faster than generating mipmaps. glGenerateMipmap will generate the complete mipmap pyramid, which seems wasteful:

https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGenerateMipmap.xml

Besides, only OpenGL ES 3.0 lets you manually select mip level when texturing:

https://www.khronos.org/opengles/sdk/docs/man3/html/textureLod.xhtml

Artistically, this might not give you the look you want. In my experience, simply downsampling gives a grainy look. I would recommend also doing a pair of one-dimensional blurs, as described in this article from GPU Gems:

http://developer.download.nvidia.com/books/HTML/gpugems/gpugems_ch21.html

$\endgroup$
  • $\begingroup$ WOW! That last link hit the spot! Things are looking great. However the code they have makes no sense to me as I am a glsl programmer. Thankfully I found two pass code somewhere. $\endgroup$ – J.Doe May 23 '16 at 6:44
  • $\begingroup$ My confusion is the following, how exactly do you increase/decrease the size of the blur? Increasing how many texels away each sample is, or increasing the amount of texels sampled? And have you seen any good code for this working inside of a for loop based on glow radius? $\endgroup$ – J.Doe May 23 '16 at 6:46
  • 1
    $\begingroup$ "I would think rendering to a downsampled FBO would be much faster than generating mipmaps. glGenerateMipmap will generate the complete mipmap pyramid, which seems wasteful:" Surely that might depend on whether there is custom hardware or not? Also, given that the total MIP map chain is a 33% overhead on the original image, but the 1st MIP map level is 25% of that, the storage for the remainder is only an additional 8%. $\endgroup$ – Simon F May 23 '16 at 12:13
  • $\begingroup$ Good point, I spoke too broadly there. It is possible that generating the chain is faster on some systems. $\endgroup$ – user3412 May 24 '16 at 3:43
  • $\begingroup$ To increase the size of the blur you increase the amount of pixels sampled. See here for a 7x7 blur: software.intel.com/en-us/blogs/2014/07/15/… $\endgroup$ – user3412 May 24 '16 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.