Complex fresnel using VRayOSLtex

That would be great Vlado! Sure would beat mapping the curves out by hand…
Although it would be even better if the two methods would work side by side. Essentially you could enter the rgb n and k values to get a starting point for ‘reflectivity’ and ‘edgetint’ and then switch over to ‘artist friendly’ color slots to tweak the color if needed. So if the client says, make that gold more rosy or less yellow - it would be easy and intuitive to do while still having physically correct starting point for the particular metal.

I hope that makes sense :slight_smile:

Otherwise I have an OSL shader with NK inputs ready that I could post later today.

Sure, that could be useful as well.
btw I’m willing to donate some cash to whoever creates a combo of the two (seriously)

Super cool. Man I really need to set aside some time for learning OSL!

Here is a shader that allows you to enter n and k values directly (for 0.65, 0.55 and 0.45 micrometers - you can get values directly from http://refractiveindex.info/)

Use as a reflection color map and make sure the Fresnel option in the VRayMtl material is disabled.

Best regards,
Vlado
complex_ior.zip (583 Bytes)

Or else, just have a drop-down with values from the refractiveindex website (copper, gold etc) so that you don’t have to type those each time… would be much simpler :slight_smile:

Best regards,
Vlado

Sure, that would be perfect :slight_smile:
For now, I guess I’ll just create a few preset maps for the most common metals manually and run them through a color correct node to slightly change the hue if needed for artistic purposes. I think that should work pretty well.

Thank you for the shader!

That’s great Vlado!

you know I probably shouldn’t have put n and k in there as those values need to be normalized to fit 0-255 (from refractiveindex.info) as was said. The idea is to make it easier to have a complex fresnel but be able to tweak those colours by eye.

just have a drop-down with values from the refractiveindex website (copper, gold etc) so that you don’t have to type those each time…

so that’s why in another post I was wondering about a dropdown list in OSL :slight_smile:
even that thinFilm shader you wrote would be great to have some pre-sets for different materials.

The drop-down is actually pretty much done now and will be in the next SP.

Best regards,
Vlado

Hmm.. where do you see the rgb values for N and K on the refactiveindex.info website ? I only see the N and K, but not the rgb values ?

You need to change the wavelength to the appropriate value - R=0.650 G=0.510 B=0.475

Here’s mine for what it’s worth. :slight_smile:

This is a somewhat different approach, I think I got the equation from the old Odforce Wiki. If someone wants to do complex number calculations in OSL there are a few functions for that included here.
complex_fresnel_v001_rh.zip (829 Bytes)

This works like a charm, thanks guys!

Vlado, would it be possible to include colour swatches next to the n and k values? It would be awesome if we can put the correct numbers in and then tweak the colours individually. It would give more control over a colour correct and keep the shader a bit simpler.

Vlado, that’s working great! But it seems I have to apply gamma to the osl texture, otherwise the result is very washed out.

Really, that’s odd. It seems to work fine for me… can you show me? I have a feeling that applying gamma to this shader is wrong.

Best regards,
Vlado

Sure! Here you can see your complex fresnel osl with the values for copper. On the left without any modifications, on the right with gamma 2.2. When I redraw the reflectance curves with a falloff map, I get a result close to the gamma 2.2 version. Will check my gamma settings just to be sure, but I never had something like that before.

Ok; not sure about that one though - I just copied the formulas and I’m pretty sure the Fresnel equations do not feature any gamma correction. What are the n and k values that you used? I think the default ones that I put in the shader are for copper.

Best regards,
Vlado

My 3dsmax design 2011 crashes instantly everytime I try to load these OSL files; just to confirm it, can anyone doublecheck with an old max release?

Vlado,
I looked up the settings for copper over at refractiveindex.info and found out that your default values are already set for copper. But it is the same for all my other materials as well. My older ones used the curves, and they are much more saturated then the materials with the osl and no gamma correction.
That isn’t a big problem for me, I can always put the osl texture into a color correct node.

I’m not sure this is a gamma issue.
I made a test with gold, rendering 3 different versions :
1- with the complex ior vrayosltex (values from refractiveindex.info)
2- with a falloff map with custom RGB curves (values from refractiveindex.info)
3- same as 1 (vrayosltex) but with a cc with gamma 0,45

As you can see the first two are pretty close, but the vrayosltex does indeed lack a little punch in the colors, whereas the gamma corrected version is very different.