World of reflections 2

World of reflections 2

BRDF stands for bidirectional reflection distribution function. It’s a function, a mathematical model, to describe the reflection behaviour of materials. This little tutorial is written for artists, not for physicians or programers. There are plenty of papers out there who deal with the technical side of BRDF’s, but my goal is to describe there behaviour without going into detail too much, just to understand how to use them correctly.
You are dealing with BRDF’s the whole time in CG. If you’re using a Phong, Blinn or any other ‘shader’, you’re dealing with BRDF models. If you’re using raytracing to produce correct reflections, shadows or gathering light for global illumination models, you’re dealing with the main principles of BRDF models as well.
A BRDF describes the relation between incoming irradiance to the reflecting radiance on a surface. So in more simple words, light is hitting a surface and the surface does something with this light. It can be reflected (clean or diffuse) or absorbed, or a mixture of those. It is possible to describe real-life materials and their BRDF by measuring the incoming and the reflecting light and the resulting data can be used in CG programs to produce materials with the same properties. But most of the time some simplified mathematical models with tweakable parameters are used to produce CG surfaces. Those models can be either empirical reflectance models or analytic reflectance models. We will deal with analytical reflectance models, because here the formulars are built with real world parameters and they are used in CGI, because you can combine them to build more complex shaders. The emipirical models, like the one of Robertson-Sandford or the Beard-Maxwell model, use measured parameters along with fictional parameters to build simplified BRDF’s for special measured materials.
Later on in this text we will also deal with advanced reflection models like BTDF, BSDF or BDF and BSSRDF. Just to clarify these terms:
A BRDF just describes the reflection of light, depending on the surface characteristics, the angels of incoming light (and it’s parameters) and the viewing angles.
BTDF stands for bidirectional transfer distribution function and describes the same for transparent surfaces, so the vectors are computed for both sides of the surface (not the same computation).
A combination of BRDF and BTDF would be a BSDF (or simply a BDF), which stands for bidirectional scattering distribution function and describes a function for the both hemispheres of a point on the surface. These are fundamental functions for advanced (glossy) raytraced renderings.
BSSRDF stands for bidirectional surface scattering reflectance distribution function and it’s inventor Henrik Jensen (the father of photon mapping) describes the scattering of light beneath a surface with it. But enough for the overview, let’s start with the simple ones….

It’s a quite simple model (it’s known for more than 200 years!), and it’s also the most popular one and used in nearly every CG scene, most of the time without the knowledge of the user. It’s a model to describe a perfectly diffuse surface and works by scattering the incoming light on the surface in every direction with the same amount. That means if you view the surface from different directions, you will always see the same color on the same spot (isotrop). The only variation is the angle of the incoming light, so the spot is brighter when lightened by a ray hitting with 90 degrees, and darker at smaller angles. This model can be seen in real-life, but a perfect diffuse surface is rather rare and so this model is one of the reasons for the typically computer generated look. But because of it’s speed it’s so popular and so it’s also used for the diffuse part of some of the even more popular following models. This is also the most used model to shade surfaces in real-time graphics, because it’s so fast. It’s known as Gourad Shading in realtime graphics, because it’s not computated per pixel, it’s computated per vertex and the values are interpolated over the polygons (newer generations of graphic cards allow the computation of pixel shaders in realtime and more sophisticated models become standard today, but that’s a topic of it’s own..).
Most of the time this model is implemented physically correct, that means that some important rules are kept. One of them is the rule, that the sum of the outgoing light has to have the same or less energy like the incoming light. Another is the correct absorbing with different diffuse colors (one of the main parameters of this model – diffuse color is a product of the lambert model) – that means e.g. a black diffuse color absorbs the whole light and does not produce a reflection on this model.
pic. I

All four spheres in pic. I have got a lambert shader applied. The first and the second one are the same spheres viewed from different directions. I’ve marked the same spot on the sphere with a red circle to show, that the lambert model produces the same amount of light in every direction (the color is the same). The third sphere is the same with another diffuse color, it’s darker and less light is reflected. The third one shows a common parameter of BRDF models – the ambient part. It’s just a value added to the whole model to simulate ambient lighting – not very useful most of the time, because it tends to flatten your image. Try to simulate ambient lighting with more lights or global illumination stuff.

pic. II

pic. II shows the physical nature of glossy reflections, also known as highlights. The first one shows a perfect diffusor (Lambert), the incoming lightray (red) is reflected in every direction by the same amount (length of the blue rays). The second one is a perfect spectral reflector, raytracers use this simple law to produce perfect reflecting materials, like mirrors. The third one can be seen as a semi-perfect mirror, due to small irregularities of the surface (bumps, scratches) the incoming light ray gets scattered a little bit around it’s perfect reflecting ray.
Now, there are a lot of different models which describe the diffuse part of a surface, we had a look at the simplest one above, Lambert. And there are even more models which describe different types of glossy reflections of surfaces (because of different types of surface irregularities) the most simple ones are the following:

The PHONG MODEL was invented by Phong Bui Tong in 1975, and because of it’s simplicity and speed it’s one of the most popular models to describe glossy reflections of CG surfaces. It’s not a physical accurate model, you can set parameters (the strength of the highlight) of it’s formular so that it reflects more light than it receives, which is impossible in real life. But because CGI is the art of creating illusions this fact can be very helpful.
pic. III

The first sphere in pic. III shows a highlight produced by the Phong model. Great part of this model is, that you can combine it with other models to achieve many different results. The most common combination is a Phong model with a Lambert diffusion, like on the second sphere. Note that I have used the same settings for the light (position, strength) in all those pictures and also the Phong highlights of those two spheres in the picture above have the same settings. The result of the Lambert diffusion is just added to the highlight, so the highlight becomes brighter, too. A great fact about this combinating of different models is that you can adjust different settings (colors, strength, glossiness, etc..) for the different models, which greatly enhances artistic freedom. The next two images show the fact, that Phong highlights are angle independent and view independent, too. It’s a three-dimensional representation of reflection-values, like the two-dimensional drawings of the reflection types above. The blue ray is the incoming light-ray, it hits the red surface at a certain point and the white cage shows the values of the reflecting light rays. A Lambert diffusion would result in a perfect sphere around the intersection point, in this picture we see a Lambert diffusion with a Phong highlight added to it. When the light ray comes from above, the Phong highlight produces strong reflection values back to the direction where the light came from, plus some glossy reflection values around it, plus the Lambert part, filling the rest of the hemisphere. When the light-ray comes from a different angle the values stay the same, just the reflection angle changes according to the law: incoming light angle = outgoing light angle.

The BLINN-PHONG MODEL, often just called Blinn model, is a very common variation of the Phong model. James F. Blinn is one of the pioneers in CG and formulated this variant of Phong because of some annoying problems of the Phong highlights. It’s also very fast and in most programs it’s the standard highlight model, combinated with a Lambert model for the diffusion part. And it’s implemented in most graphic chips, producing fast and nice highlights in realtime. But let’s have a look at it:
pic. IV

I’ve chosen the same sphere and the same settings for all the parameters (Blinn highlight has got the same basic settings as Phong highlight). There are nearly no differencies between the Phong spheres in pic. III and the Blinn spheres in pic. IV, except that the Blinn ones look a little bit softer. But when we have a look at the reflection values at different angles (image 3 and 4), we see a clear difference. At an incoming angle of 90 degrees the reflecting values are like a very soft Phong highlight, but at very small incoming angles the glossy reflection gets clearly distorted. This is because a small variation in the BRDF formular – but what’s this for?
pic. V

pic. V shows the visual difference between Phong and Blinn. The main difference is visible at small incoming light angles, so I rendered the sphere with two lights, one from above (like before) and one shining from below, nearly at an angle of 90 degree to the camera. The first sphere is rendered with a Phong model, the second one is the same with a Blinn. While the Phong highlight gets distorted, because of the face angles of the sphere, the Blinn highlight seems to keep his round shape. Well, it’s a matter of taste which of those highlights fill your needs, I personally think, that Phong highlights look more correct – but Blinn highlights are often better controllable because the highlights can be better predicted (especially on complicated surfaces) and so it has become the number one of the basic and speedy BRDF models of CG artists. The third and fourth sphere in pic. V are rendered with a raytraced glossy reflection, reflecting a complex environment, again the first with a Phong and the second with a Blinn BRDF (note, that most raytracers do not take BRDF models into account, when rendering glossy reflection – they use their own defocusing algorithms, independend from the BRDF reflection of the highlights). You can see the same effect of distortion on the Phong reflection and a clear softening effect on the Blinn one – the settings where absolutely the same, the only difference are the different results of the reflection function.

Now we have seen the most basic reflection models for a uniform diffuse and glossy reflection. But Phong and Blinn only allow glossy reflections in directions calculated by the incoming-angle=reflecting-angle law. In nature different types of roughnesses appear on surfaces and so the light can be scattered in many different ways – a special case is the so called back scattering or back reflection of the light.
pic. VI

You see, back scattering is just a reflection of the light back to the light source. A lot of different models have been developed for this effect, most of the time combinated with other models to achieve more complex results. But the most basic one is the Minnaert model. It has got the same simple formular like the Lambert model plus a darkening parameter to darken the values in the normal reflecting direction. The first sphere in pic. VI shows the Minnaert model. It was initially developed to describe the BRDF for the moon, which has basically a lambertian reflection (which is pretty rare in nature) but also a small amount of back reflection. The Minnaert model does not allow for great back scattering values or rim lighting effects but because it’s basically lambertian plus a small term – it’s veeeery fast. The Hapke/Lommel-Seelinger model is a little bit more complex, but it has got parameters to change the back and forward scattering amounts and you can produce wider variants of light scattering with it. A very common use of those models are materials like velvet or other surfaces with small, fuzzy fur on it, which can produce back scattered rim lights on top of this fur. The third sphere shows a variant of the Hapke/Lommel-Seelinger model, which is great to simulate fuzzy, soft-looking fabric. I’ve chosen a blue color for the back scattered highlights because a white color would have been hard to see against the white background. Note also, that those models have been extended with other parameters and it’s hard to find renderers who implement those models in their pure form.

The idea of building a mathematical model for rough surfaces was a very early one. Torrance and Sparrow designed a physical based BRDF in 1967 (before Phong) with the idea to use a rough surface as a base. The surface was build out of microfacets, the angle of those facets was used to describe the roughness. The microfacets build so called v-cavities, because the angle of one microfacet was the exact opposite angle of the neighbor facet. This model was physical correct, it used real world parameters to describe the reflection distribution and it was wave-lenght dependend, what means, that a specific point on the surface could have different colors from different views. It’s a very basic model and used for many following models.
pic. VII

The next important step was done by Cook and Torrance in 1982 (sometime it’s called the Cook-Torrance model, sometimes even the Blinn-Cook-Torrance model, because it’s taking the Blinn model into account). It’s kind of a mixture of the Blinn and the Torrance-Sparrow model, also physical accurate and exended with some terms, making it a pretty expensive model when talking about renderspeed. One step was to include more distribution functions for the distribution of the microfacets. Torrance-Sparrow worked with the well known Gauss distribution, Cook-Torrance included functions for the Phong distribution, the Trowbridge-Reitz-distribution and the Beckmann-distribution. But that’s just a small part, bigger steps where included by computing additional information which part of the light, shining on the microfacets, gets reflected with two additional parameters. One was the well known Fresnel reflection (in short words: reflection amount is angle and IOR dependend – see part I of this tutorial). The second was the geometrical attenuation factor with self shadowing and masking by the microfacets, as shown in pic. VII.
pic. VIII

The Cook-Torrance model builds mainly highlights and it’s a very common BRDF for simulating metal. Sometimes it’s combinated with a lambertian diffusion. But because of it’s physical correctness it often lacks of artistic freedom and it’s not the fastest one, too. Sphere no.1 in pic. VIII shows a Cook-Torrance highlight, which can be quite similar to a Blinn highlight at smaller roughness values (in fact they have very much in common).
A very common variant of the microfacet-models, in fact the most used of them because of it’s speed and because it’s a good alternative to the good old lambertian diffusion, is the Oren-Nayar model. It’s kind of a cheaper Cook-Torrance model which mainly builds diffuse surfaces and it’s often combinated with a Blinn highlight (Oren-Nayar-Blinn model). I’ve seen a lot of different implementations of Oren-Nayar models, so it’s hard for me to tell you some facts. Most of them do not use masking and self-shadowing and most of them also do not take different wave-lenght computations into account. Most of the time this model looks like a lambertian diffusor combinated with some darkening in the viewing direction and some backscattering. Sphere no.2 and 3 in pic. VIII are rendered with a very common Oren-Nayar model, and I have marked the same spot on those spheres (it’s the same sphere from different viewing directions) with a red circle to show that the reflection values are different at different angles. I like this model very much as a more realistic alternative to Lambert.

pic. IX

Sphere no.1 in pic. IX shows another Oren Nayar implementation. This one looks more like a combination of a Lambert and a backscattering component without darkening parts (see the darker ring between the bright lambert part and the bright backscattering part?). Don’t ask me what algorithm is behind it, it’s just one of those hundreds of variations of the classic models I described so far….. Sphere no.2 shows a Oren Nayar diffusion on a more complicated surface with a sharp Blinn highlight on top of it. Sphere no.3 uses exact the same settings, this time with a Lambert for the diffuse part and a Phong highlight.

In the 90’s of the 20th century a model-explosion happened and a lot of different models have been developed until now. The most popular ones from this time is the He-Torrance-Sillion-Greenberg model (1991 – very complicated, introduced sub-surface scattering effects, a new diffusion part called directional diffusion, physically and microfacets based), the Schlick model (1994 – new formulars for microfacet effects like masking, diffuse and specular part is computed together, anisotropy possible), the Ward model (1992 – very fast anisotropy model with gaussian distribution and physically correctness), the Lewis model (1993 – also known as the classic cosine-lobe-model, it’s a extension of the Phong distribution with physicall correctness) and the Lafortune model (1997 – known as general cosine-lobe-model because it’s a generalisation of the Lewis model). You can see implementations of this newer models in some 3d-programs, but often not with their real name, because the programers often just implement different ideas or parts of those models to form their own ones to fill their specific needs. This is also a reason for the big amount of different models available. For example, if you install 3ds max, with some third party renderers and their shader packages and some other plugins which come with BRDF models (like HairFX, the MooDee shaders or FacialStudio) you can end with an overwhelming amount of 20-30 different models you can choose of.
Some word about anisotropy: so far we have only seen isotropic model, that means, that the reflecting values do not change if you rotate the model. Also the basic microfacet models are isotrop because the microfacets have the same size and are evenly distributed on the surface. A reflection change by rotating the camera does not mean that this model is anisotrop, it just means, that the surface reflects light with different amounts in different directions. As I mentioned in the first part of this tutorial, anisotropy is the effect you get when the bumps and scratches on the surface tend to flow uniformly in a specific directions. But enough words, more pictures…..
pic. X

Sphere 1 in pic. X shows us the highlight of a Ward model. It’s pretty much like Blinn, but I think it looks better, because the Gaussian distribution makes the highlight more defined, not so soft like the Blinn one. You can barely see this at the highlight alone, but when you raytrace a physically correct glossy reflection you will see what I mean. Sphere 2 is that kind of raytraced reflection with a Ward model, sphere 3 the same with a Blinn model. I’ve chosen to use the anisotropy parameter for the Ward on sphere 2 and animated it, to show you the effect. And, what’s interesting, I was able to use anisotropy for the Blinn model as well, that’s what I meant with model chaos. But it’s nice to have those melting of different models, that way you can produce lot’s of different effect with just one model. But as you can see, the anisotropie on the Blinn model has got some problems, the Blinn reflection is as soft as usual, but the reflection of the bottom-left light (the thin anisotropy highlight) is very sharp and too glossy, it does not fit to the rest of the reflection in my opinion. The 3rd sphere has got an interesting anisotropy model on it, it’s the distant fur shader of finalShaders, a shader compilation for the plugin renderer finalRender stage-1 for 3ds max. It’s a good example for advanced BRDF’s, it uses a lot of different basic BRDF models and some additional terms, along with the good old layering system to give the user a lot of control over the desired effect. Would be nice to have a look at the formular for this one :)
pic. XI

Sphere 1 in pic. XI uses a soft aniso plus lambertian diffusion for a fuzzy, rough surface. The aniso makes it look furry when animated. Sphere 2 uses a very sharp, intense aniso highlight to produce a oily, water coating. Sphere 3 uses a very powerful model type which uses custom curves to control the distribution of the reflection. It’s a shame that this type of models are not implemented more tightly in the shader system of most renderers. Well known types of this model are the falloff maps or the Zauner model by CA Scanline. My wish would be a better integration of custom curves into the raytracer systems for the glossy reflection falloff and the anisotropy distribution as well… Sphere 4 uses the Zauner model to produce a custom faked sub surface scattering effect.

Looks like we have left the simple stuff behind us and we have reached the next level, we have reached sub surface scattering or SSS – so let’s proceed to the next topic.

Well, first of all, Kubelka-Munk and Hanrahan-Krueger models have nothing to do with the term -advanced rendering-. They are BRDF models like the ones above, happy with a surface, a light and a camera. But those two fit to the term sub surface scattering, in fact they are the most popular BRDF adressing this type of effect, besides the He model. But they are just dealing with the diffusion part of surfaces which scatter the light beneath their surface before absorbing or reflecting. That means they can not really calculate rays under the surface and they can not produce physically correct colors on directly unlit parts of the surface. This techniques required new rendering techniques like advanced raytracing algorithms (monte carlo) and photon mapping.
The Kubelka-Munk model is a very basic model which describes the BRDF of a surface covered with a layer of pigments. It just takes one layer of color into account – Hanrahan Krueger went one step further and they created a very good function with a lot of parameter to simulate the scattering of light under different surface layers. That means you can specify the number of layers, their diffusion and their scattering behaviour, their absorbtion colors and their thickness.
pic. XII

The first sphere in pic. XII shows an animation of a Hanrahan-Krueger model. The basic red diffusion is the basic layer and I’ve animated the diffusion value of a second skincolored layer which covers this basic layer. The second sphere shows a Hanrahan-Krueger on a more complicated surface with a backscattered highlight on it (blue) to simulate the presence of a thin fuzzy layer of hair. It’s a great model to simulate skin effects, especially when enhanced with texture maps – but it’s a BRDF (note the R for Reflecting) and so it has it’s limits.
Sphere 3 shows us the rendering of a physically correct SSS by using a monte carlo method. This is a very slow method, you can think of it as a anhanced raytracing method, where a big amount of rays are shot out from a certain point on the surface to gather more information for the needed color on that spot than a single ray can collect. It’s also something like a random lambertian raytracing method, because the rays are shot randomly in different directions over the hemisphere of the surface. I do not know many raytracers who take BRDF models for the Monte Carlo rays into account…… what would be great, to achieve more variations. The typically LAMBERTIAN computer generated look is dead, the typically GI look has arrived :)
Much too slow to use this technique for animations, yet … so Henrik Jensen, the father of the photon map (nearly every renderer has included this feature now) combined the two techniques, he used a generalized Hanrahan-Kruger for the single scattering (direct scattering and diffusion) part and a optimized diffusion approximation for the multiscattered diffusion part (plus some fresnel parts) and he called his fast SSS baby BSSRDF. And it was successfull, have a look at Gollum or Harry Potter or other big-budget-computer-animated-actors to see what I mean.
The last sphere shows a combination of a Hanrahan-Kruger with a low-quality monte carlo SSS to enhance the speed. Hope you like it and I hope I have shed some light on the one or other aspect of BRDF’s you didn’t know. Now, go and create the future.