Jump to content
• Advertisement

# Gaussian based Weights

## Recommended Posts

Hi.  I was studying the Bloom tutorial on learnopengl.com.
https://learnopengl.com/#!Advanced-Lighting/Bloom

I understand the benefits of using a Gaussian blur for achieving a Bloom effect.  I understand that the author of this tutorial is using the gaussian values as weights which are used to determine how much neighboring pixels should affect the current pixel when blurred.  In this tutorial, the author chooses to use the following weights,

0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216

Where 0.227027 + (0.1945946*2.0) + (0.1216216 * 2.0) + (0.054054 * 2.0) + (0.016216 *2.0) comes out to about 1.  The author chooses to same 4 samples to the left and right of the current pixel for a total sample count of 9 per axis.  All that makes sense but what I don't understand is how to calculate the weights myself.  For example, lets say I wanted a sample count of some arbitrary number like 5.

With a sample count of 5, the formula would then need to be A + (B * 2.0) + (C * 2.0) + (D * 2.0) + (E * 2.0) = 1
What I want to do is figure out how to calculate the wights, A,B,C,D, and E given the sample count.  Thanks!

Advertisement

This might help:

#### Share this post

##### Share on other sites

Here's a short C++11 program that roughly produces the same numbers:

	#include <cmath>
#include <iostream>

int main() {
double sigma = 1.75;
int N = 4;

double total = std::erf((N+.5) / (std::sqrt(2.0) * sigma)) - std::erf((-N-.5) / (std::sqrt(2.0) * sigma));
for (int i = -N; i <= +N; ++i) {
std::cout << (std::erf((i+.5) / (std::sqrt(2.0) * sigma)) - std::erf((i-.5) / (std::sqrt(2.0) * sigma))) / total << '\n';
}
}


## 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

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
43
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 9
• 27
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633397
• Total Posts
3011657
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!