Manta Interactive Ray Tracer Development Mailing List

Text archives Help


Re: [MANTA] rng in thread context?


Chronological Thread 
  • From: James Bigler <bigler@cs.utah.edu>
  • To: lacewell@cs.utah.edu, "'manta@sci.utah.edu'" <manta@sci.utah.edu>
  • Subject: Re: [MANTA] rng in thread context?
  • Date: Fri, 09 Mar 2007 16:05:39 -0700

You don't know the width, but this will probably work

((u+1)*2^15)*2^16 + ((v+1)*2^15)

This is based on a square that (2^16)^2 = 2^32. So the width of our window is 2^16.

(row*width)+col = (row*2^16)+col.

Now we have to scale our (u,v) to be in the [0,2^16] range.

u = [-1,1]
u+1 = [0,2]
(u+1)*2^15 = [0,2^16]

Replace that and you get the above expression. We can reduce this a bit by factoring out the *2^15

((u+1)*2^16 + (v+1))*2^15 or

((rays.data->image[0][ray_index]+1)*65536 +
 (rays.data->image[1][ray_index]+1)         )*32768;

But perhaps this won't work without casts in the proper place. I haven't thought about it that much.

James



Dylan Lacewell wrote:
Dave suggests row-major order (row*width + col), which will assign a unique seed to every pixel. I'll try that, but I think it should work.

James Bigler wrote:
Before we get all the machinery in place, you can get by with the following bit of code:

#include <Core/Math/CheapRNG.h>

for(ray_index = [rays.begin, rays.end]) {
  CheapRNG rng;
  // rays.data->image = [-1,1]
  unsigned int seed = (rays.data->image[0][ray_index]+
                       rays.data->image[1][ray_index] + 4)
                      * 1073741824; // 1073741824 = 2^30
  rng.seed(seed);
}

This code will even work for jittered samples, because the little differences in data->image (coordinates on the image plane) will produce different seeds.

James

sparker@cs.utah.edu wrote:

add one to render context -bthat is where it should go. James can point you to his rng classes.

Steve

-----Original Message-----

From:  Dylan Lacewell <lacewell@cs.utah.edu>
Subj:  [MANTA] rng in thread context?
Date:  Thu Mar 8, 2007 8:18 pm
Size:  418 bytes
To:  manta@sci.utah.edu


Is there a way to get a stream of random numbers in a surface shader? I don't see a random number generator exposed in the thread context, so I'm going to hack in my own for now.

I'm writing an ambient occlusion shader which jitters the occlusion rays. I can't use a local random number generator because that will give each shading point the same set of occlusion rays, which causes structured artifacts.

D







Archive powered by MHonArc 2.6.16.

Top of page