Jump to content
  • Advertisement
Sign in to follow this  
megav0xel

Using halton sequnce in shader

This topic is 567 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

Hi!

 

I'm trying to add importance sampling to my screen space reflection shader. Currently I'm following the approach mentioned in Frostbite's stochastic ssr presentation but I am confused about how to use halton random number in shader.

First I pre-calculate and store the halton sequence in an array and then pass the array to shader. After that I use the following code to get the random numbers in GLSL shader.

float rand(vec2 co){
    return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}


void main()
{
..........
//somwhere in main
    float random1=rand(TexCoords);
    float random2=rand(TexCoords+vec2(0.301f));
    int index1=int(random1*100);
    int index2=int(random2*100);
    vec2 Xi=vec2(haltonNum[index1],haltonNum[index2]);
    ImportanceSampleGGX(Xi, roughness);

..........
}

Then I will calculate the hit position, reproject it to previous frame and sample its color and neighbour pixels' color .

 

Unfortunately my result image has a lot of flickering black holes/gaps. It looks like the generated samples are pretty unstable. However if I sample Gbuffer directly I won't have such issue. Some other random functions(like the rand() presented above) work fine but the result is extremely noisy.

 

Does anyone know how to use halton sequence? Any help would be appreciated.

Edited by megav0xel

Share this post


Link to post
Share on other sites
Advertisement
  • Why random1*100 and random2*100? How long is the haltonNum array? How do you deal with out of range indices?
  • What does ImportanceSampleGGX return? Where do multiple samples, which should need a pseudorandom point each, come from?
  • "I will calculate the hit position, reproject it to previous frame and sample its color and neighbour pixels' color".
    Not very clear, but if the "hit position" depends on the pseudorandom points, how do you guarantee it is close to the one in the previous frame and not jumping around between unrelated surfaces?

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.

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!