Looking for Iray MDL examples for VDF
![Esemwy](https://farnsworth-prod.uc.r.appspot.com/forums/uploads/userpics/471/nB75FE0B8135D.jpg)
Has anybody found any MDL examples that implement volumes? I've got something of a handle on BSDFs, and EDFs are pretty simple, but I can't find any discussion of VDFs.
I know we can do simple volumes with Iray Uber, but it should also be possible to do things like random local density (i.e. clouds) or control the apparent size of particulates. As things stand right now, I can barely find the names of the parameters to the volume portion of the material.
Comments
source code or bricks diagrams?
Source, preferably, but custom shader mixer layouts might also be useful.
I've found only a couple of examples, none of them use df:vdf, instead they use df::anisotropic_vdf which is very simple. Reason is df::vdf does not scatter nor absorbs light. df::anisotropic_vdf only has on field which is a directional bias or in plain english a direction. A df::anisotropic_vdf is the scattering value of the material_volume struct.
A material_volume struct has three fields, scattering, absorption_coefficient and scattering_coefficient, these 2 coefficients are color values, which means you can set different amounts of absortion/scattering for the red, green and blue components. The tricky part is that a material that will behave like a volume needs to have the value thin_walled as false.
You might want to check the Structure of a Material Chapter in http://mdlhandbook.com/chapters/chapter2.html
As you can see we cannot control the size of particules, but we can play with how the light bounces on material's surfaces or how light passes through the material's interior.
You also might want to check the folder C:\Program Files\DAZ 3D\DAZStudio4 Public Build\shaders\iray\nvidia which have some interesting examples.
HTH
I've looked in those places and come to pretty much the same conclusion. I've been wondering if I couldn't wire up the perlin_noise_texture to either or both of the scattering or absorbtion coefficients to moderate the strength of the effect depending on the position within the volume. I may just have to hunker down and trace my way through the irayubermaterial.mdl with Sickleyields settings for god rays/ fog and see where the volume components come through from the SSS settings. I was really hoping to find something simpler.
what kind of material/substance do you want to design/replicate?
Another user here has brought this up a few months ago. In case you missed it (it was in the newbies thread, of all places), check about half the page down:
http://www.daz3d.com/forums/discussion/53695/tips-tricks-for-iray-for-newbies/p23
The user is zaz777
I think I know what you're trying to go after, but I'm pretty sure full volumetrics are not supported in Iray. Every example I've seen is for mental ray/VRay, and for 3DS Max to boot, which I don't have.
I've already gone through the Emissive shader and thrown out everything not related to emissives. It was a chore, but it was a good thought exercise, if nothing else. One day I'll re-create it from scratch. I used the diamond MDL example that's floating to make a generic jewel shader. In quick tests, it's more efficient, which is what I wanted to find out. It's certainly a lot easier to use, though you have to get used to applying the complementary color.
Isn't there a math brick you can use to invert the color?
In general most folks think in 'transmission' color, while the internals of the renderer (doesn't really matter which one) are working with absorption color...and that's why you need the complementary color. Inverting the color before it gets to the 'shader' should allow the artist to use the familiar transmission color and make the renderer happy with the absorption color.
Thanks for the link. It has a lot of the information I was going to have to trace through iray uber. I don't know about the level of support for volumetrics in Iray, but I think I can at least find a way to make them non-uniform. I should be able to vary the strength of the effect either randomly or by the position within the volume. I have in mind realistic ground fog and maybe snow.
I guess we'll see how far I get.
Not sure, as these bricks aren't my thing. I was mainly interested in seeing if the application-specific shader was more efficient (it was, about 2-5% more per surface), and easier to use. It would be easier if it used transmission rather than absorption color, but even with absorption, it wasn't too difficult to dial in emeralds, rubies, and other stones.
I can appreciate Daz's interest in coming up with a single uber shader for everything, but as we're finding, shaders "tuned" for specific jobs are pretty handy. The biggest impact would be in a skin-specific shader. But as Iray shaders require an MDL file with the matching definitions, maybe the place to start is a building block of definitions.
Even nVidia's own presentation papers show mostly opaque objects for their volumetric examples. In one slideshow, they have an example of a partly opaque cube frame, where the Gaussian-esque profile of volume thickness is (somewhat) shown. But it is there. That's really all I've ever seen -- the other examples tend to be VRay on Max, even in articles about Iray.
If you can crack this, the Daz Studio world will be forever in your debt.
Here's the position paper I'm referring to. Note's it's not Iray-specific (it's on MDL in general) -- take it for whatever that may imply:
http://on-demand.gputechconf.com/gtc/2013/presentations/S3560-NVIDIA-Material-Definition-Language.pdf
I'm not sure either, as I haven't really delved into the Iray side of things much...
So, I thought I'd try to get up to speed on this, and I'm coming way from behind. So to make sure I'm tackling this from the right angle, I take it we're concentrating on the following block in irayubermaterial.mdl
export material add_uber_volume(
which corresponds to UberAddVolume (29) in Shader Mixer. Is this correct?
Well, the terms are there in irayubermaterial, but clearly not easily deconstructed.
So on a lark, I looked around for a nVidia example, and found a voluemtric example in colored wax (there may be others). Add a 1 meter sphere, and put G2F in the middle of it. Set the distance scale to something quite high, like 90. For the purposes of a fog/smoke effect, set IOR to 1.0. Render, and you can see a nicely defined Gaussian volume effect, where the "thinner portions of the volume are more transparent. In looking at colored_wax.mdl, sure enough, the terms we're looking for and described in some of the documentation are there.
See attached. I've recolored the "wax" as an off-white. First is distance=90, the second is distance=200. The effect is most clearly seen on a transparent background, but the quick render will help in vizualizing the look. For a more feathered look, I think we can either bump up the scale distance, or we might try altering the math. I think scattering_coefficient will control the drop-off of the volume curve.
I know this is similar to what we can do with the uber-duber shader, but this is exhibiting a volumetric profile, and it's significantly less complex than the uber shader.
For those who know the bricks and any procedurals we might be able to use, how would one go about adding some of Ken Perlin's noise to this effect? I mean, other than we'll also need to add an input to the material block.
I think OP's idea is connect the input scattering_coefficient to a perlin noise texture to get an irregular density cloud.
I tried but failed. Didn't see no change.
And then finally this one, where distance=100. I'm guiessing the units are centimeters, as it's a 1 meter sphere. The code for the wax shader doesn't indicate a units, and Iray's defaults to 1 meter. The distance can't be 1 meter, or else at 100 the thing would be mostly transparent. At least I think.
In this shot G2F is also completely outside the sphere. I had her standing in the middle of it in the other examples.
The Perlin noise filter would probably work, but first there has to be a volume distribution to make it look like a real volume. That's demonstrated in the colored wax example that's in the NVIDIA MDL Examples folder. To change the falloff (linearity) to something more useful to mimic dispersive volumes (smoke, fog, etc.), the given math in this example needs to be altered a bit, I think.
Given a texture as an input, like in emissives, this also might work for rocket ship exhaust and gradient glows, that sort of thing. But the shader will need to be revised for that. It's a lot easier to revise the nVidia examples than the Uber shader. But here I have no experience in adding/altering bricks.
Unfortuantely, chapter 2 merely mentions that this stuff exist and what components belong to that. Not much else.![sad sad](http://www.daz3d.com/forums/plugins/ckeditor/js/ckeditor/plugins/smiley/images/sad_smile.png)
Volume materials are described in Chapter X is "a great one"
; by the pace NVIDIA finishes their Handbook, I fear that only my great grandchildren will have the pleasure to browse through the complete one. It took them about five! months to implement the chapter about Combining distribution functions and that quite nice, but, at that place, completely useless chapter about the silk fabric example. (That's something for the appendix!). And in my opinion, it would make much, much more sense to have all distribution functions explained before I explain how (only a portion by now) they can be combined. I should maybe better try to become a NVIDIA employee, 'cause if my boss would find out if I'd do my work that lazy and sloppy, I'd have the "pleasure" to be the first of mankind on Mars... or beyond. And I wouldn't even need a fancy and expensive spacecraft to get there. ![cheeky cheeky](http://www.daz3d.com/forums/plugins/ckeditor/js/ckeditor/plugins/smiley/images/tongue_smile.png)
Ahh, a volunteer. I totally agree with you on the "skin-specific shader" thingy! You've got 24 hours to make one! Um, okay, I don't want to be completely heartless to put you under such pressure... you get 25 hours.![cheeky cheeky](http://www.daz3d.com/forums/plugins/ckeditor/js/ckeditor/plugins/smiley/images/tongue_smile.png)
I'd take it as: MDL is MDL in spite of in which app the actual version of Iray is used in. I had a quick peek into some of the MDL files contained in NVIDIA MDL for 3ds Max package. The MDL examples are mostly the same as those we got included with Studio. They include a few changes regarding texture directories, but the code inside is, in those I have looked in, identical to what we have got.
As far as I can see, the presentation at the link you posted is for the older Iray version for 3ds Max 2013./2014. I'd assume (hope) that they improved it a little bit over the past one and a half year (they really can't be THAT lazy, can they?).
Fortunately, NVIDIA has the old plugins still up, and they all even include a handbook. In the "iray_material_plugin_1.5_Max2014.pdf", on pages 22 - 24, it's explained, how it was done then. Simply put, the RGB color channels of the transmitted color act something like valves or flood gates, and the SSS amount decides, what percentage of our poor little photons will get scattered. ("Out of the door. Line on the left. One cross each."
)
If it is still the same in the current version of Iray, then the color values in the shaders for the ladies of our new Generation 7 would be more than a bit nonsense, since the RGB color value for the red channel there is set at 1.0, which would result in that 100% of the "red" spectral wavelength of light would be allowed to pass through their skins. Sure, light absorption in skin at red wavelength is very much lower compared to green and blue (<- most) wavelengths, but absolutely no absorption? Doesn't happen! Either way, the formula in the IrayUber includes a logarithm on the color, and the (log) for 1.0 is... surprise... 0. Which would lead to an absorption coefficient of 0, and... you have 3 guesses.
Using IrayUber only, it's possible to plug a noise map into the refraction color input, and it will render with the texture. I found the map has to be *extremely* light -- I used Photoshop Render->Clouds, then adjusted the levels to where I could hardly see the clouds. This could point to a way to adapt the wax example.
I'm not happy with the falloff to make a "glow" effect. Since Iray is obliging with a geometric volume by showing us the edges of that geometry, I guess that's to be expected. So in the example below, I added a shell at about 2cm offset, removed the noise map, and increased the distance values about 4X from the inner sphere.
For this example, I basically took the jade shader, turned off just about everything,and set refraction weight/index to 1.0. Refraction color is white (with the optional noise map of your chosing), and transmitted color is .5 (the result of the math for the values I used is 0.00150514997, according to Google's calculator). I then just fiddled with the SSS values, severak of which are the same as the original jade:
distance for both: 250
SSS amount: 1
SSS direction: .3
There are some interesting additional flexibility if you lift the limits off SSS amount and go past 1.
The output of the wax shader is virtually the same, except it can't take a map, and it hard-codes scattering coefficient to color(.5) -- the same I set it up for in this example.
Ha! Not a chance. It's in Daz's best interest to perfect an Iray skin shader for their characters. Someone (they paid) had to have done the Uber shader, and that's one involved piece of work! That same person could assuredly write a dedicated skin shader. Let's start by removing Metal Flakes.
I agree that MDL is MDL, except not everything in Iray seems to be supported in D|S. For that matter, in other programs, too. I keep coming across stuff like this: "The ability to render scenes in Iray for Maya or mental ray using the same MDL materials (partial support for some effects in 3.13)." This is in a blog about Maya 2016, so it's pretty current.
In any case, the (paltry as it turns out) volumetrics support in MDL seems to be available to us, even with IrayUber -- as convoluted as that thing is, with all its conditionals to trace and make your brain melt. Let's see what kind of need exhaust plume effects we can create!
Yeah, I guess I found that one, too. Haven't had the time to read through yet, though.
From what I can tell, volumetrics support is definately in. You're even able to violate energy conservation and turn a poor char into a glowrod. No worries, no one got hurt, all are still alive and well.
I'm not really afraid of the melting, more of where I can lend a grinder to remove the bite marks on my desk. Fortunately I din't try to eat my keyboard... yet. ![laugh laugh](http://www.daz3d.com/forums/plugins/ckeditor/js/ckeditor/plugins/smiley/images/teeth_smile.png)
IMHO, I find the Uber Base well suited to simulate skin(I almost nailed it), I have been playing with MDL since the first beta, at first I was lost with the scarce documentation, they just give you the very basics, now I feel comfortable working with it. In 3DL I was even more lost (I still am).
We can complain for the lack of documentation but it's unforgiven not to experiment. By experimenting I have designed materials for fog, snow, smoke, clouds.
I have no talent but I love to experiment instead of biting desks, mine is mostly crystal.![wink wink](http://www.daz3d.com/forums/plugins/ckeditor/js/ckeditor/plugins/smiley/images/wink_smile.png)
@jag11, I'd say you not only nailed it, you hung it up on the wall with giant spikes!![laugh laugh](http://www.daz3d.com/forums/plugins/ckeditor/js/ckeditor/plugins/smiley/images/teeth_smile.png)
Would you care to share your shader?
Post removed.
I'm sorry. It was not a good idea to share. The purpose of the license was to warrantee fair use of knowledge, 'cause I find unfair unscupulous people to profit with the efforts of others.
Well, thanks, but...
You might have noticed all the other suggestions/findings/explorations/ideas in this thread -- and most threads in this forum -- are in the spirit of giving. People may share and use the information freely. There are no licenses attached to suggestions.
If you're wanting to monetize your shader, I'd highly encourage you to do so. From the one example you've given it looks very good. But your requirement to license for commercial use makes it a commercial post, and that isn't allowed unless you're selling through Daz. You might want to remove or amend your post accordingly.
I fully undersrtand. I hope you will find a way to distribute this in a way that's equitable with the obvious investment in time and skill you put into it. If you aren't going to make the package for resale, you can put the shader up on ShareCG with an NC license. I and others here will be sure to let others know of its availability whenever the subject comes up. That method of doesn't violate forum rules.
I'm back after spending some time in the real world this weekend.
I've jammed together a fairly minimal MDL for volumes. It's based on colored_wax, as distributed with DAZ and the diamond shader found here that I'm sure has been referenced multiple times in the forums.
The constants for IOR and Abbe number, which I looked up here, are for air at 15°C and and 1 atmosphere. This doesn't get us to snow or clouds yet, but it will allow us to simulate other atmospheres, if you're placing your scenes in methane or sulfuric acid perhaps.
A little goes a long way for the absorption and scattering coefficients.
Next, maybe tomorrow, I'm going to try to lift the Perlin noise code from 10print and see if I can get something resembling snow.
I apologise for my glacial pace at implementing this stuff. I've only been doing 3D for 10 months, and it's not my day job.
Play with it and let me know what you discover.
Looking forward to checking this out! What are the chances of being able to plug a texture into the input, as an option to the Perlin noise?
The rainbow dispersion from Abbe will aid in some effects. I played with it when doing the sample that shows the primary orb, plus the geo shell. My rig is fairly slow, though (just 500 cores), and having two deep volumes takes *forever* to render as it is. Without the volumetrics the scene renders in about two minutes; with volumetrics, I'm at 12 mintes and still "under the knee" at 75%, with plenty of unconverged pixels still left. Slow cookin'.
I'm not really sure how I might plug in a texture. Maybe it could be a mask in the XZ or XY planes to control the strength of the effect. Honestly, it really depends what's required to get the effects I've mentioned working.
That would be one way...and probably something worth exploring. But directly plugging the image in, instead of generated noise, is also a useful feature, although generated noise is probably 'cheaper' memory-wise.
When we use the uniform keyword on an argument we are telling the MDL compiler that value is fixed and won't change over time, if we want to plug in a texture, uniform keyword is not necessary. Did a test plugin in a texture to scattering_coefficient, but looks like MDL just uses the first value it gets.