This is a sampling of a red color. How it works is you have your starting red color, 0 (technically NULL), and each sample picks either full red (255,0,0) or black (0, 0, 0). It then compares this value to a precomputed 'weight' value for that pixel. If the original image has a red value of 120 at (0,0) that becomes the red weight value. If a random number is greater than that weight, it returns full red, else full black. Over time this *should* average to 120, however it doesn't. It will approach 120, then slowly rise and the image becomes washed out. I think this may be because of decimal precision. It is taking large numbers, multiplying them by even larger numbers, and dividing by large numbers, so it seems a thousandth may be lost here or there.
num = irandom(255);
if(num < weightr[xx,yy]){
sat = 255;
}else{
sat = 0;
}
red[xx,yy] = (red[xx,yy] * samples[xx,yy] + sat)/(samples[xx,yy] + 1);
samples[xx,yy] += 1;
I'm hoping someone with raytracing experience can tell me if this is accurate math/methodology.











