Complicated Iray shader questions
I've been trying (for the past several months, off an on) to work on as close to physically accurate soap-film shader.
Not just a thin-walled, thin film shader, which has issues (which I'll go into below), but one that actually looks like a real soap film.
In order to achieve this, I use a set of shader bricks in mixer to allow the selection of either a texture or one of the various noise functions to generate the 'thickness' of the film (from 0-1000nm) which is then used to index into a soap-film thickness gradient map texture. This part works, and works quite well.
It is getting that color data onto a properly specular, reflective, and transmissive thin-walled double-sided surface so that it looks and functions correctly.
The transparency of the film should be high, but should be color-filtering (i.e., the color shifts from the thickness should be quite visible, even against something inside the film.)
The inside surface should be equally visible whether outside (viewed through the outer surface) or inside the film.
The specular reflections should also be color filtered by the thickness coloring, to at least some degree (can be seen in many photographs of actual soap films.)
Fresnel transparency should be used, but with a higher power than default (it's only at the very edges where the fresnel effect should be visible) and even then only partially opaque.
Something lit from the other side of the film should show color from the thickness color effect (either complementary or not, I can find very little literature on this particular feature.)
I tried using thin-glass and thin-water, and using my above 'thickness' bricks to feed into a thin-film on them. It worked, somewhat, but only faintly, and did not have all the features (inner surface color was virtually non-existent, inner reflections mostly gone as well, Fresnel effect at edges wasn't bad, but specular reflections were always full-color, not filtered.....and no color-filtering from light on the other side of the film showing on objects.
Anyone have any suggestions on how to build out the shader preset?
Comments
I think part of your problem is that you are working with something only 1 poly thick. Even as thin as a soap bubble is, it does have real thickness. A single poly doesn't. Faking the thickness isn't going to quite do it...it will still be 'single sided'.
I've also tried using an actual hollow sphere (quite thin, but not nanometer scale) so that real interior reflection and such should work. But it isn't. (and yes, I made it myself and verified normal directions for the interior polys)
The effects you are after basically only occur at the nanometer scale, anything thicker and absorption starts to play too much of a role.
Only the thin-film simulated properties are nanometer scale. I'm not using the thin_film() MDL parameter, as that (as I noted before) creates the same issues with interior reflections and layering inside a transparent object.
I'm simulating the thickness (and it's variance over the surface) using a noise function (perlin, flow, worley, or a thickness texture) which is then indexed into a gradient map to achieve the correct coloration for a given equivalent thickness. That works just fine. It's the remaining characteristics (the fresnel term for the transparency, the color filtering, color projection, color-multiplied specular reflections both interior and exterior, and the specular highlights) which are being more troublesome to correctly generate, as well as how 'opaque' the color on the surface is (though that may be able to be handled with a simple cutout brick.)
I'll see if I can post an image this evening that demonstrates some of what is not working, as well as images that show how it should look.
Depends on the "accuracy" you're going after, but this sub-thread in the larger "Fiddling with Iray skin settings" thread might be of some use. Or maybe not, as you may be beyond these basics.
http://www.daz3d.com/forums/discussion/54239/fiddling-with-iray-skin-settings/p23
The thin film (not just thin-walled) settings in Iray simulate thin film interference, which produces the dichroism I think you're after. Andy and I shared some settings in experimenting with this. BTW, this was with default Iray Uber shader in 4.8; I haven't replicated these tests in the 4.9 beta (or maybe it's out already; I haven't been paying attention). There were some changes in the way volumetrics work in 4.9, and while volumetrics are inactive with thin wall turned on, other more subtle changes may impact the base thin film settings. If you haven't already, you may wish to open the irayubermaterial.mdl file to review the math they are using. You may find it useful to make a copy of this file if you want to try applying different terms to the formulas.
Thanks Tobor, I already looked over those discussions in the other thread. The big issue with using thin-film is that to simulate the varying thickness of the soap film surface (which in virtually every render I've seen, they don't) is that the thin-film interference effect doesn't vary and becomes very faint. In actual photos of soap-bubble films, the colors are quite bright and intense, as are the specular highlights. Also, the reflections off the surface are colored by the film colors, which doesn't seem to happen with any layering I've been able to produce.
Also, reflections on the inner surface become virtually invisible, which they should NOT be. (yes, using an actual hollow sphere, not just a solid sphere with thin-walled on, which also has that issue.)
I also see a lensing effect on the specular reflections even with such a thin layer of glass (my hollow sphere is 0.1mm thick at 1m diameter.) The specular reflection on one side is inverted on the interior specular reflection on the other side.....it shouldn't be.
I'm beginning to think that Iray itself has some sort of buggy behavior here......trying to come up with some simple renders that show the individual issues.
This is a drawing of what you are looking for in a model of a soap bubble.
In reality you are dealing with 2 volumes. The first is a thin film of soap/water. This thickness is not neglegible, even though it is very thin. The second is a contained volume of air. The differences between the air and the film IOR values are what cause the dichromism and other effects.
The thickness of that film IS fairly uniform...surface tension is going to assure that. Also, it's thin enough that absorption is not much of a factor.
One of the problems with the Iray shaders is that thin film/wall doesn't account for that interior volume of air (it's supposed to simulate a surface film on SOMETHING...like oil on skin/water/etc or a very thin, nearly no volume surface) and with it off, you start getting absorption playing with things...as if the whole volume is water/soap mixture...like a drop.
In any shader, that interior volume of the bubble needs to be defined as being AIR.
Actually, the surface thickness of a soap film varies considerably (between 1 to 1200nm.) That is why different colors appear across the surface (in addition to the angular differences for curved films do to light passing through longer chords.) It varies due to fluid dynamics, since the 'film' is actually a three-layer structure consisting of soap molecules on the outside with water contained between them. The fluid dynamics causes vortices and other phenomena throughout the surface, which stabilizes over time and the film becomes less varied by fluid movement. Gravity also affects the water significantly, which is why most bubbles pop (in addition to evaporative losses.) The fluid tends to pool toward the bottom of the bubble.....which is why over time, the bubble coloration becomes more horizontal stripes, with the very top becoming almost clear just before the bubble pops (when the thickness goes below 50nm, virtually no color is seen.....it becomes effectively transparent.)
But as I said, achieving the color patterns isn't the issue. It's achieving correct intensity, transparency, and color-filtering OF those colors as well as correct interior reflections. The built-in thin-film MDL was designed more for adding iridescence to existing surfaces, not being the base surface itself, and it also doesn't handle certain elements beyond that very well (or at least the mixing functions don't allow it to.) Hence, why I posted here for ideas.
mjc, are you suggesting modelling this as two seperate volumes (the hollow sphere, and the interior air? I thought that Iray (like most renderers) when path tracing through a surface, would consider exiting that same object (i.e., passing through the same object, but through a poly that was facing away) it considered it as exiting to the default IOR (namely 1.0, for air) so that such things weren't necessary to model.....
Yes most shaders are written so that passing through like that will go from air > material > air. That works well for things like flat surfaces or 'open' things like a wine glass...but not so much for a totally contained volume. It needs some way of saying that the inside is air...that's why you are getting the magnification...the shader is thinking the inside is water/glass/whatever.
I think it would be easier to do for particles than it would be for mesh models...or a pure procedural that the shader IS the surface. Or make a double sided shader that applies thin film to both sides of a single thickness sphere.
Actually, it turned out I was misinterpreting the reversed specular reflections, which are simply due to the concave surface and the angles I was using. It wasn't producing lensing effects. But it is STILL not wanting to show interior reflections, except for VERY faintly, and then only when I ramp certain things up way too far. It's almost as if Iray thinks that within a closed volume, the transmitted light inside gets reduced substantially.
That's the apbsorption part of the shader kicking in...it's 'thinking' that interior is a 'solid', not a volume of air.
Is this in 4.8 or 4.9?
There are some volume fixes in the version of Iray in 4.9....
Here are couple of 3Delight double sided Shader Mixer examples. I don't know if they can be translated to Iray or not...
http://www.sharecg.com/v/67747/gallery/7/Material-and-Shader/Age-of-Armours-Doublesided-Shadermixer-network
http://www.sharecg.com/v/67744/gallery/7/Material-and-Shader/Richards-doublesided-ShaderMixer-network
The more I think about it, the more I think the double sided approach with thin film on each side, while not completely physcally accurate, will end up looking better/closer.
Not sure it's so much buggy behavior but one of unsupported use case. Iray is not a "technical" renderer; nVidia's other PBRs provide for this. Iray is the "pushbutton" version of their more robust engines. As such, Iray doesn't have as many fine-tuning adjustments for the final details of the more unique physically-based materials, and that would include thin film coatings.
In addition, the material definition file D|S uses, irayubermaterial.mdl, is likely not built with this kind of subtlety in mind. It's made for things like applying shaders to clothing, skin, and hair. I think you want Maya, or some other more advanced rendering tool with extended materials support.
Do also keep in mind that part of the effect you want may also come down to lighting type and angle, especially specular lighting, and perhaps applying the Caustics Sampler filter.
Be aware that if thin walled is on -- typical for geometries that are one poly thick -- the volumetric shading features are simply not active. This is how the Daz iray shader works. The volume functions are only active when thin walled is turned off. So you either have to live with some compromises, or write your own MDL functions to support what you want. I suspect this is what you will need to do in any case. D|S shaders only connect to (and control) MDL functions, and if those functions in the Iray uber file are lacking for you, you need to craft your own. Check the nVidia technical documentation for their version of the MDL specs. There have been some threads in the Technical Help forum detailing stabs here in there on custom MDL writing.
mjc, I'm using 4.8, as 4.9 still has enough issues that I'm holding off on the beta. So that may be the problem, and I'll simply have to wait for the Iray fixes that are coming in 4.9.
Tobor, I'm not using IrayUberMaterial. I'm building directly using blocks inside of Shader Mixer. I did make some attempts to build it directly in MDL, however I kept running into issues with testing the new shader....so I decided to build it first in shader mixer, so I could better lay out the layering and mixing sections before making it as a pure MDL shader. It also allows me to tweak values a little easier. I'm quite familiar with the MDL documentation (what there is of it.)
I think you are going to run into the same problems most of us who have tried Shader Mixer on the 3DL side of things, too...not much documentation there, either. And not every brick works exactly like expected (it could be that the expectations were off, too...but without good documentation it's not easy to figure out which case it is).
You cannot build an Iray shader with the mixer or editor alone. Everything in Iray eventually funnels through an MDL file, which contains the actual functions that Iray uses to define the surface. All of the Daz Uber Iray presets use irayubermaterial.mdl, so if you're building a shader off any of those, then it's the functions in this file that are being called.
There are some older threads in the Technical Help forum on building new shaders from scratch, starting with MDL then importing those into the shader mixer -- the associated bricks are automatically created. You might want to go through those threads to see if there's anything you can do to alter the base functions, in order to get the look you want. Warning though, this is arcane science. There are scant examples (though D|S comes with some, adapted from the nVidia examples), and the testing can be tedious.