Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/vecpix/public_html/tutorials/3dstudio/sm002.php on line 5

Warning: include(http://www.vecpix.com/include_leftnav.php) [function.include]: failed to open stream: no suitable wrapper could be found in /home/vecpix/public_html/tutorials/3dstudio/sm002.php on line 5

Warning: include() [function.include]: Failed opening 'http://www.vecpix.com/include_leftnav.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/vecpix/public_html/tutorials/3dstudio/sm002.php on line 5

Metals And Reflections

The standard Max scanline renderer gives us a host of methods for simulating reflections. The most accurate methods are usually the most expensive time wise. Using raytracing can produce the most accurate results, but it's a slower process compared to reflection maps. Reflection maps can produce some good results, but only if the user has spent his/her time really observing how real reflections react.

The problem I find with cheats and cg methods in general is if we are trying to make something photoreal, it's better to rely on our own power of observation then get caught up in the tools at hand. If it looks right, it's right, don't rely on people who hype that their software is 100% physically correct, or software that just implies their accuracy. As an example, 5 years ago when max first came out, I believed that placing any sort of map in the reflection slot (usually refmap.jpg) and changing the shader type to metal meant I now had a realistic metal. I didn't bother observing that a reflection should in fact reflect the environment the object is in, and that different parts of the metal surface reflect different amounts of the environment, and how the less polished the surface is, the fuzzier the reflections become. I put too much faith in the tool and didn't do enough of my own research to see that what I was doing could be improved dramatically. Software is getting better all the time, but don't count on it to do all the thinking for you.

While concentrating mainly on reflections and metals, this tutorial will also touch one topics ranging from non-metal surfaces to lighting. Some notes:

  • I will be using the Raytrace material for all material examples in this tutorial.
  • What holds true for the raytrace material also holds for the new Brazil renderer and material in its current configuration.
  • All scene files provided are in max4 format.
Ambient Light, and Why To Turn It Off

A standard max material has 3 components, Ambient, Diffuse and Specular. These names are short for Ambient Reflection, Diffuse Reflection and Specular Reflection.

What is ambient? One can think of it as a global color and brightness of parts of your object that are in shadow. But by changing this color (or changing the amount of ambient light in your scene), you are globally removing the ability of your material to go completely black when no light is shining on it. This feature was added to try and simulate the more complex phenomenon of light bouncing off of diffuse surfaces, illuminating other surfaces (Global Illumination), but fails since it adds light to the entire shadow surface, not just parts that are actually receiving light from secondary bounces. It's generally advisable to make your ambient color black, and have no ambient light in your scene.

So in fact, materials should only have two components, diffuse and specular.

The Truth About Specular Highlights

In Max, you control the highlight on your material using the specular controls, such as shininess strength and glossiness. You can then also add a reflection of your environment to your material through a variety of methods (such as a raytrace map, flat mirror map, etc). But in the real world, there is no difference between what we generally refer to as a "reflection" and the object's specular characteristics. What we call a specular highlight is just a reflection of a light source on your surface. And this is done quickly by the scanline renderer because the lights in max are what is known as a point source: Light is sent from an infinitely small point to the objects it illuminates. Real lights don't work this way, light is emitted from an area, such as your light bulb, and as such, specular highlights come in all sorts of shapes and sizes, most of which are not round (the specular highlight produced by a point light source is generally round).


A real world highlight, not quite round (more oval), but not too far off from the standard blinn highlight.


We get closer, and we see the highlight isn't an oval shape, but a reflection...


...of our light source overhead.

So, now, how do we simulate a true light source in 3d without resorting to Global Illumination methods?

Well, ideally you'd want a mesh object shaped like your true light source, and then have this surface emit light rays from all over its faces. This can't be done in max yet, so in the meantime, here's the cheat. First, make a material that's 100% self illuminated, white diffuse, and place an output map in the diffuse slot with a higher then 1 RGB level. Now assign this material to the object in your scene you wish to be a light source. Now, make a max light that comes from the same direction as this object, uncheck the specular component of the light. Now make a raytrace material that will reflect the scene, apply it to a sphere. The material should have 0 shininess strength and 0 glossiness, and make the reflection color 128,128,128, which makes the ball 50% reflective (ie, the color of your ball is 50% reflection and 50% diffuse color). What you've done is your specular highlight is now a reflection of your light source, and your max light is illuminating the diffuse component of your sphere. You've split up the problem, treating the diffuse and specular part of your light as two separate things. And changing the RGB Level amount will make the reflection of the material brighter. If you wish, consider this number as some abstraction of the amount of light energy coming from your light material.

If you don't have the time to raytrace your scene, you can also try this, make an environment map, something maybe as simple as a few white squares on a black background, go to your ball material, turn off the raytrace reflections and refractions, and put this bitmap in the material's environment slot. Now it will look like your sphere is being illuminated by some large square light sources (usually referred to as light cards, or bounce cards, many photographers use these because they produce nice looking specular highlights). One thing I love about the raytrace material is how it splits the reflection into two categories, reflect which controls how much it reflects, and environment, which controls what it's reflecting. If you have raytracing on and an environment map, you can reflect both your map and other objects in the scene, or else you can have it only reflect the environment map. Anyways, using this method, you can still have nice properly reflected light sources, but without the need to raytrace. The only drawbacks is it's harder to line up your diffuse lighting with your reflected light sources, since these sources are now positions on a bitmap instead of existing in a part of your 3d environment. And, of course, objects will not reflect each other.

Fresnel and IOR

Ok, now back to our main focus, reflections and metal. As mentioned before, objects reflect two kinds of light, diffuse and specular. Now that we've done away with the specular cheat common to most renderers, and replaced the cheat with a true reflection of your scene and light sources, we can move on to how these reflections appear on different materials. This brings us to the concept of Fresnel and IOR. Materials are assigned an IOR based on how they reflect light (IOR stands for Index Of Refraction, but even non transparent objects such as metals have an IOR, usually referred to as a "complex IOR". A complex IOR measures a slightly different property then a regular IOR, but it deals with the same stuff, light reflecting or refracting off / through a surface). As a surface starts facing away from the viewer, it reflects more then a surface that is directly facing a viewer.

Here's a reflective glass surface. Notice how it's less reflective when I look directly at it vs looking at it from an angle. The greater the angle the more it reflects.

On round surface like a sphere (as opposed to a flat surface like the glass), this means the edges of the sphere will reflect more specular light then the front of the sphere. This phenomenon is called Fresnel.

It is simulated in max using the falloff map in the Reflection slot of the Raytrace material. Place a falloff map in your reflection slot, and set it to fresnel. Uncheck override IOR, and return to the top level of your material, there's an IOR setting there. Different materials have different IORs, some good example are air is 1.0, glass has an IOR of about 1.5, Gloss materials such as porcelain or car paint 3-5, super shiny metals like chrome a value of 10-20. The IOR controls the proportion between how much the faces pointing away from your reflect vs the faces pointing towards you. For example, a lower IOR means that the away faces will reflect a lot, and the faces facing your reflect very little, and a higher IOR will make just abut all faces of your object reflect the scene the same amount.


An IOR of 1.5 on the left, and IOR 5.0 on the right, reflecting the checkerboard environment.

Additive vs Default Reflections

Some of you who have stared at the raytrace material a lot may have noticed the two reflection modes in extended parameters. These two modes are Additive and Default. The standard material uses additive and cannot be changed, the raytrace material gives you the option, and defaults to default. What's the difference? Look at this image.

The material to the left is using additive mode, the material on the right default. These spheres are very, very reflective, ie, they should be close to a perfect mirror of their environment. Knowing this, you'd expect the reflection in the mirror of a black object (the background) to be black, like it is on the default sphere, whereas the additive sphere takes the color black and adds to to the diffuse color of the sphere which is blue, producing an incorrect result. This is because in the real world, a surface that is very reflective (high specular reflection) has very little diffuse illumination. So mixing a high specular reflection with a high amount of diffuse illumination (the blue of a ball) is not a natural phenomenon. This is a good reason (IMO) to use the raytrace material for any material that will do reflections, even if you don't plan on actually raytracing (you can use maps like flat mirror with the raytrace material, just place the map in the environment slot and now you're doing your regular faked reflection using the raytrace material as your base, but doing no actual raytracing. The difference is now you can affect how much of your flat mirror environment gets reflected using the standard Fresnel IOR method talked about above).

The Metal Shader

A shader is another word for a material, but in 3dstudio, the word shader refers to the kind of highlight and illumination a material receives. As stated in Siggraph 96 course notes book #30 Pixel Cinematography: A lighting approach for Computer Graphics...

"When light hits an object, the energy is reflected as one of two components; the specular component (the shiny highlight) and the diffuse (the color of the object). The relationship of these two components is what defines what kind of material the object is. These two kinds of energy make up the 100% of light reflected off an object. If 95% of it is diffuse energy, then the remaining 5% is specular energy. When the specularity increases, the diffuse component drops, and vice versa. A ping pong ball is considered to be a very diffuse object, with very little specularity and lots of diffuse, and a mirror is thought of as having a very high specularity, and almost no diffuse."

Max comes with a shader called "metal", and if you play with it, you'll notice it does just this, the more specular highlight, the less the diffuse color or map affects the surface, and the more diffuse the object is, the less the specular highlight. Unfortunately, this shader is overly simplistic, and does not actually follow the real science behind the diffuse / specular relationship. That is one of the reasons I'd suggest avoiding the metal shader, a little knowledge and good observation on your part will allow you to simulate this diffuse / specular relationship without being stifled by a shader type that is inaccurate. The way to achieve this is by simply changing the shader to blinn or phong, and then changing the diffuse color to almost black. That way, a high IOR will apply a bright clear reflection, and reflect almost no diffuse light since your diffuse color is almost black. The advantage of this method is that if you need to add a little diffuse color to your object to get it to light properly, you can, and without reducing the reflective qualities of the surface. Just remember that the shinier the metal, generally the closer your diffuse color should be to black, and vice versa, and observe real world examples to help you find the right balance.

Simplicity

Following these rules means ideal materials can be made quite simply. For example, chrome is just a raytrace material with fresnel in the reflection slot, an IOR of 10-20, a black ambient and diffuse color, and remember, no specular highlight (since specular is now a reflection of your environment). Worn chrome can be simulated by applying a bump map to this material. Chrome with dirt and crud on it can be simulated by a bump map and a painted map placed in the fresnel map slots to vary the amount of reflection on your material, or a blend material blending between a more diffuse material and your original chrome material.


Real Chrome, almost a perfect reflection of the environment at all viewing angles (with just a tiny bit of diffuse showing through.).

Gold

Another thing to consider about metals, colored metals (such as gold). Non metal materials are referred to as Dialectrics, and usually reflect very little specular light. This makes sense, since most non metal materials have lower IORs, and as such, really only reflect strongly at the edges, metals reflect strongly over most of their surface, which happens when you make the IOR a higher number such as 10. What's more, non metals have neutral colored reflections, the reflections remain the same color as the object being reflected, whereas metals tint their reflections the color of the material. For chrome, the reflection color is neutral, since chrome is a monochrome material. But a material such as gold is more yellowish in color, and so its reflections take on a yellowish tint.

Here's an example, a set of keys and a blue pen. Notice how the grey key reflects the true color of the pen top, and the golden key tints the highlight and pen color the key color. Also note the reflection of the keys in the pen top, which is plastic. Although on first glance it may seem like the reflections are tinted blue, it's actually just the blue diffuse showing through the weaker reflection (remember, as stated above, non metals don't tint their reflection). The pen top probably has an IOR of somewhere between 2 and 3, the keys are closer to 10, but the reflections are broken up a bit since the keys are all scratched up.

Here's another example, 4 colored pencils reflected in colored metal. Notice how all the colors are tinted gold, with the white pencil appears the most tinted.

Again, how do we do this in our max materials? This is achieved by tinting the color of your reflection. See this final example , to properly reflect the four colored balls, the reflection color in the fresnel map is changed to a golden color. By doing so, the colors of the balls being reflected change to approx. the same colors we saw in our real world photograph. Also note in the material the diffuse color is dark, but not entirely black. Don't be afraid to add a little color to your diffuse, just remember that the more specular your material is (the more reflective), overall the less diffuse it should have (ie, closer to black), but do what you need to to make the shot look right.

Note that since the ball is in a completely white environment, and its IOR is so high (ie, it reflects pretty uniformly over the entire surface of the sphere) the sphere is almost entirely gold. If you replaced the white environment with say a room, and it were a completely raytraced image, this would look natural since it would be properly reflecting everything in the environment. However, if you're integrating this material into a scene with no raytracing (but possibly a reflected environment map) you may wish to place the falloff map inside of a second falloff map set to shadow light, with the fresnel falloff map placed in the light part of your shadow/light falloff, and the color black in the shadow slot. This will stop the material from glowing where it receives no illumination from a standard max light source in scenes where you're mixing reflections and more traditional point light sources.

Reference

Hopefully you find something in here that can help you better understand how reflections in the real world work, and how to simulate them in 3d. For my parting words, I can't recommend enough good reference for whatever you're doing, in preparing for this tutorial, I really had no idea for example how the reflections on a colored surface should look. Finding the golden object, taking some good reference photos, this told me how things should look, and after playing in 3d, I was able to figure out how to simulate that look in 3d. Just playing in 3d till I got something that looked right would have taken me a lot longer, and probably would have returned incorrect results, trust your eyes, research before you pick up that mouse and start texturing. It'll save you a lot of work.


Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/vecpix/public_html/tutorials/3dstudio/sm002.php on line 290

Warning: include(http://www.vecpix.com/include_useful.php) [function.include]: failed to open stream: no suitable wrapper could be found in /home/vecpix/public_html/tutorials/3dstudio/sm002.php on line 290

Warning: include() [function.include]: Failed opening 'http://www.vecpix.com/include_useful.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/vecpix/public_html/tutorials/3dstudio/sm002.php on line 290

 


Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/vecpix/public_html/tutorials/3dstudio/sm002.php on line 295

Warning: include(http://www.vecpix.com/footer.php) [function.include]: failed to open stream: no suitable wrapper could be found in /home/vecpix/public_html/tutorials/3dstudio/sm002.php on line 295

Warning: include() [function.include]: Failed opening 'http://www.vecpix.com/footer.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/vecpix/public_html/tutorials/3dstudio/sm002.php on line 295