Looking for Iray MDL examples for VDF

2

Comments

  • ToborTobor Posts: 2,300
    edited September 2015

    As a proof of concept, I had edited IrayUber shader (not the MDL) for just volumetrics, and kept the refraction weight, index, and color input nodes intact. I also left in Abbe, and a few other things.

    As I noted above, you can get a noise texture by plugging it into the Refraction Color node.

    The "problem" is that the volume brick is downstream of everything -- it appears right before the render stage. The refraction color first goes through a refraction map brick, then to join into what looks like a T-bridge, the metallacity base. (As I'm a beginner with these brick thingies on not clear on the terminology!). 

    Here's a test render with my modified UberShade that has all the nodes removed except the ones I felt critical to this process. I didn't render this with the texture input, so it's straight volumetrics. (As a side note: this volumet stuff really taxes the old CUDA cores.)  Being able to use a texture map is, I believe, crucial. Not just for noise, but for general effects, such as exhaust plumes.

    In case this is useful, what's the EULA restrictions for posting a DUF or DBM that's been modified from a Daz asset? Can these be shared? 

     

    ModifiedVolumeShader.jpg
    1712 x 939 - 123K
    Post edited by Tobor on
  • Arnold CArnold C Posts: 740
    edited September 2015

    I'm back after spending some time in the real world this weekend. smiley 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.

    Looks like there isn't any absorption or scattering happening there. I may can help you out to optimize that. At least for the absorption coefficent.

    Taken from the article "Journal of Heat Transfer, November 1982, Vol. 104/602-608 "Evaluation of Coefficients for the Weighted Sum of Gray Gases Model", that for water vapor, at a pressure of 1 atm (atmosphere),  would be around 0.4496 (per meter), and for a water vapor/carbon dioxide mixture around 0.4303 (per meter). Since DAZ seem to already have adjusted their Iray renderer-plugin to the default 1 cm per unit Studio world scale, I'd go with a 1.0 for "distance_scale" in the MDL and a 0.001 on the Shader Mixer in Studio. That way your work would be of universal usability for any Iry version.

    GPU Gems 2 has an article about Accurate Atmospheric Scattering. Some of the listed "References" are dead already, but the "Rainbows and Fogbows: Adding Natural Phenomena." by Clint Brewer is still available and looks interesting at the first glance. Maybe you find something useful in there for your project.

    Cheers

    Post edited by Arnold C on
  • Arnold CArnold C Posts: 740
    edited September 2015
    Tobor said:

    As a proof of concept, I had edited IrayUber shader (not the MDL) for just volumetrics, and kept the refraction weight, index, and color input nodes intact. I also left in Abbe, and a few other things.

    As I noted above, you can get a noise texture by plugging it into the Refraction Color node.

    The "problem" is that the volume brick is downstream of everything -- it appears right before the render stage. The refraction color first goes through a refraction map brick, then to join into what looks like a T-bridge, the metallacity base. (As I'm a beginner with these brick thingies on not clear on the terminology!). 

    Here's a test render with my modified UberShade that has all the nodes removed except the ones I felt critical to this process. I didn't render this with the texture input, so it's straight volumetrics. (As a side note: this volumet stuff really taxes the old CUDA cores.)  Being able to use a texture map is, I believe, crucial. Not just for noise, but for general effects, such as exhaust plumes.

    In case this is useful, what's the EULA restrictions for posting a DUF or DBM that's been modified from a Daz asset? Can these be shared? 

    I'd say, since it says at the top:

    "Copyright © 2015 DAZ 3D, Inc. All Rights Reserved.

     This file is part of the DAZ Script Documentation.

     This file may be used only in accordance with the DAZ Script
     license provided with the DAZ Script Documentation.

     The contents of this file may not be disclosed to third parties,
     copied or duplicated in any form, in whole or in part, without the
     prior written permission of DAZ 3D, Inc, except as explicitly
     allowed in the DAZ Script license."

    I'd take a look at that first. Just to be on the safe and sunny side. winksmiley

    Post edited by Arnold C on
  • ToborTobor Posts: 2,300
    Arnold C. said:

    I'd say, since it says at the top:

    "Copyright © 2015 DAZ 3D, Inc. All Rights Reserved.

     This file is part of the DAZ Script Documentation.

     This file may be used only in accordance with the DAZ Script
     license provided with the DAZ Script Documentation.

    Wrong file -- that's the MDL. There's no copyright preamble to the IrayUber DUF, or DBMs generated from existing assets. I'm wondering if it's the same as file with a morph controller that contains the original morph.

  • ToborTobor Posts: 2,300
    Arnold C. said:

    Looks like there isn't any absorption or scattering happening there. I may can help you out to optimize that. At least for the absorption coefficent.

    Not sure if this comment was in response to my sample at the top of the page, but the volumetrics are there. I simply dialed in large values intentionally to speed up the render. It's a 1meter sphere, and I put both values at 2 meters, as shown in the shader panel

    Spheres are actually not all that good for demonstrating volume effects. I've attached another example of a cone, with distances set to 50cm. The apex of the cone, and the thinnest part of the volume, is right in front of her.

    cone_volume.png
    800 x 800 - 414K
  • EsemwyEsemwy Posts: 578
    edited September 2015

    Thanks to jag11, I have Image inputs at least wired up. Removing the uniform keyword and a couple of new bricks takes care of that.

    jag11 said:

    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.

     

    mdl 1.1;import df::*;import math::*;import anno::*;import base::*;export material basic_volume(    uniform float ior = 1.0002772,    uniform float abbe_number = 89.30,    color absorption_coefficient = color(0),    color scattering_coefficient = color(0))= material (    ior: base::abbe_number_ior(        ior: ior,        abbe_number: abbe_number    ),    surface: material_surface (        scattering:    df::specular_bsdf(            tint: color(1.0, 1.0, 1.0),            mode: df::scatter_reflect_transmit        )    ),    volume:  material_volume (        scattering: df::anisotropic_vdf(),        absorption_coefficient: absorption_coefficient,        scattering_coefficient: scattering_coefficient    ));

     

     Actually plugging in a texture, though, makes Studio crash. I'll give that a try again later this evening. Suggestions?

    Tobor pointed out this post the other day. The item of interest to me is the equations lifted from Iray Uber:

    absorption_coefficient = log(Transmitted Color) / (-1.0 * Transmitted Measurement Distance)scattering_coefficient = SSS Amount / SSS Measurement Distance

    My question, since I'm not familiar with the physical processes, is this. Is the logorithm used above simply to make a more granular range of values available in the result, or is it a fact of nature?

    I need to get some dinner. I'll report back on the noise texture when I have some results.

    P.S. And why do code snippets display in such a huge font?

    mdl_vdf_bricks.png
    1218 x 722 - 237K
    Post edited by Esemwy on
  • ToborTobor Posts: 2,300

    Nice work!

    I'm currently doing a very long 3000px render, and when I can I'll experiment a bit with the toolset I've made. But to answer the question about the math involved, I would think this is material specific. That said, when I rendered side-by-side orbs using IrayUber and the wax snippet, they looked pretty similar. The renders weren't high def, and I only let them go to about 40%, so maybe in a fully-rendered scene the differences in the math between the two MDLs is more apparent.

    On the crash, I'm guessing at this point, but I wonder if the image needs to go into only one term, either absorption or scattering, but not both? For that matter, what happens if we have different maps for each?

    So ... we can copy and paste code to make the MDL, but is there a way you can save the brickset and post it here?

  • EsemwyEsemwy Posts: 578
    edited September 2015

    Basic Volume (works)

    Intermediate Volume (crash)

    I was only using one texture map at the time, for scattering. I'm stepping back on that and taking a closer look at noise textures.

    Noise texture also causes crash just as render starts.

    Update: Bug report filed. I'm probably doing something stupid, but it still shouldn't crash.

    Post edited by Esemwy on
  • EsemwyEsemwy Posts: 578

    Noise Volume (also crashes)

    Any suggestions?

  • jag11jag11 Posts: 885

    I'm away from my computer. I'll give it a try later.

  • jag11jag11 Posts: 885

    No crash here. Use these values to actually generate visible perlin noise. I did some tests and found that plugin in perlin noise generator to the SSS Amount has no effect.

    Perlin Noise Values

    pn-values.PNG
    171 x 365 - 9K
    noise.png
    764 x 573 - 285K
  • EsemwyEsemwy Posts: 578
    edited September 2015

    Yep. Still crashes. Apparently OS X specific. I'm running latest NVidia webdriver and CUDA. Looks like I'm toast on this until somebody fixes something.

    Update: Definitely a Studio problem. Still crashes on a Mac with no NVidia/CUDA. Looks like they're overrunning a buffer on the stack.

    Post edited by Esemwy on
  • jag11jag11 Posts: 885
    Esemwy said:

    Yep. Still crashes. Apparently OS X specific. I'm running latest NVidia webdriver and CUDA. Looks like I'm toast on this until somebody fixes something.

    That's weird, I'm always working with Iray preview on. The only time DAZ Studio crashes on me is when I use Geometry shell and export to Hexagon, no matter what figure or shape I work with.

    What if you just render with CPU only?

  • EsemwyEsemwy Posts: 578
    jag11 said:
    Esemwy said:

    Yep. Still crashes. Apparently OS X specific. I'm running latest NVidia webdriver and CUDA. Looks like I'm toast on this until somebody fixes something.

    That's weird, I'm always working with Iray preview on. The only time DAZ Studio crashes on me is when I use Geometry shell and export to Hexagon, no matter what figure or shape I work with.

    What if you just render with CPU only?

    I rendered on a completely different computer, a laptop with no NVidia card. It still crashes.

    It's getting a SIGBUS in one of the threads running libiray.so. This is always a programming error. I thought initially that they were overrunning a buffer because of the stack canary message, but looking closer it's more like they tried to access data on an improperly aligned address.

    If the above sentence is gibberish, please ignore it. If you're a software engineer, I'll gladly provide more, but it might injure others in the thread.wink

  • jag11jag11 Posts: 885
    Esemwy said:
    jag11 said:
    Esemwy said:

    Yep. Still crashes. Apparently OS X specific. I'm running latest NVidia webdriver and CUDA. Looks like I'm toast on this until somebody fixes something.

    That's weird, I'm always working with Iray preview on. The only time DAZ Studio crashes on me is when I use Geometry shell and export to Hexagon, no matter what figure or shape I work with.

    What if you just render with CPU only?

    I rendered on a completely different computer, a laptop with no NVidia card. It still crashes.

    It's getting a SIGBUS in one of the threads running libiray.so. This is always a programming error. I thought initially that they were overrunning a buffer because of the stack canary message, but looking closer it's more like they tried to access data on an improperly aligned address.

    If the above sentence is gibberish, please ignore it. If you're a software engineer, I'll gladly provide more, but it might injure others in the thread.wink

    What's gibberish? laughJust shoot. I speak several languages, from binary, octal, hex to C++. what does your log file says?

  • EsemwyEsemwy Posts: 578
    edited September 2015

    FORSAKE ALL HOPE YE WHO ENTER HERE

     

    txt
    txt
    crash-report.txt
    99K
    Post edited by Esemwy on
  • jag11jag11 Posts: 885

    Could you share a basic crashing scene with just a cube in it with the shaders applied and the mdl script use, please.

  • EsemwyEsemwy Posts: 578

    volume.mdl material

    Test MDL.duf scene file

    Noise Volume.dbm shader config

    Interestingly on reloading (using a cube instead of my usual sphere), it got through a couple dozen iterations before crashing.

  • ToborTobor Posts: 2,300

    No crashes here. The input values are not what I was expecting, so I'm guessing you're going after something a little different. I'll wait for you and jag11 to sort out the crashing.

     

  • EsemwyEsemwy Posts: 578
    Tobor said:

    No crashes here. The input values are not what I was expecting, so I'm guessing you're going after something a little different. I'll wait for you and jag11 to sort out the crashing.

     Tobor, the working theory right now is that the crash is Mac specific. If you're on Windows, you should be able to run what I posted with jag11's parameters and get something resembling his results shown above. Right now, the noise is only connected to the scattering coefficient. You might need to play around a bit to get something more snow-like.

    You might also try working with the "Intermediate Volume" I posted, since the crash there is probably also Mac specific.

  • jag11jag11 Posts: 885

    Didn't crashed either.

  • EsemwyEsemwy Posts: 578
    jag11 said:

    Didn't crashed either.

    OK. Thanks. I assume you're on Windows?

    I'll try applying the noise texture using straight MDL and see where that gets me. 

  • jag11jag11 Posts: 885
    Esemwy said:
    jag11 said:

    Didn't crashed either.

    OK. Thanks. I assume you're on Windows?

    I'll try applying the noise texture using straight MDL and see where that gets me. 

    W10-64.

  • ToborTobor Posts: 2,300
    edited September 2015

    I'm afraid my inexperience with shader bricks has me at a disadvantage here, so the only thing I can test is if it crashes -- and yes, I'm on Windows. I'm going to need to educate myself a little more about these brick things.

    I'm guessing the MDL Callable entry is able to take values from the Perlin Noise Texture brick, and use those to pass to the surface, as that brick doesn't otherwise have an output. Have not seen this before, so something new every day! (I am guessing here. The output of the shader doesn't do anything on my system, even when I've placed the MDL in the roper paths, and added its own in the Directory Manager. Will keep at it...)

     

     

    Post edited by Tobor on
  • Arnold CArnold C Posts: 740
    edited September 2015

     

    Tobor said:

    Not sure if this comment was in response to my sample at the top of the page, ...

    No, sorry, this was aimed at Esemwy's code example. Seems I accidentally deleted the quote block. blush Corrected that.

    Tobor said:

    Wrong file -- that's the MDL. There's no copyright preamble to the IrayUber DUF, or DBMs generated from existing assets. I'm wondering if it's the same as file with a morph controller that contains the original morph.

    Since the IrayUber seems to been build up from the MDL, I assume that in that case the DAZ Script EULA will be applied. As if I got that right from what has been posted in other threads in the forum, as long as you don't include any original geometry files and/or textures, or derivates of those, material/shader/whatever presets will fall under the Script EULA, and you're allowed to share them.

    But now to something completely different:

    If someone is interested, there is a pack of MDL examples available in the Material Definition Language examples for automotive thread at the NVIDIA Advanced Rendering Forum, including several for carfabric, carglass, artificial carleather (that's would be a new one), carmetal, carpaint, carplastic, carrubber, carwood, etc and textures. Thought to be used mainly for cars hence the directory namings, but one or the other could be useful elsewhere, too, though I guess. smiley

    Post edited by Arnold C on
  • EsemwyEsemwy Posts: 578

    I think I've reached some limit in my brain. Can anybody see what's going wrong here? 

    mdl 1.1;import df::*;import math::*;import anno::*;import base::*;export base::texture_return noise(    uniform float size = 0.02,    uniform int noise_levels = 4,    base::texture_coordinate_info uvw = base::texture_coordinate_info()) {    color result = base::perlin_noise_texture(        color1: color(1),        color2: color(0),        size: size,        noise_levels: noise_levels,        uvw: uvw    ).mono;    return base::texture_return(        result,        math::luminance(result)    );}export material basic_volume(    uniform float ior = 1.0002772,    uniform float abbe_number = 89.30,    uniform color absorption_coefficient = color(0),    uniform float size = 0.02,    uniform int noise_levels = 4)= material (    ior: base::abbe_number_ior(        ior: ior,        abbe_number: abbe_number    ),    surface: material_surface (        scattering:    df::specular_bsdf(            tint: color(1.0, 1.0, 1.0),            mode: df::scatter_reflect_transmit        )    ),    volume:  material_volume (        scattering: df::anisotropic_vdf(),        absorption_coefficient: absorption_coefficient,        scattering_coefficient: noise(noise_levels: noise_levels, size: size).tint    ));

    I hoped to get a noisy cube, but I got nothing.

  • EsemwyEsemwy Posts: 578
    Tobor said:

    I'm afraid my inexperience with shader bricks has me at a disadvantage here, so the only thing I can test is if it crashes -- and yes, I'm on Windows. I'm going to need to educate myself a little more about these brick things.

    I'm guessing the MDL Callable entry is able to take values from the Perlin Noise Texture brick, and use those to pass to the surface, as that brick doesn't otherwise have an output. Have not seen this before, so something new every day! (I am guessing here. The output of the shader doesn't do anything on my system, even when I've placed the MDL in the roper paths, and added its own in the Directory Manager. Will keep at it...)

    Tobor, it sounds like you have the general idea. If you need more specific information, I posted a general tutorial a while back on working with MDL and Shader Mixer. It's here. Everything I've learned about Shader Mixer is from Carnite on Youtube

  • jag11jag11 Posts: 885

    If you rise the absorption coefficient to color(0.02) you'll see inside the cube but no noise. I think the scattering_coefficient ignores dynamic texture values I think iray uses the same scattering value for all volume.surprise

  • Arnold CArnold C Posts: 740
    edited September 2015

    On the first glance, I'd say you can't use a texture on the scattering_coefficent. It's the product of a color (as float) divided by a given distance.

    scattering_coefficient: noise(noise_levels: noise_levels, size: size).tint

    I can make out, that you have defined "noise_levels", "size" and "tint", but cant find "noise" anywhere. Ant the dot "." in front of "tint" doesn't belong there, too., I guess. It could also be, that the scattering coefficient will only work with a monochromatic color.

    And I guess it can't make sense of the (noise_levels: noise_levels, size: size) part. They are already uniform, so it's IMO unneccessary to define them again. (noise_levels / size) would make more sense I guess. Any operation like multiplying, dividing, add or subtract.

    Post edited by Arnold C on
  • ToborTobor Posts: 2,300
    jag11 said:

    If you rise the absorption coefficient to color(0.02) you'll see inside the cube but no noise. I think the scattering_coefficient ignores dynamic texture values I think iray uses the same scattering value for all volume.surprise

    This is my thought as well. The function for setting the coefficient is read just once, not for every pixel. Though it may not be physically-based, what if the texture plugs into the refraction node? That map is read for each pixel of the volume.

    Esemwy, I'll check out those videos. You have to play her stuff five times to take it all in. She packs a LOT of information in there! Her tutorial on using D-formers was the one that finally got me over the logjam in using them. 

Sign In or Register to comment.