Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8636487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:14:24+00:00 2026-06-12T10:14:24+00:00

I’ve recently been looking into optimising a gaussian blur shader by using a linear

  • 0

I’ve recently been looking into optimising a gaussian blur shader by using a linear sampling method instead of a discrete method.

I read a very informative article:

Efficient Gaussian Blur With Linear Sampling

In case of such a merge of two texels we have to adjust the coordinates that the distance of the determined coordinate from the texel #1 center should be equal to the weight of texel #2 divided by the sum of the two weights. In the same style, the distance of the determined coordinate from the texel #2 center should be equal to the weight of texel #1 divided by the sum of the two weights.

While I understand the logic behind this, I’m not sure how they arrived at the figures for the offset with the given weights. Would anyone be kind enough to shed more light on this for me and to also explain how, given uniform weight variables we could calculate correct offsets?

Regarding non hard coded offsets, I found another post which recommended a method of calculating the offsets, however no solution was posted for a variable amount of samples. How could I achieve that?

vec2 offsets[3];
offsets[0] = vec2(0.0, 0.0);

offsets[1] = vec2(dFdx(gl_TexCoord[0].s), dFdy(gl_TexCoord[0].t));

offsets[2] = offsets[1] + offsets[1];

Fragment Offset

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:14:25+00:00Added an answer on June 12, 2026 at 10:14 am

    I just came across the same article, and found it tremendously useful as well. The formula to calculate the weights and offsets is given in it:

    Formula
    (source: rastergrid.com)

    The author arrived at the weights by using the 12th row in the pascal triangle. So for example the second offset is calculated by:

    1.3846153846 = (1 * 792 + 2 * 495) / (792 + 495)
    

    The second weight is calculated by:

    0.1945945946 = (792 + 495) / 4070
    

    I’m not sure what you mean by calculating the offsets given uniform weight variables but if it’s of help I’ve included a C++ program at the end of this post that outputs the offsets and weights for an arbitrary row in the pascal triangle.

    If I understand your question about non hardcoded offsets, then you want to be able to calculate the offsets on the fly in GLSL? You could do that by porting the program below, but you’ll still need to hardcode the binomial coefficients, or calculate those on the fly as well. However, that will be expensive since it will have to be done for every pixel. I think a better alternative is to precalculate the offsets and weights in C (or whatever programming language you’re using), and then bind them to a uniform array value in GLSL. Here’s the GLSL snippet for what I mean:

        uniform float offset[5];
        uniform float weight[5];"
        uniform int numOffsets;
    

    You’ll want to replace “5” with the maximum number of offsets/weights you plan to use, and set numOffsets to the number you’re using for a particular operation.

    Here’s the program that outputs the weights and offsets. “coeffs” should be replaced with the binomial coefficients of the row you want in the pascal table. The one included here is from the 22nd row

    #include <iostream>
    #include <vector>
    
    using namespace std;
    
    int main(int argc, char* argv[])
    {
      float coeffs[] = { 705432, 646646, 497420, 319770, 170544, 74613, 26334, 7315, 1540, 231 };
      double total = coeffs[0];
      for (int i = 1; i < sizeof(coeffs) / sizeof(float); i++)
        {
          total += 2 * coeffs[i];
        }
      vector<float> offsets;
      vector<float> weights;
    
      offsets.push_back(0);
      weights.push_back(coeffs[0] / total);
    
      for (int i = 1;  i <= (sizeof(coeffs) / sizeof(float) - 1) / 2; i++) 
        {
          int index = (i - 1) * 2 + 1;
          float weight = coeffs[index] + coeffs[index + 1]; 
          offsets.push_back((coeffs[index] * index + coeffs[index + 1] * (index + 1)) /  weight);
          weights.push_back(weight / total);
        }
    
      for (int i = 0; i < offsets.size(); i++)
        {
          cout << offsets[i] << ", ";
        }
      cout << "\n";
    
      for (int i = 0; i < weights.size(); i++)
        {
          cout << weights[i] << ", ";
        }
      cout << "\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.