Sampling neighbour texel using fixed pipeline

Apprentice
Posts: 14
Joined: 2009.04
Post: #1
Hi,

I'm trying to create a blur effect for a given texture using OpenGL ES 1.1 (or fixed pipeline). For this I need to sample the neighbouring texels. I've been searching the internet now for a few days (taking a loop at the supported extensions of the iphone 3G at http://developer.apple.com/iphone/librar...-CH106-SW1 as well, draw_texture sure looks interesting for fast drawing!) but I am unable to come up anything better than the following:

create an fbo to render the blurred version in
render the texture into it normally
for 1 to the radius of my blur:

put the texture of the fbo in texture unit 0
put the original texture in texture unit 1 but with the texture coordinates i pixels to the left, so that for iteration i in my loop pixel x,y coincides with pixel x+i,y+1
activate texture combiners to multiply the colors
put the weight of the actual iteration in the environment color

render the textures
end loop

anyone has a better way of sampling the neighbour texels using a fixed pipeline?
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
Didn't people used to use mipmap generation to get a cheap blur like effect?

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2009.04
Post: #3
I tried to render the texture to a smaller fbo and render the fbo at the same size as the original texture (using GL_LINEAR as the magnifying filter). The result was really ugly, I suppose using mipmaps the resul would be similar, no? Anyway, I'll look into it.

I would like to generate a high quality blur since I only need to calculate it at certain points in time, so performance is not that big of a deal.

Thanks!
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #4
I don't know about OpenGLES 1.1 supporting this, but it was common for people to use a lower-res texture then scale it up with linear filtering and no mipmaps. The linear filtering does texel interpolation. It's not as good as shaders or software guassian blur, but it's the fastest method.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #5
Mipmap generation (manual or otherwise) is OK for quick and dirty blurs, but the approach you're using (offsetting texture coordinates and accumulating samples with combiners) is really the only way to do blurs with arbitrary kernels in ES1.

There are some details here which make a big differences though, like:
* use multiple texture units to reduce the number of passes
* use a sampling pattern that takes advantage of bilinear filtering, to reduce the number of samples

And hardware-specific details, like:
* use the primary color as a sample weight, instead of the constant env color, which is stored in low precision on MBX

See the GLImageProcessing sample code for an example of a 17-tap blur in 3 passes. It runs fullscreen at interactive framerate, although the overhead is still pretty high on the earlier devices.

High quality gaussian pyramid blurs can be similarly implemented.


As an aside, I would pretend OES_draw_texture doesn't exist. It's not a performance path-- you can do much better by drawing textured quads yourself, because you can batch many quads in a single draw call.
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2009.04
Post: #6
Ok, that was all I needed to know! Thanks for the tips! Let's see if I'll manage to implement it Smile
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2009.04
Post: #7
About draw_texture, you wouldn't even use it for large background images?
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #8
For one-shot background quads, it's OK. Just don't be tricked into thinking it's great for drawing font glyphs or anything.
Quote this message in a reply
Post Reply