View Full Version : Blur/ Unsharping with OpenGL
11-20-2006, 01:13 AM
Hi I would like to slowly unsharp an object / texture more and more until it dissolves completly.
I read somewhere that this is possible with the imaging extention with a filter matrix. Unfortunetly this is not supported on all cards. Is there another way to do it like pixelshaders or another extention ?
I would not like to draw the object multiple times slightly reposotionend and with different alpha value, or onto a texture.
Any help is highly appreciated...
Thanks a lot.
11-20-2006, 08:30 AM
Ok, do you need correct filtering working as fast as possible or fast filtering looking as good as possible?
Pixel shaders would be the best solution if you want correct (matrix based) filtering. You would only need a fragment shader that samples the texture at multiple points, scales these values by matrix and add them together to produce final color. For small matrices (let's say no more than 5x5) this would work fast enough.
more and more until it dissolves completlyNow that would be a problem, because you would need a large matrix (as large as the texture) so for 256x256 texture it would be equivalent to sampling every pixel of this texture 64k times (because matrix is 256x256 too).
So, if you want this to work in realtime you have to either:
1. reuse blurred texture every frame blurring it a bit more every time - this will blur texture faster at beginning and slower at the end and you won't be able to sharpen it again this way
2. give away the quality and use some simple blurring
Simplest implementation of #2 would be to generate mipmaps and access this texture from shader with different LOD bias parameter using GL_LINEAR_MIPMA_LINEAR filter. It will look ugly, but it will be fast. You could also perform some additional blurring on these mipmaps in your shader to make it look a bit better.
11-20-2006, 09:08 AM
- sample texture at midpoints, so that each texture access will already average 4 texels
- run one horizontal blur, then a vertical blur (linear cost instead of polynomial)
- and as already said, start with mipmaps for the wider blurs
11-21-2006, 01:49 AM
Thanks a lot.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.