Vray Materials – Part 3 – Metals

Let’s continue the shader theme a bit further. Todays topic will be METALS

Metals are a special case – in their pure form, they do not have a Diffuse component, only reflections.
As if that were not enough, those reflections behave differently from non-metals.

They are much stronger, the fresnel equation (and the resulting curve) is more complex and the reflections are colored in a lot of cases.
Here is a comparison of reflection curves of aluminum and plastic.

curves

Notice that overall reflections are stronger and that there is a dip towards the right end of the graph for the aluminum. The math to create this graph needs multiple values, not just a simple number for IOR.
Vray doesn’t natively support the complex fresnel equation with n and k values used for metals. So to get accurate reflections, we must use some tricks.

The first method (popularized by Grant Warwick in his Mastering VRay course) is by creating custom falloff curves by hand in the material editor.
This method works, although it is quite tedious to set up. If you watch his course you will see how to use it, I’m not going to repeat it here.

However, there is one important thing that Grant didn’t quite get correctly, so I feel like I should ‘fix’ it.
The falloff map in 3ds max works in a strange way, the actual values are not really exactly what they seem. It seems that the falloff goes from 0 to 90 degrees in a linear fashion, but that is simply not true. So if we place a point at 50% and expect it to represent the color at 45 degree incidence angle… it doesn’t really show up at 45 degrees.
Here’s a simple test setup and the results. The lines on the sphere are rotated at exactly 45 and 22.5 degrees As you can see, it simply does not match.

edit

***Edit***

Thanks to on Wobi on chaosgroup forums for writing this osl you can use to ‘fix’ the falloff precisely. Just unzip and load this FILE as both Front and Side of the falloff and you can use the curves like Grant suggests in his videos.

FIX

After writing this post, there have been some changes that make the method below outdated. Siger from sigerstudio.eu has written a FREE plugin that works with older versions of vray and also has ready-made presets that allow you to get the correct metal reflections very quickly and easily!

Check it out HERE!


The second method (the one I prefer) uses a custom OSL shader as the reflection texture (load it into the reflection slot through VrayOSLTex node and make sure the Fresnel is off in the shader settings) and it’s a bit easier to use. You just have to enter the n and k values taken from the refractiveindex.info site for R, G and B wavelengths.

nkvalues

rgb
The actual values for red, green and blue are somewhat open to interpretation, Different sources use different numbers but the approximate range is similar.
I use values from NASA’s site: 0.650, 0.510, 0.475

Now the resulting reflection map has the correct color and the correct falloff calculated by the complex fresnel equation.
When you’ve set up the values for a particular metal, save the osl file for future use.

If the color feels a bit wrong or you need a slightly different alloy, just run the map through a color correction node and adjust the hue saturation there. This way you still have the correct starting point with correct falloff curve and are just making color changes.

color_tweak

Another interesting thing about metals is that they are actually almost never pure metals. As soon as they are exposed to air, they start to oxidize (tarnish, rust).
tarnishThe resulting metal oxides behave like dielectrics. So this means they actually have a completely different set of properties. There are a couple of ways to deal with this: Blend materials and complex map setups in single layered shaders. I’ll demonstrate these workflows in detail pretty soon as a premium video.

That’s it for this chapter in the vray PBR material guide :)

32 thoughts on “Vray Materials – Part 3 – Metals

  1. I would not say that the metal does not contain diffusion.
    Think why all metals in general gray? if you want to portray a primitive picture with metal object, what pen color will you take? most likely it will be gray.
    but why? because as you said metals do not contain diffuse and reflect the whole world. if they only reflect why they gray? fact our world is not gray.

  2. I find when using the Complex IOR OSL the gamma is wrong and I always need to run it through a Color Correct because it seems pretty washed out. Do you care sharing the link to NASA’s database, did you need a special login?

    • I find that gamma correction makes the result too intense, and Vlado says this osl shouldn’t be corrected.
      If the color seems too washed out, I just pump up the saturation through the color correction node.

      The nasa site is not a database or anything, it’s just a page that explains color wavelengths (page looks like it was made 20 years ago, still, basic physics couldn’t have changed in this time :D ) – http://science-edu.larc.nasa.gov/EDDOCS/Wavelengths_for_Colors.html

      • Ha ha! With that site you could make an infrared or ultraviolet material. (joke) :)

        Thanks again, Austris! You’re the best!!

  3. Thanks Austris! For me PBR information is really, really useful stuff, and I love it! :)

  4. I tried to use this custom OSL Shader in Vray4Maya, but it doesn´t seem to work.
    Shouldn´t it work?

  5. Just a quick question, you mentioned I should enter the values for N & K in the VrayTexOSL… If I am trying to replicate copper for instance…. The N & K Values are N = 0.460990 K = 2.9736 – where on this page “http://refractiveindex.info/?shelf=main&book=Cu&page=Rakic” Is there a break down of the values for the R,G,B????

    • You need to input the wavelength values in µm one by one.
      So for example, input 0.650 to get the n and k values for red, then enter 0.510 to get them for green and finally 0.475 for blue.

  6. Please one question, where can I find the wavelength input values of red, green and blue, thanks a lot for your help!

  7. Hi, i am vray 2.40 user, but i cannot find the vrayOSLtex, am i missing anything?

  8. Thanks for the tutorial.
    Where do I find this parameter ?
    http://viscorbel.com/wp-content/uploads/rgb.png
    it’s not in VRayOSLTex

  9. Hi guys maybe you can help me. I have vray 2.4 and i only have glsl shaders and no osl, even though on chaosgroup docs there is page about osl for vray2 with examples.
    http://help.chaosgroup.com/vray/help/200R1/vrayosl.htm
    http://help.chaosgroup.com/vray/help/200R1/examples_vrayosl.htm

    I was wondering is it possible to somehow convert osl shaders to glsl in?
    Or maybe i just doing something wrong.
    Thanks.

    • Hi Toki, i facing the same problem with you, i cannot find anything about osl with my vray 2.40 too :(

  10. It’s a really amazing take on the PBR approach for materials. (All thanks to Austris for his in depth explanation) but it was little confusing to understand the procedure to get the values for n and k. So after reading the comments properly from Austris I was able to figure out the procedure. (Actually its quite simple). Have a look on the images below for explanation.

    https://www.dropbox.com/s/bnnym6w5l5djuf7/n%20and%20K%20Values.jpg?dl=0

    https://www.dropbox.com/s/3woon386z46ekhk/Copper%20Result.jpg?dl=0

  11. If we take for example Zn (Zinc) – it has n=1.17 and K=4.92. How can we work with the RGB values that you mentioned if the actual wavelenght is (1.23-10.0)?

  12. Hi Austris
    One thing form lesson 2:
    Grant’s technique was meant to do 2 things at once:
    1st – simulate the multiple lobe specular (now replaced by GGX)
    2nd – make the reflections become glossier as they approach grazing angles.

    Above (lesson3 technique) is replacement for above point 1 or 2 ?
    So do we need GGX BRDF when using osl shader technique ?

    Cheers
    Greg

  13. http://www.sigerstudio.eu/shop/3ds-max/sigertexmap-complexfresnel/
    Found a plug-in, which is based on the osl file, it seemed easier to use as you think?
    With the description of use, can be ineteresen you and your subscribers.

  14. This article guided me at idea to create a plug-in of which it is possible to use and with early V-Ray versions. Thank you, Austris.

  15. Hi,

    I’ve read this tutorial a few times; and since the beginning, I’ve always thought that the preview sphere is in perspective (as opposed to planar projection), so the preview always looked right to me.

    Can somebody explain why the falloff needs to be projected in planar instead of with foreshortening? I’m starting to get confused now… :)

    Thanks!

  16. Hi Austris,

    Thanks so much for all the hard work you do that we get the benefit of! I’ve learned quite a bit from these posts and have gone back to some of your scenes from the Studio Lighting Premium Tutorial I got a while back and updated the shaders. They looked great before, but even better now! :)

    By the way, I’m wondeing if there are some optimal PBR settings for the V-Ray Physical Camera? The default is always too dark and has to be adjusted anyway, but I’m not sure if there is a best combination of settings to correct the exposure. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *