Home

Topic: Basicly, THE Basics: GI lowdown from ELZARION.

posted by ELZARION
archived on 1.5.2002

There seems to be a fair bit of confusion around here about what exactly different GI techniques VRay uses or could use in future are, what is good/bad about them, etc... so I'm posting this to try and clarify that...

1) The simplest kind of GI that VRay uses, Direct Computation uses a very simple algorithm: for each point to be shaded, it sends out a lot of rays into the scene (the number is controlled by subdivs), to work out how much skylight/bouncelight/etc. it gets - it reaches out to see what is around it, in effect.

This has the major advantage of giving, on the right settings, GI that is extremely clean and accurate - there isn't any blurring or interpolation artifaacting, sharp variations are very clear, and smooth shading looks smooth (though you do need sufficient samples :)

2) VRay also offers a GI style called irradiance maps. With irradiance maps, instead of working out what hits every point it hits when it renders your final image, VRay renders a low resolution picture, and every time that picture hits a diffuse surface (including reflected and refracted GI), it works out what the GI at that point is, in exactly the same way direct computation does, where a bunch of rays are sent out to find what's there, with number of rays (and thus accuracy of GI) controlled by subdivs). If there is lots of colour, angle, or whatever variation, more points are calculated where that variation happens, according to your sampling settings.

The end result of this is a collection of 3D points with GI shading info - your irradiance map.

Then, when VRay goes to render its actual image, instead of having to calculate GI at each pixel, it can just blend between samples on your irradiance map. The amount of samples blended together is controlled by Interp. Samples - this is how many of those 3D points are taken into account.

Now, some notes on irradiance map quality...
Irradiance maps render at low resolution for speed. This is often very effective, since GI tends to be smooth stuff. However, sometimes GI is actually quite sharp and clear - and in these cases, irradiance mapping, used incorrectly, makes GI look flat, dull, and bad.

Either that, or it tends to look gross and blotchy.

This is *not* an inevitiable aspect of irradiance mapping - it can be avoided, with some understanding of what is going on and careful parameter tuning...

This tutorial is biased towards acheiving high quality GI, not giving fast renders - in general, you just have to work the other way around for fast, low quality GI that looks as good as it can at that quality [ more on this later ].

The first step in getting a high quality irradiance map render is to render with direct computation. The reason you do this is that it gives you a target picture with very accurate, clear GI. This picture represents the ideal GI situation - the GI is calculated without any blurring or distortion, maximum quality. You will need to set the sample rate up a bit to get a pic without too much grain, but in general, just get the grain down to a level where it doesn't obscure the subtler GI shading too much.

Now, you have to play a balancing game... here's how it works:
We have 3 main things to tune:
- Interp. samples
- Subdivs
- Sampling rate (in image space, not GI accuracy like subdivs)

Interp. samples simply controls, as I said, how many samples are taken into account...interp. samples has these effects:

Low:
- Blotchiness in the irradiance map is far more visible
- Details are clearer/GI looks sharper
High:
- Blotchiness is masked by the blurring effect
- GI is flat and fuzzy

Interp. samples only has a small effect on speed - it mostly affects only the rendering stage (and that not by much), but also since sharp settings make shifts more visible, low interp. samples makes the supersampling more sensitive.

Also, on very low samples (less than about 8), the underlying structure of the irradiance map becomes clearly visible, and makes it look blocky, no matter what else you do. A value of 8 is about as clear as you can get without seeing these, so often works very well, but requirees pretty high sampling rates to kill blotchiness - since it makes blotches at their most visible.

Basically, think of interp. samples as a blur effect... high amounts make both noise and detail disappear.

Subdivs controls how well your GI is sampled - low subdivs leads to a blotchy irradiance map, high subdivs leads to a clean one. This is how accurately your GI is calculated - high values lead to sending a lot of random rays out into the scene from the shade point to work GI out, low values lead to few.

Blotchiness is the result of insufficient sampling rates to properly represent the scene (which means the random placement of your rays shows up as noise). Note that here I'm talking about blotchiness in the irradiance map itself, not in the end image - high interp samples can make it invisible, but it's still there in the map and will show up if you rerender with the same map but low interp settings.

High:
- Samples in irradiance map are clean
- Slow - lots of rays are sent out

Low:
- Samples in irradiance map are noisy
- Fast - not many rays are sent out
Low samples acts like grain on your irradiance map - which, combined with clear, lower interp. samples makes things look blotchy.

There are a few sampling settings - the primary ones are the minimum and maximum irradiance map rates. These define how densly VRay samples to start with and how densly it will sample if it decides it needs more samples, which is controlled by colour, normal (basically angle), etc. thresholds - which are "variation before VRay decides it needs more samples", so low colour/normal thresholds means that even small variations make VRay decide it needs more samples easily, and high thresholds makes VRay treat even larger variations as not requiring more samples.

High:
- Sharp irradiance map
- Higher resolution of calculation doesn't decrease intensity of blotchiness but makes blotches smaller, and often a bit more visible.
- Slow - more samples are taken.

Low:
- Blurry irradiance map
- Map looks blurrier, blotches are still same intensity but they are stretched out more, so can often be a little less visible.
- Fast - less samples are taken.

[ remember, big negative numbers are lower than small ones, -3 is lower than -2, which is lower than -1, lower than 0, lower than 1 etc. ]

VRay's adaptive sampling is mostly pretty efficient, so usually for clearer GI it is fine to just go from the defaults of -3/-2 to -3/-1 or -3/0, but for some scenes you may need to go to -2/-1 or -2/0 to get the clarity you want. You may often find it is much more efficient to get it sampling higher just where you need it by lowering thresholds...

So here we have interp. samples, subdivs and sampling rate... if you extend the image analogy:
- Sampling rate is the resolution of your image
- Subdivs is how grainy your image is
- Interp. samples is a blur filter

So a blurry, low resolution image doesn't show much grain/blotch, but isn't clear.

But a sharp image needs a minimal amount of grain otherwise it's pretty clearly visible.

And a higher resolution image isn't much more or less grainy (since this is pixel grain), but the grain is smaller.

And calculating a high resolution, clean image is slow.

And so on...

So basically, that's what's up with VRay's irradiance maps.

Now, what are photon maps? Or more specifically, global photon maps.

Your basic photon maps are very simple - they shoot a bunch of photons out of a light, and see where they bounce to make caustics.

The idea of global photon maps is very similar - you start with a light, and bounce a bunch of photons around the scene, leaving trails behind them

Now comes the special bit: If we have a light, and it is pumping out a bunch of these photons, and they are leaving trails behind then:

You can pick any point in your scene, and look at the direction the trails are going in that general area, and those trails will point to where the light is coming from.

Pretty special, aye?

Now, it's only an approximation - if you directly render those light trails on your geometry, it actually looks awful.

BUT, since you know know the general direction that the light is coming from, you're a hell of a lot better off than you were before - you didn't know *anything* about it before with your direct GI, and just threw rays around randomly, which is very inefficient if, say, a lot of your light is coming from a spot on a wall where the sunlight hits it, and you're still looking all over the place.

Global photon maps provide, well, a map - a map of where the light is going. So you can just say at point x "Where is my light roughly coming from?", your photon map says "Mostly in the direction of that wall over there..." then you say "Instead of sending my GI samples way off to the black patch there and wasting loads of time getting nowhere and only spend a bit of time getting somewhere, I will go straight to the wall!". And it does - it sends most of its samples right to the wall, and just a few around the dimmer parts, to get the smaller effects from elsewhere.

So global photon maps are great - they let you sample far more effectively, and thus get clean images much faster than traditional random ray-chucking - it's smart ray-chucking.

Of course, they're not without their problems - the fact is that since they try to represent your continuous lighting with individual lumps of light, they can cause artifacting or localised blotching if the global photon map is too low-res, and they need extra memory, and can sometimes be more trouble than they're worth - but often they can give you much less grain for the same rendertime and are just cool :)

Hope this helps you with your GI, VRayers :)


> print this entry
VRay.info v2.0 | VRay.info is NOT the official VRay site. VRay is property of Chaos Group