Iray accessing the RGBA channels of an image

In game development we combine multiple grey scale images such as opacity, roughness, glossiness and ambient occlusion to the RGBA channels of a single image.

So R = roughness, G = glossiness, B = ambient occlusion, A = opacity.

Doing this saves a lot of graphics memory and drive space but does not appear to be utilized in Daz that I can tell.

for those of you that are into creating custom iray materials. Can you access the separate RGBA components of an image in an iray shader / material?

Comments

  • margravemargrave Posts: 1,822
    You might be able to do something like that using the Shader Mixer, but due to Daz Studio's legendary lack of proper documentation, I (and I assume many others) don't know much about how it works. You'd probably need some kind of RGB splitter, like in Blender's Shader Editor.
  • ForceXForceX Posts: 52

    Thanks for the reply. I've looked at the shader mixer it's, interesting... searching for a node type is not a pleasant experience. I'm sure if Daz has a splitter it would just copy the image nTimes and negate the benefit of using a single image.

  • ebergerlyebergerly Posts: 3,255
    edited April 2021

    Not sure if this is what you're looking for, but FWIW I've always been extremely impressed at the incredible functionality in DAZ Studio, and the Shader Mixer is just one of those amazing things. Not sure how many people actually use it, but anyway...

    Some general thoughts:

    First, you can limit the search for bricks to only the Iray/MDL-related bricks by selecting from the "Language Filter" dropdown on the list of bricks. That cuts down the stuff you have to wade thru from 1.36 million to only a couple hundred thousand laugh

    Also, there is a whole list of nodes (the correct term, not 'bricks") called Accessors, and those may hold the key for what you're trying to accomplish. Though honestly I'm not sure why you're looking to do this in D|S rather than something like Nuke, where this kind of stuff is easy.

    Shader Mixer has a bunch of nodes that are basically "getters" (as in C# and other languages) that allow you to extract properties and stuff.

    So I started by adding the all important User Parameters node where I defined that I wanted the input color to be a jpg image. Then I grabbed three "Float3 Get" nodes (X,Y, and Z), and took the output of the User Parameters as input to those. It seems that those nodes extract the 3 float RGB values from the color output.

    They also have a "Color 3 Inputs" node that takes the RGB/XYZ colors I just separated and re-combines them again into a color channel. I then apply that to a Simple Diffuse shader node, then to the final MDL Surface that applies it to the scene object surface. 

    And it seems to apply the image to the surface, and shows up in the OpenGL preview, though not the Iray for some reason. 

    I'm sure there's one or more errors in the node setup I used, but at least it might help get you going. 

    Also, if you do decide to mess with the Shader Mixer, don't forget to, once you have your nodes set up, make sure you select the scene object you want to apply it to, AND select the appropriate Surface you want to apply it to, AND hit the Apply button on the bottom right.

    Also, if you search for the NVIDIA MDL manual it might help understand what's going on in MDL. But for me the basic workflow is to add a User Parameter node, which allows you to define all aspects of the material/surface, and also add the all-important MDL surface node (which applies whatever you've made to the surface) as well as an appropriate MDL material node (such as the PBR Specular or Metalicity Base nodes, which have everything you could ever need to define your surface). 

    And if you just want to get a feel for how to design a shader, just go to File/New Shader, and it will give you a ready-to-go (and fairly complex) default shader that you can study. 

    MDL.JPG
    1478 x 774 - 76K
    Post edited by ebergerly on
  • ebergerlyebergerly Posts: 3,255

    Here's another tweak to my node setup, and in this case I added a multiply node on the Blue channel, with a plaid input jpg image (which I moved to its own "Texture Instance" node, and that seems to make it show in the Iray preview).

    After I extract the RGB float values from the texture input I run it thru a Multiply node, which multiplies the X and Y inputs. The Y input is a User Parameters node, where I added a Float parameter, which shows up as a slider in my Surface that you can adjust -100% to 100%. So basically it allows me to subtract any blue from the image. 

    So here's the node setup, the original blue plaid texture, and the resulting Iray render with the slider set near 0%.

    MDLNew.JPG
    1524 x 901 - 83K
    Blue.JPG
    278 x 262 - 22K
    Yellow.JPG
    854 x 739 - 45K
  • ebergerlyebergerly Posts: 3,255
    edited April 2021

    Also, if you find that needing 3 nodes (Float3 Get X, Float3 Get Y, and Float3 Get Z) just to extract RGB a bit annoying, once you have them set up you can drag-select them, then go to the top left Shader Mixer menu items, and under Edit choose Group Selected Nodes and it will squish them into one nice clean node (see below). You can also save that grouped node as a custom node/brick, and just load it later when you need it.  

    And as a side note, one thing that I've always wished for in Nuke is the ability to convert the Iray EXR files which are not normalized (0-1 pixel values), but rather 0-infinity, into normalized values for use in Nuke and other software without going crazy in the process. Suprisingly, the Shader Mixer has a couple of "normalize" nodes that seem to do the trick. Wow. Although I haven't spent much time investigating, but still, for an app like D|S to have these features is mind boggling. I guess it's mostly NVIDIA Iray, but still for D|S to include interfaces for all that is impressive.

    FloatUnGroup.JPG
    283 x 690 - 27K
    FloatGroup.JPG
    306 x 388 - 16K
    Post edited by ebergerly on
  • In Daz Studio "node" refers to an item in the scene. The correct term for the units in the Daz Studio Shader Mixer is bricks. Using non-standard terms is not going to help people understand your explanation.

  • ForceXForceX Posts: 52
    edited May 2021

    @ebergerly : Thanks for your reply and examples. You are correct they are called Nodes. Just because Daz decides to call a flower a dog doesn't make the flower a dog. It's still a flower, and a node is still a node. That's why it's called a node based editor in "Every" other software.

    @Richard Haseltine: "Using non-standard terms is not going to help people understand your explanation."

    This is absolutely correct, Daz should really standardize. 

    Post edited by ForceX on
Sign In or Register to comment.