Search - User list
Full Version: Irradiance Caching and Local Illumination
Root » Technical Discussion » Irradiance Caching and Local Illumination
edward
For arrays in VEX, there's always this Ugly VEX Kludge:
float arrayGet(int i) {
if( i == 0 ) return value0;
if( i == 1 ) return value1;

}


Since you're already generating your look up table already, might as well generate an array lookup function that you can include.
Mario Marengo
edward
Since you're already generating your look up table already, might as well generate an array lookup function that you can include.

Yea, you're right. It's automatic, so might as well…

But would I then get the highly coveted “Longest if-then Cascade Ever Written” award?

Thanks edward.
mark
Hmmm… These seem to be one dimensional arrays, no?

Why not use the spline functions. This gives you interpolation on the lookups and can be written (well generated at least) as a simple one line function:


float
poisson_dist(float t)
{
return lspline(t, …..);
}


I haven't looked at the shader, so I may not know what I'm talking about. However, from the test app you posted, it looks like they are 1D lookup tables…

This way, it could be self-contained.
Mario Marengo
mark
Hmmm… These seem to be one dimensional arrays, no?
Why not use the spline functions.

Yes; these are 1D static arrays, and yes, using the spline functions is a very good suggestion indeed. Thanks Mark!

Here is a quick modification of the generator (along with its output) for both Mark's and Edward's suggestions:

Edward: generator [members.rogers.com],output [members.rogers.com].
Mark: generator [members.rogers.com],output [members.rogers.com].


A few notes:

1. I've no idea what the maximum number of arguments might be for VEX (or even if there is a cap at all), so I just took a guess at 100, which it seems to accept OK. If the limit is much higher (or doesn't exist), then the spline version wouldn't need to be split into blocks of 100 args each as it is now, making it run faster…. (Mark?)

2. This call is made once per sample, so it's pretty important that the solution be as fast as possible. I did a quick profile on both solutions and, not surprisingly, the spline version ran faster. What *did* surprise me was just how *much* faster it ran:
if-chain: 7.41 secs (355,081,424 instructions)
lspline(): 0.55 secs (15,189,372 instructions)
That's close to 14 times faster! (and about 23 times less instructions!!) :shock:
… guess the optimizer can't do much with the if() statements (even though they're all immediate returns of a static value), and probably ends up with all the overhead of a full branching. Also; the if-chain can't solve this in constant time (linear with a worst-case at index=N-1). Anyhoo… interesting results… and the spline() function seems to be the VEX-method-of-choice for all your static lookup needs

3. I'll likely start looking into the dipole diffuse (multiple scattering) section when I get a chance (this is fun but I still got a job to finish ). But in the meantime:

A) Has anyone had any ideas about how to construct a light->NDC matrix from within the light context? – or an alternative solution for the whole matrix thing?

B) Anybody think my interpretation of how the poisson dist. is meant to be applied (highest density at center of beam -> 0.5) is way off?

C) Anyone disagree with the modifications I made to the code in the slides (based on my comparisons to the Jensen paper) ?

D) Would anybody care to have a go at a version of this using rayhittest() instead of all those maps? (rayhittest() will likely play a big role in the dipole function)…. Jim?


TTYL,
wolfwood
Word.

Thanks for all the effort Mario. I really wish I could play too but I just started at c.o.r.e. and well… this working thing… actually takes up a lot of time. :shock:

I'll try to get to it tonight. I PROMISE.

jim.
Mario Marengo
Wolfwood
I really wish I could play too but I just started at c.o.r.e. and well… this working thing… actually takes up a lot of time. :shock:

Hahaha…. yes; *shocking* isn't it?!

Wolfwood
I'll try to get to it tonight. I PROMISE.

LOL. I was just kidding!
It should go without saying…. no pressure – only if there's time, and only if you (or anyone else) is into it 8)

Cheers!

P.S: Say hi to Bret Culp for me
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB