## Understanding LuxRender materials – part 1

When setting up materials in LuxRender one needs to be conscious about it’s physically based nature. Thus it helps to know how how the various materials are modeled and how the parameters related to the real world. In this series of articles I’ll try to give some insight into this. First up are the basic materials: matte, glossy, glass and metal.First I’ll give a rough explanation for some of the terms which will be used when explaining the materials.

#### Diffuse reflection

Diffuse reflection is used to describe reflections where the direction of the reflected light is completely independent of the direction of the incoming light. Plaster or plain white paper usually behaves very much like a diffuse reflector. A rough explanation is that as the light enters the material it bounces around so much that when it leaves the material the direction it leaves is totally independent of the direction the light entered the material.

#### Specular reflection

Specular reflection is in many ways the exact opposite of diffuse reflection. A mirror is the prime example of specular reflection. Light that hits the material is reflected back at the same angle with respect to the surface normal. Note that with specular reflection the light does not penetrate the surface, unlike diffuse reflection.

#### Microfacets

Most materials reflect light in a much more complicated way than what you get by mixing ideal diffuse and specular reflections. A very common way to try to reproduce the more complicated behaviors observed is to use a so-called microfacet model.

The idea is fairly simple: instead of assuming the surface is perfectly flat, you assume it consists of lots of small facets. One often assumes that the material to look the same under rotation around the surface normal (isotropic). This allows one to consider the 2D case which makes life easier. The surface then looks like it has lots of tiny V-like grooves, where the edge of a groove is called a facet.

Microfacets of a rough material

The key point is that the facets are assumed to be so small that they are not directly visible. The situation is similar to how the surface of an orange appears smooth when viewed from afar. Assuming each facet is either an ideal diffuse or ideal specular reflector one can calculate how the surface appears from afar. Depending on the accuracy of these calculations one can take into account effects such as inter-reflection between the facets and shadowing, which can play an important role for rough surfaces.

The roughness of the surface is usually specified as the probability distribution of the specific angle of any given V-groove. Frequently a Gaussian distribution is assumed, such that most angles fall around the specified with some grooves having a much steeper/shallower angle than the average. However it is also common to use a more intuative “zero to one” scale, where for example zero means perfectly smooth and one means as rough as it gets.

While these microfacet-based models are fairly general and can be used to model a wide range of different materials, they have some limitations. For example one typically assumes that the facets always form grooves. To be more specific, the normal of each facet will never point into the material.

## Matte

The “matte” material models diffuse reflection only. The diffuse color parameter indicates the color of the light that gets reflected. Any light that is not reflected is taken to be absorbed. It uses one of two models depending on whether the surface is rough or not.

For perfectly smooth surfaces the Lambertian reflectance model is used. This model assumes that the light is reflected equally in all directions, and that the object is thick enough that no light is transmitted through the object. It also assumes that the light exits the material very close to the point of entry, such that the error of pretending the light exits exactly at the point of entry is small.

The Lambertian model does not consider the roughness of the surface. This makes it inaccurate for many materials such as clay, concrete, sand and cloth, where a plain Lambertian material would appear too dark at grazing angles. The Oren-Nayar reflectance model was developed to correct this. It is a microfacet-based model, where each facet is assumed to be a Lambertian reflector. The model takes into account the interplay between neighboring facets, such as shadowing and interreflection. This model is used for rough surfaces.

The sigma parameter ($$\sigma$$) determines how rough the surface appears, with zero being perfectly smooth. Technically it’s the standard deviation of the angle of the grooves. The maximum value is 90 degrees, however very rough materials will have a sigma of no more than 30 degrees in the real world. The rougher the surface the more light is reflected back at grazing angles, giving it a flatter look.

## Glass

The glass material models a smooth dielectric such as glass or clear plastic. Mostly you can think of any insulator (non-conducting material) as a dielectric. Notably dielectrics transmit all the light when the light hits the material “head on” (normal incidence) and reflects all the light at grazing angles. The index of refraction (IOR) dictates how the material reflects and refracts light between these extremes. The index of refraction also determines how much the light will bend when entering the material. Mathematically the amount of light reflected and transmitted by a dielectric is described by the Fresnel equations, and how the light bends is described by Snell’s law. Both are  used internally by LuxRender.

LuxRender has two glass materials, named “glass” and “glass2”. The latter is the more correct one from a physical point of view, and it’s controlled via the IOR and the absorption of the material. The “glass” material has, in addition to the IOR parameter, a specular color and a transmission color. These two parameters simply modulate (filter) the color that is reflected or transmitted.

Given that the reflection off a dielectric is a surface effect the reflected light isn’t actually affected (colored) by the dielectric at all. Also the transmission color does not take the transmission depth into account and as such does not realistically model absorption. Thus if you can you should try to use the “glass2” material.

In some materials the index of refraction varies significantly with the wavelength (color) of the light. This causes dispersion, also known as nice rainbows of color. Since dispersion makes a scene converge a lot slower you have to enable dispersion explicitly for each glass material. In addition you need to tell LuxRender how the the index of refraction varies with wavelength. There are several different ways to do this. The easiest option is to use one of the presets if your exporter has one. Otherwise you can enter the Cauchy or Sellmeier coefficients, which can often be found in glass catalogs. Another alternative is to use data files with the tabulateddata texture. However those are more advanced features I won’t go into here.

Usually dielectrics behave very similar, so if you can’t find data for a specific dielectric you should be able to get away with choosing one of the presets which have a similar index of refraction.

## Glossy

The glossy material is a layered model. It assumes a diffuse base layer which is coated with a dielectric layer. This model fits well materials like varnished wood and colored plastics. Any light which is not reflected by the coating is transmitted to the base layer where the light is diffusely reflected or absorbed.

The diffuse base is treated like in the matte material, except the roughness does not apply to it. Thus it does not take any subsurface scattering effects into account either. The coating is treated as a dielectric obeying the Fresnel equations. You can define it via a specular color, which filters the reflected light, or the index of refraction. As mentioned above it’s more correct, and thus preferable, to use the index of refraction. The roughness parameter controls the surface roughness of the coating from almost mirror-like (zero) to perfectly diffuse (one). It is also based on a microfacet model, however the roughness parameter does not directly relate to the angles between microfacets.

The glossy material also has an absorption parameter, which determines the absorption of the coating layer before the light hits the diffuse base. The associated depth parameter indicates the depth, or height, of the coating layer above the diffuse base, and is measured in nanometers. The effect of the absorption can be subtle, but is most noticeable when the material is viewed at near grazing angles. Keep in mind that you specify an absorption color. So if you set it to bright red, your object will get a cyan tint as the red color is absorbed by the coating before it’s reflected.

## Metal

The metal material models metals, or more specifically conducting materials. Like dielectrics their reflective behavior is given by their index of refraction. Unlike dielectrics however no light is transmitted through the material. Almost all of the light is reflected and the rest is absorbed within a few nanometers of the surface. The only parameters used for the metal material is the index of refraction and the roughness. The surface roughness is treated the same way as with the glossy material.

Since metals reflect almost all the light, it’s important to have a good environment around them. Otherwise they’ll just appear black and lifeless. In the real world metals look like metals exactly because of the way they reflect the environment.

The color of a metal is due entirely to how the index of refraction changes with wavelength. The index of refraction can come from either a list of presets or from so-called nk files which can be found for instance on the luxpop site (which despite the name is not associated with LuxRender in any way). The nk files contain the index of refraction at different wavelengths, and it is assumed that the IOR changes smoothly between the given values.

Please keep in mind that the index of refraction of metals is very different from dielectrics. Technically the metals have a complex refractive index with non-zero imaginary part, called the extinction coefficient. In contrast the IOR of dielectrics only has a real component.

The extinction coefficient is so named because it determines how far into the material light will penetrate before being absorbed. In the case of metals however, the typical penetration depth is on the order of nanometers and thus LuxRender does not consider the metal material to be transparent so any light which isn’t reflected is assumed to be absorbed.

Posted on: October 11, 2010
Categories: Rendering
###### One Response to Understanding LuxRender materials – part 1
1. Thank you for that post. It really helps me a lot
Ralf

This site uses Akismet to reduce spam. Learn how your comment data is processed.