"Radiosity"

You can grab the scene-file used for these tests here: Radiosity.ZIP


Index

Introduction

Photon Issues

Radiosity Issues

Pure Radiosity

Radiosity + Lightsources

Radiosity + Lightsource + no_shadow on Lightobject

Final notes on max-trace-level and recursion-limit


Introduction

After using POV-Ray for a long time, I've finally taken notice that I don't know that much about it's radiosity feature as I've actually liked to know. Interdiffuse light reflection is a component in our everyday life and is one of the main reasons why we identify a CG image out of a bunch of photographs. The light-interaction without radiosity is just too plain flat.

But there are some things which have to be said beforehand, or you might get confused about what I'm talking: POV's radiosity feature is actually a global illumination algorithm. The difference between these two is very simple: actual radiosity is normally based on patches, which subdivide surfaces and store lighting information, whereas global illumination is a technique using samples spread across surfaces. The main issue on this part lies on POV-Ray being a raytracer: global illumination is better suited for that. The main difference is also in the mental handling of options. Thinking in samples is more suited than thinking in patches, where POV-Ray has (almost) none...

And finally, I've done radiosity in two passes since about a year and found in useful and far easier to handle than trying to get ultra-realistic smooth results right away. Credit for this goes to the newsgroup community. Gilles Tran, who explained this approach on the newsgroups to me at some point, later told me that one User had a problem with radiosity, and several others joined the fray. Finally, this technique emerged. I've used it ever since.

I use a very low error_bound on the first pass (like .1 or .05), but multiply it with 4 or even 8 when loading it later (two pass method only makes sense when saving and loading the radiosity, so you might want to look up "save_file" and "load_file"). With this, I get pretty crappy results on the first pass, sometimes even with black holes and blotchy artefacts. These are smoothened when using a higher error-bound when loading, since POV-Ray interpolates amongst more wider spread samples than taken on the first pass. This is actually the point of the entire two-pass process and a main issue when judging this review.


Back to Top


Photon Issues

Photons cover one of the more tricky aspects of lighting: specular reflection and refraction of light. This occurs on mirrors and when light is passing through transparent or filtering medium. This was the basic idea in implementing photon lightmapping in the first place - a raytracer traces light backwards, from the camera outwards until it reaches a surface and is stopped there. It could impossibly check if some light is being reflected/refracted off of some other object somewhere in the scene. So, to circumvent this, photons are shot from a lightsource and are reflected/refracted by objects (note that they are initially shot at objects designated with the target keyword in the photon-block, look at the docs 6.10 "Photons").

Photons are unaffected by radiosity calculations, but radiosity does take lighting due to photons into account, though their effect into actual calculations seem to be very small. They DO make a difference, so keep that in mind when modelling scenes which will rely heavily on photons: you'll need to have them in-scene when generating radiosity lighting.

The main thing about combining photons with radiosity is very easy to understand: radiosity doesn't handle specular reflection that well, it's more suited to diffuse spreading of light. Combining them is thus simple conclusion anyone would come to sooner or later. An important sidenote to this is that when loading photons, the original lightsource doesn't have to be in the scene anymore. This is shown with the example below.

The basic scene layout, with a lightsource just below the bright box at the top. The lightsource shoots the photons.

The loaded Photons. The glowing box is visible due to its in-scene ambient value, it doesn't actually store any photons itself.


Back to Top


Radiosity Issues

The main thing of the two-pass method is to create extremely detailed data, even though displaying them might not look as detailed (as in "blotchy", "black holes"). The idea is to interpolate amongst many more samples in the second pass and thus obtain smooth results.

1st Pass

brightness 1
error_bound .1
minimum_reuse .0025
nearest_count 20
count 1200
recursion_limit 2
always_sample off
low_error_factor 1

I'm using a very low minimum_reuse, which, along with the low error_bound, should ensure lots of samples in the scene. nearest_count is set to maximum, thus attempting to raise sampling when there are too few around to get averaged. count doesn't have to be maxed, but just further increases smoothness of samples. Low_error_factor is normally used to lower the error_bound on pretraces, which, in fact, is like doing an internal two-pass.

2nd Pass

brightness 1.25
error_bound .8
minimum_reuse .0025
nearest_count 20
count 1200
recursion_limit 2
always_sample off
low_error_factor 1
The only two things I do on the second pass is raise the error_bound either by 8 or 4 (just take 2 with some exponent if you want to smoothen ever further), and modify the brightness somewhat upward on radiosity-only images, as smoothening often loses the very bright regions. I lower the brightness on lightsource-driven images, in order to have radiosity add less effect to a (probably) already well-lit scene.
pretrace_start 1
pretrace_end 1

When loading radiosity, it is unnecessary to pretrace the entire scene again, that was done on the first pass to ensure a proper placement of the samples. With these values, POV-Ray won't pretrace.

Regarding the pretrace: I can't really recommend anything on those. The two-pass method described and used throughout this experimental series didn't show any major differences when using only one, two or four pretraces. It is advisable to do something like 4 or 5 pretraces (just divide the pretrace_start by 2 as many times as you want another pretrace-round) to make sure that all areas are sampled somewhat evenly, but this can also be achieved with a VERY low settings for pretrace_start and -end (like .01 or such).

Regarding low_error_factor: One might say that what this technique does is exactly what low_error_factor is supposed to do: use a lower error_bound during the pretraces, and raise it a notch on the final rendering. And you are correct, it is the same thing done by hand. There is, nontheless, a difference.

One would assume that when using "always_sample off", no additional samples will be taken after the pretraces. That is wrong. It will still gather samples when there is need. Christoph Hormann explained that always_sample will just set nearest_count to 1 on the final trace. Thus, if no samples is found, a new one will be gathered. Combining this with an error_bound of 0.1, even with always_sample set to off, there are lots of holes in which radiosity will fit another sample. This is where the two-pass method kicks in: radiosity-samples are saved AFTER the final trace. Thus, those last new samples will also be saved. Since the entire scene is sampled with error_bound 0.1 on a final trace, this means we get lots of additional samples, which would otherwise be left out when using low_error_factor. Why? Because on the final trace, radiosity would gather with error_bound 0.8, leaving lots of the holes an error_bound of 0.1 would find remaining.

And another advantage is that on a two pass method, you can trace the first pass on a much slower resolution, which saves the huge amounts of rendering times (more on complex images, of course). Even a 40x30 first pass works pretty well with a final 1280x960 pass, and when using heavy refraction/reflection, you'll save LOTS of tracing time.

The conclusion to this is that the two-pass method CAN be achieved with low_error_factor, but with less precision. This comes at the cost of the extra pass, but other features may be changed on a second pass as well (like leaving always_sample on for the first pass, and only switch it off for the second pass), providing much more flexibility and handling.


Back to Top


Pure Radiosity

The main issue with radiosity is ambient-values. They define the ambient-lighting of an object, and in radiosity-terms sets the object to "glow in the dark". Thus, high ambient objects will be not only very bright, but also add to the lighting of a radiosity scene. This can be taken into extremes when rendering an image without any conventional lightsource whatsoever, and only rely on ambient-values. For the following examples, the glowing box at the top of the image uses an ambient-value of 25. As you might have guessed, smaller values lead to darker images, whereas larger values... You get the point. Also note that specular highlights are only possible with either actual, conventional lightsources, or when using exponential reflection on the objects on which you want highlights, but I don't plan on going into further detail with this. It increases rendering times significantly, and when looking at exponential reflection in the docs, you should come up with why that would get you some highlights...

First pass

There are several things to notice. First of all, the black dots all around the place. These are very common in my first passes and are due to the low max_trace_level as well as other factors (but manly trace-level). But don't go out raising the level to insane values, as you will see, this wasn't a problem, even with this data. Also note the bright spot just to the left of the sphere, on the floor. Radiosity does take reflected and refracted light into account, but it does a bad job of attaining accurate results. That's why I'll combine the lighting with photons... Also note the absence of specular highlighting on the torus.

Second pass

Notice the lack of black dots? Using an error-bound 8 times as large got rid of almost all blotchy artefacts, but still looks good. The main thing to notice is the absence of definitive shadows, which is a known and also wanted side-effect of radiosity: its meant to get rid of utter black shadows by spreading the light. Still, some sense of depth is retained, as shadow-like features are still visible. Due to the smoothening process I've raised the brightness to 1.25 for the rad-data. I've always raised the brightness on radiosity scenes unless I do use conventional lighting, but I'll come to that later.

Composition

Now I've added the loaded photons into the pure radiosity scene. The results are very lifelike, though the shadows are VERY smooth. Also note (though it may be more identifiable on the following larger pic) the darker area on the torus: radiosity doesn't take objects with no_image-tag into account, which was used on the wall we're looking through. Thus, no light from there. Still no specular highlight on the torus.

Final image, 640x480, Antialiased

Now, onward generating radiosity data with photons loaded from up front...

First pass

There's not much visible difference to the image without photons. The black dots appear at the same locations.

Second pass

This image (without the photons from the former image) shows that there's not much visible difference to the radiosity scene generated without photons. Photons only slowed down the calculation process, and their effect is too small to actually care about it in this scene.

Conclusion

Unless photons will dominate the lighting of a scene, you should definitely generate your rad-data without them. They slow down the sampling process without having enough effect for you to notice. The results will be even less visible when using textured objects, so in this case, you do no harm when saving that extra time.


Back to Top


Radiosity + Lightsources

Combining radiosity with conventional lightsources is another topic not easily done with. First of all, most scenes will get modelled and rendered with conventional lightsources anyways, so just finding a suitable method of adding that extra-realism which isn't easily obtained in CG imaging has to come in. Radiosity, taking care of diffuse light-reflection is suited for just that. But what are the differences?

Above all, radiosity relies on the ambient-values of the finish-statement to tell if an object is glowing by itself and thus emitting light. Even if no lightsource illuminates it, it'll be visible that way, and with radiosity, it'll lighten its neighbours as well.

Conventional Lighting

As you will notice later, conventional lighting affects shadows very significantly when compared to pure radiosity-lighting. Thus, it is advisable to set the lightsources to a realistic setting. In this case, I've used an arealight fit to the side-length of the glowing box. Additionally, as the main lighting is now given by a conventional source, the box's ambient is set down to 1. It'll still have some effect, but the main part should now go to the conventional source.

First pass

As always, we get black dots on the first pass. Since I'm using the same settings as before on pure radiosity, the black dots appear at the same positions. Notice the difference in lighting, especially around the glowing box. It now throws a shadow. Also note the specular highlighting on the torus, which is simulated via conventional lightsources, and thus not possible with pure radiosity lighting.

Second Pass

As before, brightness is raised to 1.25 along with error_bound up to .8 from .1. The main difference to pure radiosity lighting is already visible: more defined shadows and a shadow surrounding the glowing box.

Composition

Finally we add the photons and the results are more defined than those of the radiosity-only approach. The only annoying thing is the shadow surrounding the glowing box, but we'll come to that later.

Conclusion

Using lightsources in combination with radiosity gives more predictable results for shadows and bright regions, as well as obtaining more detailed shadows, altogether creating a better sense of depth for the image. Also, the nice little tweaks like specular and phong highlighting are easily integrated, and photons may even be generated during the radiosity-phase as well (although, as noted before, photons slow down the radiosity-sampling somewhat).


Back to Top


Radiosity + Lightsource + no_shadow on Lightobject

Using no_shadow on lightsource-objects is a pretty obvious step: since the object is emitting light, it shouldn't cast a shadow of its own. This is true when speaking about the little wire of a glass-bulb, but doesn't apply to the glass-bulb itself. One often models the bulb and renders it as a white object, which is, of course, not the most realistic approach. As noticed above, the glowing box casts a shadow of its own, although it should (being without framing and such) just cast light. Thus, I put a no_shadow on the box. For scenes with several lightsources, it might be advisable to only apply that to the actual light-source object (e.g. the wire in the bulb, not the bulb itself), as light from other sources would also affect the shadow of the bulb that they produce.

Conventional Lighting

Applying no_shadow eliminates the shadow of the box. Additionally, this effects the lighting of the walls and other objects which have formerly been shadowed at least slightly be the box, and thus the total amount of light spread through the upper part of the scene seems to be brighter, as less is blocked on the already white box.

First pass

Notice the difference in lighting in comparison to earlier images, especially around the glowing box. The area is now really bright.

Second Pass

As before, brightness is raised to 1.25 along with error_bound up to .8 from .1. With no_shadow, the lighting now gets very bright all of a sudden. The light is probably spread somewhat different with the box blocking the light to the ceiling. I'm also unsure if there are additional samples stored on the box which might add up in the image.

Composition

Loading the photons adds that extra notch to the image. Along with the conventional lighting, the image seems pretty photorealistic by now, even though it might be a little bright.

Composition - Take 2

Lowering the brightness value to 0.5 instead of raising it to 1.25 gives a lighting level similiar to the series before. Notice though that radiosity lighting depends on the depicted scene, so this is most probably a factor you'll always have to tweak a little for the second pass when changing features like no_shadow, photons, count, etc.

Composition - Photons present during first pass

As always, I had made a little series of four or five tests to check for differences in lighting when having photons present in the first pass. Again, the difference is too subtle to be visible (especially on compressed JPG-images) and not worth the effort. As noted before, this shouldn't be taken lightly when the scene is lit in major parts by photons, of course.


Back to Top


Final notes on max_trace_level and recursion_limit

Raytracers always come with an option which limits the recursion-depth of rays. A ray goes into the next depth-level when it is reflected or refracted, or passes through a transparent object (which is just a different form of refraction). POV-Ray ships with a default max_trace_level of 5, which is quiet low when the scene gets filled with glass objects, shiny objects that reflect, and combinations of both. The point is, though, that it also limits the sampling of radiosity. For radiosity, rays are sent outwards which "probe" the surrounding area. When these rays have to travel through glass objects, the recursion depth rises. At some points, this may get so complicated, that very high amounts of depth would only return an actual value, rather than just stating "the rays needs to travel farther".

Also note that recursion_limit is a completely different option. It sets the amount of recursion the diffuse light will take when gathering samples. For most scenes, a limit of 1 to 3 is sufficient. I've found that there is a siginificant different from 1 to 2, but after that, the effect diminishes to almost an unnoticeable level. Of course, image-manipulating programs can still reveal the difference, but our eyes don't do that. Below I've put an example with recursion_limit set to 4 instead of 2. If you don't notice any difference, then that's completely right!

Max_Trace_Level 5

A first pass of the scene with maximum depth set to 5. Notice the amount of black dots near the lower edge of the room, and beside the glass-sphere.

Max_Trace_Level set to 64

We can clearly see that many black dots have disappeared, though some new ones have been introduced elsewhere, which is a common side-effect when changing options: you might get samples where you formerly got none, thus some other samples might not be taken as we've already got some, and on it goes... Point is: much less black dots total.

Composition

In this image, the final composition doesn't differ much from the trace-level 5 version, while taking longer. Much like using photons during radiosity-gathering, the recursion-level should be raised when scene make heavy usage of transparent and reflective surfaces. The lighting may change significantly, e.g. when a bright object is being blocked through some transparent surfaces, because of the trace limit. You'll have to try and experiment if higher trace-levels increase realism, or aren't worthwhile, until you have enough experience to judge it from the objects and scene-composition itself.

Recursion_Limit 2 - Pure Radiosity Scene

No additional comment

Recursion_Limit 4 - Pure Radiosity Scene

Even with a higher limit, the change in lighting is pretty unsignificant in this scene. It did get a little brighter, but than can be achieved with brightness as well. But, as always (I've written this a thousand times by now, I guess), the limit is scene-dependant, and if something doesn't seem properly lit, experiment if a slighty higher limit (begin with 1 or 2) will change anything. If it doesn't, using even higher values won't change much more.


Back to Top