PDA

View Full Version : Some specific questions about mental ray's GI...


ConSeannery
10-14-2009, 10:19 AM
Hi,

just a few questions about Gi in mental ray. I hope you can help me out, because some of these questions have been bugging me for quite a while now.

1. Why is Final Gather considered physically incorrect in comparison to photon mapping? Is it because it can't render caustic effects?

2. Does FG in multibounce mode sample the entire hemisphere of directions with each bounce or just one random direction? I find FG multibounce pretty fast. At least way faster than what I would expect from an exponentially growing ray count if the entire "FG rays" count was sampled with every bounce.

3. I remember this question was up on CGTalk before, but I can't find the thread anymore.
Anyway: I do not quite understand why we can specify a decay/exponent parameter with photon mapping. I always thought the inverse square falloff was implicit to photon mapping, because photons spread out into the scene and thus obey the inverse square falloff naturally.
Or in other words: what happens to a single photon that has an exponent of 2? Does its energy really decay with the distance travelled?

Forgot the 4th question! :-D

Thanks!

ConSeannery
10-15-2009, 11:56 AM
Nobody? :-(

InfernalDarkness
10-15-2009, 09:26 PM
I suppose I'm somebody. My parents used that lie a lot, anyway!

1. The math behind Final Gather wasn't intended to mimic photons, which are light particles of course and actually exist. FG was designed mostly to help blend and smooth other forms of lighting, so that you don't have to calculate billions of photons to achieve a realistic result. With modern computers you can often get away with JUST Final Gather, though... It can look pretty good.

"Physically Accurate" doesn't mean caustics. It means that it's based on actual real-world physics, which FG is not. Your eyes don't do an FG pass when you open them. Ambient Occlusion (AO) also doesn't exist in real life, but the theory goes like this:

A. Pure GI, insane quality levels, billions of photons per light = rendertime x
B. Optimized GI + Final Gather (and/or AO) = rendertime y

Now if rendertime y looks equal to rendertime x, OR renders faster, then you would want to use Final Gather. Especially if you're on a deadline. Even at print resolutions, there are still a very finite amount of pixels to be calculated. If this were not true, GI alone would likely be the most realistic choice.

2. I believe this is a function of the object's normals. You could test this by creating a low-poly sphere inside a high-poly sphere, set FG really low (Quality of 1, maybe), set the sphere to emit FG rays, and see where they land in your render or using the MapViz. I could also test it, but I don't wanna.

3. You can specify these controls so that they do just that, give you control. In real-life, one can't tell photons what to do. In MR, one can. Some scenes or styles call for such control.

4. I forgot it too!

ConSeannery
10-16-2009, 09:51 AM
I suppose I'm somebody. My parents used that lie a lot, anyway!

1. The math behind Final Gather wasn't intended to mimic photons, which are light particles of course and actually exist. FG was designed mostly to help blend and smooth other forms of lighting, so that you don't have to calculate billions of photons to achieve a realistic result. With modern computers you can often get away with JUST Final Gather, though... It can look pretty good.

"Physically Accurate" doesn't mean caustics. It means that it's based on actual real-world physics, which FG is not. Your eyes don't do an FG pass when you open them. Ambient Occlusion (AO) also doesn't exist in real life, but the theory goes like this:

A. Pure GI, insane quality levels, billions of photons per light = rendertime x
B. Optimized GI + Final Gather (and/or AO) = rendertime y

Now if rendertime y looks equal to rendertime x, OR renders faster, then you would want to use Final Gather. Especially if you're on a deadline. Even at print resolutions, there are still a very finite amount of pixels to be calculated. If this were not true, GI alone would likely be the most realistic choice.

2. I believe this is a function of the object's normals. You could test this by creating a low-poly sphere inside a high-poly sphere, set FG really low (Quality of 1, maybe), set the sphere to emit FG rays, and see where they land in your render or using the MapViz. I could also test it, but I don't wanna.

3. You can specify these controls so that they do just that, give you control. In real-life, one can't tell photons what to do. In MR, one can. Some scenes or styles call for such control.

4. I forgot it too!

Thanks InfernalDarkness! :-)
I'm glad someone replied!

1) I was actually more interested in the actual math that makes FG inaccurate or physically incorrect. As far as my understanding goes, photons are also a biased, yet consistent GI algorithm, meaning that only when you drive the number of photons to the limit they will actually be "accurate" or - mathematically expressed - "converge" to the correct result. As long as the number of photons is only in the range of a few hundred thousand or millions photon mapping is heavily based on density estimation and thus interpolation. So, both FG and photon mapping interpolate heavily which for all practical purposes makes them inaccurate and no better than a (very) good estimation of indirect lighting.

FG is based on irradiance caching or rather radiance caching since mr 3.5. I do not know for sure if these algorithms are also consistent estimators or if they remain biased no matter how many FG rays are shot...? So in case, FG remains biased, independent of the number of FG rays, is it this subtle detail that makes FG "inaccurate" and photon mapping "accurate"?
And what about the FG brute force method? I thought there was no interpolation going on, but is it still "inaccurate"?

2) I don't quite understand what you mean with FG multibounce being a function of the object normals. Also how you want to use this test to see if the entire FG rays count is used for every bounce? Do you mean that the outer sphere should have an exponentially higher number of FG points than the inner one?
Also, I thought one can only see first generation FG points with the map visualizer...

3) Thanks. I know this is just artistic control and does not relate to real world physics in any way. However, I am interested to know if at an exponent of 2 the algorithm behaves just like normal photon mapping, meaning the energy of an individual photon does NOT decay and only the spread of all emitted photons dictates the decay implicitly without affecting the energy of a single photon.

Thanks again InfernalDarkness. And sorry for this boring tech post, but I didn't know where else to ask these questions :-(

Con

FrizzleFry0
10-16-2009, 02:57 PM
Thanks InfernalDarkness! :-)
I'm glad someone replied!

1) I was actually more interested in the actual math that makes FG inaccurate or physically incorrect. As far as my understanding goes, photons are also a biased, yet consistent GI algorithm, meaning that only when you drive the number of photons to the limit they will actually be "accurate" or - mathematically expressed - "converge" to the correct result. As long as the number of photons is only in the range of a few hundred thousand or millions photon mapping is heavily based on density estimation and thus interpolation. So, both FG and photon mapping interpolate heavily which for all practical purposes makes them inaccurate and no better than a (very) good estimation of indirect lighting.

FG is based on irradiance caching or rather radiance caching since mr 3.5. I do not know for sure if these algorithms are also consistent estimators or if they remain biased no matter how many FG rays are shot...? So in case, FG remains biased, independent of the number of FG rays, is it this subtle detail that makes FG "inaccurate" and photon mapping "accurate"?
And what about the FG brute force method? I thought there was no interpolation going on, but is it still "inaccurate"?

2) I don't quite understand what you mean with FG multibounce being a function of the object normals. Also how you want to use this test to see if the entire FG rays count is used for every bounce? Do you mean that the outer sphere should have an exponentially higher number of FG points than the inner one?
Also, I thought one can only see first generation FG points with the map visualizer...

3) Thanks. I know this is just artistic control and does not relate to real world physics in any way. However, I am interested to know if at an exponent of 2 the algorithm behaves just like normal photon mapping, meaning the energy of an individual photon does NOT decay and only the spread of all emitted photons dictates the decay implicitly without affecting the energy of a single photon.

Thanks again InfernalDarkness. And sorry for this boring tech post, but I didn't know where else to ask these questions :-(

Con

1. The main difference between FG and GI is the way it branches out illumination. GI is actually the easiest to understand the concept because it's packets of energy emit directly from an actual light source, whether that's an IBL or standard Maya light. The first contact of photons does NOT contribute to any illumination because it assumes that the actual light you're using as an emitter is already going to illuminate that area (it prevents getting double-illumination or overexposure). Each bounce takes the surfaces diffuse properties to determine HSV information for the photon. For instance, if a blue photon leaves a light source and hits a pure red cube, it will have a purple color as it travels to the next surface. I'm not sure if it's a 50/50 blend of colors; from my experience it seems like it maintains a little more of the initial photon color than the surface color, so maybe more like a 60/40. These photons are traced throughout the whole scene and use their exponent falloff to determine how their intensity falls off over distance. So in summary we can say that GI is truly coming from a light source and only bouncing where light should actually be hitting.

FG on the other hand uses rays shot from surfaces to determine illumination. So if you have a spot light creating a circular patch of illumination on the ground, final gather rays sample the diffuse value of the illuminated area, and those rays shot from the surface have a value based on that diffuse information. So if we have an accuracy of 300, there should be 300 rays shot from the surface. It can come from density points OR surface areas set by tolerance (min/max radius) - it just depends which version of MR you're using and what you choose in the settings. So with only 1 FG bounce it obviously may not show ALL the indirect lighting you want. The tricky part is trying to force FG to maintain it's inverse square falloff. The secondary diffuse bounce doesn't seem like it maintains the same intensity as the first, so I would imagine there is some sort of falloff they're trying to incorporate into it.

Another thing to take into consideration with FG is that it is a camera specific calculation. So every time the camera moves, the areas that it samples diffuse values for rays actually will shift slightly. This can cause FG flickering as you watch a series of frames. So there are slight inaccuracies unless you use a higher point density, smaller min/max radius, and higher accuracy. Although, the same can be said for GI with photon count, accuracy, and radius.

And now that I'm thinking about it, a good example as to how FG and GI differ can be done with the basic example of a IBL around the scene. If use the IBL with photon emission, you should notice that as you scale the IBL up the intensity it casts on the scene should become lower. And if you scale it in closer to the scene, it should illuminate much brighter. This is done by the fact that it's using distance to control the intensity by the inverse square falloff. Now try the same thing with the IBL, but this time use only FG. You should notice that it doesn't matter how large or small you make the IBL - the intensities remain exactly the same. This is because the rays don't understand distance travelled through the same. All the understand is that they travel out in a particular direction. When you have thousands or rays all hitting the same area, it average them together to produce what we actually see with FG ray bounces.

2. The multibounce with FG probably does not use the same number of rays or density as the first bounce because the render time doesn't multiply with bounces like you would expect. There is a chance though, that the first bounce sets "cached" information for all future bounces to use. So for example, most of the render time is probably spent actually shooting rays out from the surfaces and calculating where they need to go. When secondary bounces occur, it can probably use the already calculated emission and contact points.

3. The ability to change exponential falloff for GI is really just for artistic control. The lower you make the falloff, the longer the photons will bounce. It can cause the scene to become washed out occasionally, so use it with caution. And raising the falloff causes lighting to drop off faster, giving a higher contrast look. I'm pretty sure that it affects each photon individually and not necessarily one overall affect to the GI solve. If it's already basing the falloff on units travelled, then I can't see why they would apply the exponent to everything at once.

Hope this helps!

FrizzleFry0
10-16-2009, 06:00 PM
EDIT:

Sorry I kind of got derailed on my last post and didn't really answer the initial first question. Probably the reason why GI is considered physically accurate is because it's actually coming from a light source and tracing through the scene, much similar to real lighting. FG's solve can be seen as more of a cheap way to replicate the same affect, but doesn't really "emit" from a particular light - just uses diffuse values of surfaces to help spread it around. It's kind of on the same concept as occlusion.

ConSeannery
10-16-2009, 06:25 PM
Thanks FrizzleFry0! :-)

1. The main difference between FG and GI is the way it branches out illumination. GI is actually the easiest to understand the concept because it's packets of energy emit directly from an actual light source, whether that's an IBL or standard Maya light. The first contact of photons does NOT contribute to any illumination because it assumes that the actual light you're using as an emitter is already going to illuminate that area (it prevents getting double-illumination or overexposure). Each bounce takes the surfaces diffuse properties to determine HSV information for the photon. For instance, if a blue photon leaves a light source and hits a pure red cube, it will have a purple color as it travels to the next surface. I'm not sure if it's a 50/50 blend of colors; from my experience it seems like it maintains a little more of the initial photon color than the surface color, so maybe more like a 60/40. These photons are traced throughout the whole scene and use their exponent falloff to determine how their intensity falls off over distance. So in summary we can say that GI is truly coming from a light source and only bouncing where light should actually be hitting.


Well, I do not quite know if this explains it mathematically. Photon mapping is simply a forward raytracing approach while FG is a backward one. Being a backward approach shouldn't make it physically inaccurate because path tracing for instance is also backward raytracing, but unbiased and therefore physically accurate.


FG on the other hand uses rays shot from surfaces to determine illumination. So if you have a spot light creating a circular patch of illumination on the ground, final gather rays sample the diffuse value of the illuminated area, and those rays shot from the surface have a value based on that diffuse information. So if we have an accuracy of 300, there should be 300 rays shot from the surface. It can come from density points OR surface areas set by tolerance (min/max radius) - it just depends which version of MR you're using and what you choose in the settings. So with only 1 FG bounce it obviously may not show ALL the indirect lighting you want. The tricky part is trying to force FG to maintain it's inverse square falloff. The secondary diffuse bounce doesn't seem like it maintains the same intensity as the first, so I would imagine there is some sort of falloff they're trying to incorporate into it.


The falloff should also happen with FG since the FG rays spread out hemispherically and thus less rays hit a surface that is farther away from an FG point as compared to the same surface when it is closer. It's because the projected solid angle of the surface is larger when it is closer to the FG point and therefore more FG rays "see" it than they would if it was farther away.
There is no intensity falloff for single FG rays, because an FG ray samples incoming radiance which by defintion is invariant in a vacuum. Right? Or did I get something wrong here?


Another thing to take into consideration with FG is that it is a camera specific calculation. So every time the camera moves, the areas that it samples diffuse values for rays actually will shift slightly. This can cause FG flickering as you watch a series of frames. So there are slight inaccuracies unless you use a higher point density, smaller min/max radius, and higher accuracy. Although, the same can be said for GI with photon count, accuracy, and radius.


Yes, thats true, but that shouldnt make it less accurate than photon mapping in theory. The flickering is just an interpolation issue just like photon mapping has a whole set of interpolation issues.


And now that I'm thinking about it, a good example as to how FG and GI differ can be done with the basic example of a IBL around the scene. If use the IBL with photon emission, you should notice that as you scale the IBL up the intensity it casts on the scene should become lower. And if you scale it in closer to the scene, it should illuminate much brighter. This is done by the fact that it's using distance to control the intensity by the inverse square falloff. Now try the same thing with the IBL, but this time use only FG. You should notice that it doesn't matter how large or small you make the IBL - the intensities remain exactly the same. This is because the rays don't understand distance travelled through the same. All the understand is that they travel out in a particular direction. When you have thousands or rays all hitting the same area, it average them together to produce what we actually see with FG ray bounces.

I haven't thought about the IBL case yet, but for a sphere with a finite radius there should also be a noticable difference in the FG solution depending on its scale. Of course, if the environment is a uniform color than there shouldn't be any change, but if you imagine a sphere that is black in most parts and has only a few illuminating spots than the FG solution should be affected, because fewer FG rays hit these spots if the sphere is scaled up etc.


2. The multibounce with FG probably does not use the same number of rays or density as the first bounce because the render time doesn't multiply with bounces like you would expect. There is a chance though, that the first bounce sets "cached" information for all future bounces to use. So for example, most of the render time is probably spent actually shooting rays out from the surfaces and calculating where they need to go. When secondary bounces occur, it can probably use the already calculated emission and contact points.

This could indeed be true. I believe you are right that cached FG points are reused by higher generation FG rays. Any suggestions on how we could test that? Probably closely oberserving the mr message window is a good start :)

Yes it helped a bit :-) Thnx!

FrizzleFry0
10-16-2009, 06:49 PM
Thanks FrizzleFry0! :-)



Well, I do not quite know if this explains it mathematically. Photon mapping is simply a forward raytracing approach while FG is a backward one. Being a backward approach shouldn't make it physically inaccurate because path tracing for instance is also backward raytracing, but unbiased and therefore physically accurate.



The falloff should also happen with FG since the FG rays spread out hemispherically and thus less rays hit a surface that is farther away from an FG point as compared to the same surface when it is closer. It's because the projected solid angle of the surface is larger when it is closer to the FG point and therefore more FG rays "see" it than they would if it was farther away.
There is no intensity falloff for single FG rays, because an FG ray samples incoming radiance which by defintion is invariant in a vacuum. Right? Or did I get something wrong here?


Very true about the backwards and forward raytracing. The hemispherical sampling does give the same basic affect as GI photons - like you were saying with the concept of a sphere being closer to an object, and therefor having more contact information with the incoming rays or photons. I guess really the main difference comes from how you, as a user, tweak out the initial intensity - FG using the intensity of what the lights contribute to the surfaces' diffuse values, and GI using it's own intensity as it leaves the light source.

If you find any more information about the math, I'd be real interested in checking it out. Most of the stuff I know is just from theory and whatever research I can find online.

Cheers!

CGTalk Moderation
10-16-2009, 06:49 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.