Fireflies in pathtracer back

Board: Home Board index Raytracing General Development

(L) [2012/04/17] [ost by KaRaMBa] [Fireflies in pathtracer] Wayback!

Hi!

I'm currently working on a basic path tracer.  Recently I added next event estimation for emissive surfaces (ie. direct sampling of lights). Now, if a small but powerful light source is near a diffuse surface, I get 'fireflies' all through my rendering. This effect can be seen in this image (rendered with 64 samples per pixel):

[IMG #1 Image]

What can I do to reduce this noise? MIS reduces high variance noise in scenes with shiny surfaces, but would it also help in a completely diffuse scene like this?
[IMG #1]:[IMG:#0]
(L) [2012/04/18] [ost by Dade] [Fireflies in pathtracer] Wayback!

>> KaRaMBa wrote: MIS reduces high variance noise in scenes with shiny surfaces, but would it also help in a completely diffuse scene like this?
Yup, it does, your fireflies are likely to be caused by paths directly hitting a very near light source. If you lower the light sources in your scene, you will see how the fireflies will disappear.
(L) [2012/04/18] [ost by ingenious] [Fireflies in pathtracer] Wayback!

Unfortunately, in a basic path tracer there's little you can to about this problem. Bidirectional methods, e.g. bidirectional path tracing or VPL methods, perform better in such conditions, as they sample these firefly-causing paths with higher probability.
(L) [2012/04/18] [ost by KaRaMBa] [Fireflies in pathtracer] Wayback!

>> Dade wrote:KaRaMBa wrote: MIS reduces high variance noise in scenes with shiny surfaces, but would it also help in a completely diffuse scene like this?
Yup, it does, your fireflies are likely to be caused by paths directly hitting a very near light source. If you lower the light sources in your scene, you will see how the fireflies will disappear.
My path tracer takes a similar aproach for direct sampling of lights as the (extended) smallpt pathtracer:
- If a ray hits a diffuse surface, a random point on a random light is picked and a shadow ray is send. If the lightsource is visible, the appropriate amount of light is added
- Next, a random diffuse ray is send into the scene to add indirect lighting, and directly hitting lightsources is disabled

This gives nice noise-free results within very little samples, if the lightlevel is below 1.0. However, more intense lights are required to sufficently light the scene.

If I move the lightsource down, such that the bright area on te ceiling is less bright, my fireflies also reduce drasticly. I susspect a random diffuce ray hitting the very bright diffuse area above the lightsource, is the cause of my fireflies... (N.B. this is similar to the discussion on the second page of this topic: [LINK http://ompf2.com/viewtopic.php?f=3&t=5 viewtopic.php?f=3&t=5])

Since i disable the hitting of lightsources after a diffuse bounce, how would MIS solve this issue? As I understand, MIS only solves variance introduced by hitting lightsources with the an unlikely chance (which isn't possible in my case)? And if I didn't understand MIS correct, how would I implement MIS in my case (what probablilites should I mix)?

I've added a snipset (pseudocode) of my tracer:
Code: [LINK # Select all]COLOR pathTracer(const KDTREE *world, POINT *pt, POINT *dir)
{
    COLOR colscale = {1.0f, 1.0f, 1.0f};
    COLOR ret = {0.0f, 0.0f, 0.0f};
    int depth = 0, allowlight = 1;
    while(1)
    {
        if(depth>15) break;
        
        IXPT *ixpt = findIntersectPt(world, pt, dir);        // Intersection point ixpt contains information about hit: face, hitpoint, etc
        
        if(!ixpt)    // nothing hit, add sky-light
        {
            ret += skyColor(dir) * colscale;
            return ret;
        }
        POINT norm = getFaceNormalAtPoint(ixpt);
        if(ixpt->face.emit)
        {
            if(allowlight)
                ret += ixpt->face.color * colscale * ixpt->face.emit;
            return ret;
        }
        else // diffuse hit
        {
            // Directly sample light
            POINT newdir;
            COLOR lightColor;
            const tReal pdf = sampleLight(dir, ixpt->pt, &norm, &newdir, &lightColor);
            const tReal brdf = brdf_Lambert(dir, ixpt->pt, &norm, &newdir);
            const tReal scale = brdf / pdf;
            if(!findObscured(world, &ixpt->pt, &newdir))
                ret += ixpt->face.color * lightColor * colscale * scale;
            allowlight = 0;    // directly sampled lights, so exclude them from being hit accidentally
            // Now do a diffuce bounce for indirect lightning
            static const tReal Prr = 0.9;
            if(sample()<Prr)
            {
                const tReal pdf = sampleVectorCosweighted(dir, ixpt->pt, &norm, &newdir);
                const tReal brdf = brdf_Lambert(dir, ixpt->pt, &norm, &newdir);
                const tReal scale = brdf / (pdf * Prr);
                if(scale > REL_EPSYLON)
                {
                    colscale *= matcol * scale;
                    *pt = ixpt->pt;
                    *dir = newdir;
                    depth++;
    
                    continue;
                }
            }
            return ret;
        }
    }
}
(L) [2012/04/18] [ost by igneus] [Fireflies in pathtracer] Wayback!

This isn't a perfect fix, but you might be interested in [LINK http://gfx.cs.princeton.edu/pubs/DeCoro_2010_DOR/outliers.pdf this paper] which uses outlier rejection to remove fireflies. It's a sample space filtering technique so you don't get the same smudgy artefacts as with some methods. Also, the energy that's removed by the filtering can be cached and added back in later when more samples are taken.
(L) [2012/04/18] [ost by beason] [Fireflies in pathtracer] Wayback!

I don't think MIS will help you. I second the bidirectional approach, but metropolis sampling may help also. The problem is how to send more rays to those secondary bright spots.
(L) [2012/04/18] [ost by apaffy] [Fireflies in pathtracer] Wayback!

Yep the fireflies will be from BSDF sampling to extend the path hitting one of these areas that are very brightly directly lit.

The only way to reduce the fireflies is to find paths through these bright areas with higher probability, which is exactly what light subpaths (in a bidirectional path tracer) will do for you. [SMILEY :)]

back