Jump to content
  • Advertisement
Sign in to follow this  

Can you help me make an Gaussian Blur filter using C

This topic is 1092 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I'd post some code but my stuff is optimized so it wouldn't make any sense. I'm sure there's examples online (and DirectX SDK) for this but here's the over view in a nut shell.


First you want to compute a bell curve based on the number of samples that you want to use for your blur. You can use hard coded numbers for this but computing your own bell curve will allow you fine tune it to your needs. All we care about is half the bell curve because this is your target pixel and the number of samples taken. These values are your weights. Target pixel plus half the number of samples. We can now reused these samples for the other side of the target pixel. X = target pixel.


+++++X+++++ = 1.0


In the example above, there is 11 weights. If you were to add them all up, they would equal 1.0. You use the same array of weights to do the horizontal and vertical blur pass. At this point you simply multiply the sampled pixels by their respective weights to calculate the new color of the target pixel.


As stated above, this is a two step process and you'll need one additional buffer to complete the process. This assumes you're using a back buffer. Otherwise you'll need two buffers depending on how you are implementing it.


First pass - horizontal: Sample the values from the back buffer and write the new pixel value to the extra buffer.

Second pass - vertical: Sample the values from the extra buffer and write the new pixel value to the back buffer.


That's it in a nut shell. There's optimizations you can do like use two smaller buffers to do the blurring. Scale it down to a smaller buffer, blur between the two buffers, scale back up to the original size.

Edited by GameCodingNinja

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!