Irradiance Caching and Local Illumination

   22312   25   1
User Avatar
Member
4262 posts
Joined: 7月 2005
Offline
Quick question concerning Irradiance caching.

Are there any tricks for adding the local illumination (like diffuse(N) ) to the irradiance cache? It seems the irradiance cache only contains the bounced illumination from other objects. It would be neat if we could specify what gets stored in the cache.

jim.
if(coffees<2,round(float),float)
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
Yup…

…after three days, I thought it's be good to break the overwhelming……silence. 8)

<ping!>

Jim: No; I'm pretty sure there's no way (currently) to access the cache contents from VEX
But, like Jim (I'm assuming), I've been using prman's tracing/GI stuff quite a bit lately, thinking all the time “how would I do this in VEX, I wonder…” – especially since I got to get back into “porting mode” once I finish this job….

So; I'm also wondering what SESI's future plans may be regarding:

1. Adding shading-context hooks in VEX to read/write an arbitrary cache file.

2. Adding a way to discriminate amongst rays at the shader level (ray labels/tags/whatever).

3. Does the current cache mechanism support arbitrary attributes? – not that it *has* to really, but it would make it even more powerful

4. And for any of the above to be really useful, we'll need some equivalent to the gather construct. Then again, maybe with a beefed-up verion of the irradiance() function and a means to query the rays that trigger each shader, we can do without an actual gather construct? maybe? no?

Comments from SESI on any of these would be much appreciated



<ping!>

… we now return you to your regularly scheduled silence… (we need a ninja emoticon, lol!)
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
4262 posts
Joined: 7月 2005
Offline
Thanks for chiming in Mario.

Your textureinfo discussion on the mail server was what prompted me to post this thread.

To be honest I knew the answer to my question I was just trying to stir the pot a tad. :twisted:

I admit it, I'm guilty of 2nd degree pot stirring.

jim.
if(coffees<2,round(float),float)
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
Wolfwood
I admit it, I'm guilty of 2nd degree pot stirring.

Hehehe;
Yea… I kind'a figured your question was somewhat rhetorical

Incidentally…
Are you also trying to port this shadowmap sss trick to VEX?
I probably won't be able to spend any serious time on it until this job's over (couple'of weeks), but maybe we can compare notes and post our results here.

waddya think?
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
4262 posts
Joined: 7月 2005
Offline
Actually a while back ago I tried a straight raytracing approach. For the single scattering I refracted “I” into the surface then along this ray I the light that was being transmitted from the surface (where the light entered). For the diffusion approximation I didn't really follow the dipole way, I created sample points on plane using the surface derivatives at P then projected those points to where the light entered the surface. But I loss interest since it was WAY too noisey when animated. And I kept running out of tricks. Like if I'm at a point in space how did I know where light entered the surface? Trace a ray from the light source? etc? Since then I've been patiently waiting for ray labels in mantra. :wink:

Oddly enough ZJ updated his page just yesterday with a new template.
You can check it out here,
http://zj.deathfall.com/depthbasedTranslucence.htm [zj.deathfall.com]

With all this new interest I'll give it a try since I'm still a bum for the time being.

jim.
if(coffees<2,round(float),float)
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
Wolfwood
Oddly enough ZJ updated his page just yesterday with a new template.
You can check it out here,
http://zj.deathfall.com/depthbasedTranslucence.htm [zj.deathfall.com]

I just saw the little avi's… the shadow side seems to have a grid-like/blotchy look to it; though it's hard to tell from such a tiny image. But good to have at least one coded attempt out there

Wolfwood
With all this new interest I'll give it a try since I'm still a bum for the time being.

Great. I'll try to research it some more in my spare time (read: between Harry Potter “readings” to my kids :lol.

First thing, i think, would be getting a solid version in prman (since that's where it was originally implemented), and then finding out what needs to get modified to work in VEX – assuming all the necessary bits can be accessed. Or maybe developing both in parallell… hmmm….
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
4262 posts
Joined: 7月 2005
Offline
Tonight at the Marengo household:

“Tonight children we are going to take a break from Harry Potter, Daddy will continue with Harry tomorrow. But tonight I got a special surprise for you! Its called ‘A Practical Model for Subsurface Light Transport’ by Henrik Wann Jensen, et al. Its just like Harry Potter because there is lots of magic involved, but without the whining. Lets begin. 'This paper introduces a simple model for subsurface light transport….”



jim.

ps. If they follow what you are saying then their career path is officially chosen.
if(coffees<2,round(float),float)
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
ROTFLMAO!
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
Well; I managed to escape Harry Potter long enough to have some time to look at this bssrdf thing a little more closely.
Here's a first stab at the single-scattering term (in VEX):





WARNING: This is *NOT* a shader (yet – so please don't download these files expecting a full subsurface scattering solution. I'm posting these so as to start a discussion on some of the issues involved in implementing something like this in VEX. And in the end, eventually, yes: maybe even a shader
At the moment, these files represent only one half of one function (one term in an equation) that, when coupled with the other half, will form a type of illumination model (like Diffuse, Lambert, Oren-Nayar, and so on).

The good news: it works
The bad news: well.. there really isn't any *bad* news, but there are a bunch of issues, as with anything meaty like this

Tech Notes

Maps:
Among the key elements in Hery's approach are shadow maps. In the prman implementation, a shadow map is used to extract both the depth of the projected sample point and the percent occlusion for the light. This, as it turns out, is not possible in VEX. The shadowmap() functions return only occlusion, and the texture() function, only RGB or RGBA (according to the docs). This leaves only the depthmap() function for accessing depth, which requires a “mantra -Z” pass – an exclusive pass that generates nothing *but* z-depth: you can't e.g, generate both z-depth *and* the normal map *and* the shadow map for the light (if you choose not to use traced shadows) in one pass.
This means that the map-making side of the pipeline becomes:
Pass 1: z-map with light as camera.
Pass 2: N-map plus shadow map with light as camera.

What I ended up doing instead, is changing the singlescatter() function so it uses a map with a special format: the normal (N) is expected to be stashed in channels R,G, and B, and the depth in Alpha. This means you can generate all three maps (shadow, z-depth, and Normal) in one pass. It also means this pass has to be generated with “-b float” since both z and N should be floating-point values. For this pass, you can probably also get away with setting the filter to “box 1 1” and super-sampling to 1x1, which makes it really fast.
The bad news is that you need a different shader active for all objects (or a different set of objects) for this pass to work. Here is a simple test shader [members.rogers.com] that puts N and z in the right slots.


Spaces:
I ended up writing it backwards: from the singlescatter() function back to VEX/Houdini; simply assuming that things like xform matrices and such would be dealt with by the caller, and passed in properly… well; it was a nice dream while it lasted
The result was that doing the singlescatter() translation took about 1/10th the total time, and the other 9/10ths were spent hallucinating ways to extract the necessary bits from VEX :shock:
The function needs two matrices: one to go from “current” to “light” space, and one to go form “current” (through “light”) to the light's “NDC” space. In PRMan, both of these are stored with the shadow map, so it's a no-brainer. In VEX, AFAIK, they're only accessible at run-time, and only from within the light context… except they aren't, really… at least not in the form of matrices, that is
You can xform a vector from/to one of these spaces, for example, but you can't (again, AFAIK) extract the actual matrices.
Long story short: I ended up building them by hand from inside the light context.
The current-to-light construction assumes the xform will always be affine/linear, which should be a safe assumption (I hope). And light-to-NDC is not a matrix at all! – it's just the scaling factors (minus the .5 offset that puts (0,0) at the bottom-left corner) for x and y, based on a light-to-NDC projection of the (light-space) point (1,1,1). This means the client has to do the z-divide and add back the offset to finally get NDC.
It is messy. I don't like it… :evil:
I got tired of thinking about it after a while, but if someone can think of a way to generate the NDC transform as a *matrix* from inside the light context (i.e: a way to get at the near, far, left, right, top, etc.).
Oh; I also snuck in a much-needed bias parameter in there… we're dealing with maps after all. Here's a small shader [members.rogers.com] to test-drive this side of things.


Sampling:
Hery pushes the samples away from the refracted outgoing ray “To” (and into the volume projected by the shading area) using a Poisson lookup table. Two problems with this; one conceptual, and one practical:

1. It's hard to (for me at least) to infer *exactly* how the poisson distribution was intended to be used. My gut tells me it's meant to be centered at 0.5 so the majority of the samples lie close to the central axis of the volume. i.e: lambda=0.5, with a spread of .
But it could also be interpreted as an amplitude distribution based on sample number – earlier samples get jittered more than later samples… although this wouldn't make much sense, would it?

2. Regardless of what the correct interpretation may be, VEX does not support arrays (and you can't do it with the pre-processor; I don't know what I was thinking when I suggested that, lol), so the possible implementations for VEX are quite limited:

A) Do it as a DSO shadeop. The most sensible solution (and the one I'll adopt), but unfortunately non-portable: platform/compiler issues, not to mention the fact that you'd need the HDK to port it to Windoze… but if others chip in, then…

B) Write it as a VEX function and call it from inside a surface shader. Apply the shader to a grid that fills frame, render a square, point-sampled image, and use *it* as the lookup table. You'd need to pass it to the singlescatter() function, which would then use a point-sampled texture() call to get at the Poisson distribution indexed as ui%resx)/resx and vi%resy)/resy.

C) Use a uniform distribution until SESI adds support for arrays in VEX

For this test, I've left it with a uniform distribution, but I also sketched in some of the necessary bits for a possible DSO implementation [members.rogers.com]. The static lookup-table-like output from such a function would look something like this [members.rogers.com].


The Single Scatternig Term:
I wrote the translation with both the Hery slides and Jensen's siggraph paper side by side, checking every line against each other. As you can imagine, there were *lots* of little details that came up, but I've included copious amounts of comments in the code [members.rogers.com], so I won't repeat them here. I basically dissected it line by line, trying to explain each and every step.


Anyway… fun stuff!

Ideas, suggestions, corrections, flames… all welcome.

Edit:
Here's a little shader [members.rogers.com] to drive the singlescatter() function
Edited by - 2003年7月3日 14:02:45
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
4262 posts
Joined: 7月 2005
Offline
CHEERS!

Very nice Mario!


Description: The mind-numbing complexity of this shader would
simply take too long to explain in this itty-bitty space,
sorry.


ROFL. (Fermat's Enigma)

Even sportin a pdisc.

While no one is looking today at work I'll check it out all the details. :wink:

jim.
if(coffees<2,round(float),float)
User Avatar
Member
4262 posts
Joined: 7月 2005
Offline
The magical 304.8 scaling factor is to convert mm to feet. However I"ve never really figured out why. Jensen provides a table of values in his BSSRDF paper which are in mm. But to use those values I thought you would just need to invert and normalize them.

More in a second.

jim.
if(coffees<2,round(float),float)
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
AH HA!!

Good one Jim!

OK. It still doesn't quite explain it, unless their modelling is all done in “virtual feet”…. I suppose that's possible… hmmm.
In any case; it would seem safe to remove it altogether, then.

I'll probably get back to it tonight after work…

Thanks!
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
4262 posts
Joined: 7月 2005
Offline
2. Regardless of what the correct interpretation may be, VEX does not support arrays (and you can't do it with the pre-processor; I don't know what I was thinking when I suggested that, lol), so the possible implementations for VEX are quite limited:

What about generating your array and storing it to a floating point tiff file.
10x10 pixel tiff file would represent a 100 element (0-99) array. You would load up the tiff file as a texture, turn on point filtering (no filtering). Then using your s & t you could access the texture map like an array.

Just to test this out, I created a 9 by 9 (pixels) tiff file. All the pixels were black except the middle one which was red. With my S and T both set to .5 I was able to point sample that specific pixel in the texture map and get (1,0,0). (Or the 41th element in my array of 81).

Or you could do it in a nice long 1 pixel high tiff.
Here is a sample file. There is a 18x1 pixel noise cop. And a VOP network. So your array would be . So to get the next to last element your “s” value would be (16/17).

http://www.stickylight.com/FLinks/texarray.zip [stickylight.com]

A couple of other tests gave the same results with a +/- 0.0001 margin of error like 0.9999 instead of 1, but I can live with that. (Not so sure about Mario though :wink: )

Yes? No? Beer?

jim.
Edited by - 2003年7月3日 00:08:38
if(coffees<2,round(float),float)
User Avatar
Member
4262 posts
Joined: 7月 2005
Offline
Doh, I didn't even finished reading all of “2” before I posted the above. Mario already pointed out the point sampling trick in “2B”.

Got all excited and jumped the gun. Sorry for being redundant. Check out the example though.

jim.
if(coffees<2,round(float),float)
User Avatar
Member
4262 posts
Joined: 7月 2005
Offline
Now I'm just spamming.

What about a “3rd” pass which holds the extinction coefficient (rendered from the respective light). So instead of having uniform coefficients all over the surface you could paint them like texture maps.

jim.
if(coffees<2,round(float),float)
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
Yes; this would work fine even if the sampling weren't *exactly" on the pixel. After all, a linear interpolation (or an averaging) between neighbours should still retain the distribution. So yes; a definite possibility

The only reason I'd stay away from it would be because the function would now suddenly depend on an external resource, breaking portability. Same goes for the DSO approach, I realize… so; ultimately, there's nothing better than a mechanism that's built into the language: arrays.

H6.1? … H6.5? … H7.0? …. SESI? :roll:
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
Wolfwood
Now I'm just spamming.

What about a “3rd” pass which holds the extinction coefficient (rendered from the respective light). So instead of having uniform coefficients all over the surface you could paint them like texture maps.

jim.

I'm assuming you're talking about a method of applying a *varying* version of the (currently *uniform*) scattering and absorption coefficients.
Extinction is derived from those other two and applied on the outgoing side of the path (camera), where the sampling is done, and the algo then assumes that this value is the same on the incomming side.

My first instinct would be to say “yes” – that there's nothing stopping you from using some form of texturing to vary the material properties inside the volume (paint-like variations purely *on* the surface would project monotonically into the volume) – but after thinking about it a little, the assumptions currently being made on the incoming side of the path would probably break down (visually) for certain kinds of textures (low freq albedo changes with high translucency).

Definitely something that it should support eventually – after all other wrinkles are gone and the diffuse dipole side is working
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
DOH! :shock:

I just looked through my initial post again, and realized I forgot to include a link to the little shader that tests the singlescatter() function!

Sorry everyone ops:

I've edited that post to include the link
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
4262 posts
Joined: 7月 2005
Offline
Teehee, the new link points to poissondist. :cry:



jim.
if(coffees<2,round(float),float)
User Avatar
Member
941 posts
Joined: 7月 2005
Offline
Wolfwood
Teehee, the new link points to poissondist.

Not my day

… try it now…
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
  • Quick Links