Resources Numerical accuracy Calculation policy

Samples per pixel reported after a render

Works out the average and the largest number of samples a pixel received in an adaptive path-traced render, shown on the finish line.

How the precision is kept

The per-pixel sample count is the fourth channel of the accumulation buffer read back from the graphics card as a Float32Array. A whole number is exact in 32-bit up to 16,777,216, so the counts read back are exact below that; the sum over the picture is kept in 64-bit. The average shown is rounded to one decimal.

Open item. Keep the per-pixel sample count in an unsigned integer buffer instead of the fourth channel of the 32-bit float accumulation buffer.

Calculations under this policy

1 calculation in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.

render/render-pt.js BimCraft 0.8.1 32-bit in part 1 calculation Reviewed

Tests None found by the review

Average and largest sample count

32-bit in part

The two numbers the render dialog states after an adaptive render.

avg = round(10 × Σ nᵢ ÷ (w × h)) ÷ 10; max = largest nᵢ

Each nᵢ is read from the 32-bit float accumulation buffer (channel 4 of each pixel); as whole numbers below 16,777,216 they are exact there. They are added in order into a 64-bit sum, and the average is rounded to one decimal with Math.round before it is returned.

  • render/render-pt.js
  • lines 201 to 203
  • BimCraft 0.8.1
let sum = 0, mx = 0;
for (let i = 0; i < w * h; i++) { const n = layers.accum[i * 4 + 3]; sum += n; if (n > mx) mx = n; }
out.adaptive = { converged: !!r.converged, avg: Math.round((sum / (w * h)) * 10) / 10, max: mx };

In detail

Method
A loop over every pixel adds the count and keeps the largest; average = sum ÷ (width × height).
Number types
Counts from a Float32Array read back from the GPU; the sum and the average in 64-bit.
Limits
The average is rounded to 0.1 before it is returned. A pixel's count above 16,777,216 would no longer be a whole number in the buffer.

Approach: 32-bit step, flagged

One step stores or exchanges 32-bit values that reach a number a person reads. It is listed here with its open item, and the step is either moved to 64-bit or the app will warn where the number is read.

Every policy that takes this approach