RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
982 stars 178 forks source link

[Question] Every two steps have same variance as previous, is that normal? #587

Closed WhitePhoera closed 1 month ago

WhitePhoera commented 1 month ago

Hello. I have i simple scene(actually building one, just testing partially, before moving to more complex models): It consists of 3 1-Quad meshes, every in separate instance. Ambient light and uses path tracer renderer(with background color set to 1)

I use my own dotnet wrapper for that, but since rendering loop is simple args mapping it doesn't matter:

        while (step <= 50)
        {
            var clock = Stopwatch.StartNew();
            using var future = renderer.RenderFuture(framebuffer, camera, world);
            future.Wait();
            last = framebuffer.Variance;
            clock.Stop();
            Console.WriteLine($"Step {step} done, variance is {last:0.000} : {clock.Elapsed}");
            step++;
        }

in C this will be something like

OSPFuture future = ospRenderFrame(frameBuffer, renderer, camera, world);
ospWait(future); // actually sync arg is TaskFinished, as default
last = ospGetVariance(framebuffer);

from C code i omited log and timing, since that not matter.

This code produces the next log:

Step 1 done, variance is ? : 00:00:01.0597915
Step 2 done, variance is 23,284 : 00:00:01.0188481
Step 3 done, variance is 23,284 : 00:00:01.0487581
Step 4 done, variance is 16,495 : 00:00:01.0256538
Step 5 done, variance is 16,495 : 00:00:01.0591974
Step 6 done, variance is 12,273 : 00:00:01.0881235
Step 7 done, variance is 12,273 : 00:00:01.0418732
Step 8 done, variance is 13,345 : 00:00:01.0744449
Step 9 done, variance is 13,345 : 00:00:01.0908219
Step 10 done, variance is 14,383 : 00:00:01.0544194
Step 11 done, variance is 14,383 : 00:00:01.0473024
...

As you can see every 2 steps have same variance. Is that fine? or i do something wrong?

johguenther commented 1 month ago

Hello, yes, in the current implementation it is expected that the variance changes only every second frame. Background: Variance estimation works by comparing the accumulated frame with a buffer which gets (and accumulates) only every second frame. With that, computing the variance every frame will lead to oscillation (going up and down again), but we like to have it monotonically decrease. Hence we re-use and report the variance from the previous frame. We are about to improve variance estimation even within a single frame, but no final results yet.

WhitePhoera commented 1 month ago

Thank you