Sign in to follow this  
fpsgamer

arb_fragment_program and gaussian blur.

Recommended Posts

Using arb_fragment_program, how can I access pixels adjacent to the current fragment to build up an interpolation kernel? I want to be sure I am accessing a single pixel value at particular offsets from the current pixel that is being rasterized. Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by fpsgamer
Using arb_fragment_program, how can I access pixels adjacent to the current fragment to build up an interpolation kernel?
You cannot because the adjacent pixels are not guaranteed to exist and not guaranteed to have been computed.
You must render to a texture and use texture lookups, in other words, perform a post-processing effect.
Quote:
Original post by fpsgamer
I want to be sure I am accessing a single pixel value at particular offsets from the current pixel that is being rasterized.
You can do that by having a uniform containing 1.0/TEXTURE_DIMENSION, which is a texel width/height. I have tried doing this with NEAREST and it worked just ok to index a large LUT dynamically. Last-gen graphics cards allows you to access the texels indexed as integers directly, but I'm not sure it already makes sense to use this functionality.

Share this post


Link to post
Share on other sites
Quote:
Original post by Krohm
You must render to a texture and use texture lookups, in other words, perform a post-processing effect.


Oh sorry. I should have mentioned that I have already rendered to texture the thing that I want to "blur". Then I re-render that texture to a screen alligned quad.

Quote:
Original post by Krohm
You can do that by having a uniform containing 1.0/TEXTURE_DIMENSION, which is a texel width/height. I have tried doing this with NEAREST and it worked just ok to index a large LUT dynamically. Last-gen graphics cards allows you to access the texels indexed as integers directly, but I'm not sure it already makes sense to use this functionality.


Infact this is what I did. I actually first created another pbuffer exactly the same size as the texture and enabled GL_NEAREST filtering to be absolutely sure that I was accessing a single pixel at a time from the texture map when I offset from my current texture coords.

I just wanted to be absolutely sure that this was the "right" method. As I dont want to be working harder than I have to. There donesnt seem to be a particularly "clean" way in arb_fragment_program to fetch more than one texel without several lines of +1 and -1 increments from the current texture coords.

Share this post


Link to post
Share on other sites
Ok, I see.

If you absolutely want more perf, you could try using a lower mip level. Cutting down to 1/2 or 1/4 of texture dimensions usually doesn't introduce sensible variations in the blurriness.

This basically allows to resolve "blocks" of texels as you want and may give a nice performance boost I suggest you try it out! It's just standard with tonemapping methods.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this