I’m looking to do a “selective blur” or “surface blur” on the GPU. I’ve read some research papers on the subject, and seen a good deal of C code, but ideally I’d like something in GLSL, HSL, or CG.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Actually, a bilateral blur is not very different from a gaussian blur, you just have to multiply the value of the sample by the gaussian factor multiplied by the result of a “closeness’ function between the actual values of the centre pixel and the sampled pixel.
So, in pseude GLSL
You should probably have a better way to determine the closeness value, eg do it in a perceptively uniform space such as LUV.
For optimization, you can apply all techniques that work for gaussian blur, apart from the ones that ignore the fact you have to know the pixel’s value. For example, with a pure gaussian you can choose your texcoords wisely and integrate 4 pixels in one fetch. That won’t work.
The big things that do work:
*Separate your filter. Instead of 5×5 samples (25), do 5 horizontally, save to an intermediate buffer, and do 5 vertically. It won’t look exactly the same, but it will still remove noise.
*Perform your filter on a lower resolution, and composit it with the orignal to get some detail back.