Blending Multiple Shaders

   Views 1720   Replies 5   Subscribers 1
User Avatar
Member
65 posts
Joined: Aug. 2015
Offline
Hello SideFX,

I think I found a bug where multiple shaders are not able to layer when using two Mtlx Mix nodes.

Here's the situation:

I'm creating a large environment that features salt flats:



And I want to add some snow on top of these mountains using a layered shader approach.

At the moment, I am accomplishing the transition between the salt / mountain areas using a Mtlx Mix node:



The mix is determined by a point attribute that is set in SOPs.

When I try adding another mix like this, everything will render white no matter what I do. In this example, I tried troubleshooting it by making my snow shader red. As you can see, it will revert to a white color no matter what:



As far as the mix attribute goes, I checked on this in SOPs as well:



And I double checked the signal with an unlit shader to make sure this information came through.



So... I'm pretty sure that this situation is bugged. Is there any other alternative that I can use to layer on a snow shader in the meantime?

I don't have time to upload the scene file, but I'll make sure to add a bug report.


Thanks,

- Tyler

Attachments:
saltFlatsTest_v5.jpg (261.6 KB)
saltFlatsTest_v6.jpg (52.2 KB)
saltFlatsTest_v7.jpg (149.5 KB)
saltFlatsTest_v8.jpg (128.0 KB)
saltFlatsTest_v9.jpg (138.7 KB)

User Avatar
Member
67 posts
Joined: June 2022
Online
In XPU you cant blend more than two shaders, here is topcirelated to this https://www.sidefx.com/forum/topic/93069/ [www.sidefx.com] . However I dont really understand why this is that big deal when you can mix masks before pluging them into shader. I'm always working like that and its more reliable (Yeah, maybe a little bit more inconvenient but more physically accurate)
Edited by sniegockiszymon - Dec. 1, 2023 11:39:22
User Avatar
Member
65 posts
Joined: Aug. 2015
Offline
sniegockiszymon
In XPU you cant blend more than two shaders, here is topcirelated to this https://www.sidefx.com/forum/topic/93069/ [www.sidefx.com] . However I dont really understand why this is that big deal when you can mix masks before pluging them into shader. I'm always working like that and its more reliable (Yeah, maybe a little bit more inconvenient but more physically accurate)

Hey, thanks for the reply,


When you say, "mix masks before plugging them into shader" I'm not understanding you there yet. In this scenario, I have the salt flats, mountain, and snow shaders that need to layer on top of each other. Each of those shaders require something different for the diffuse, spec roughness, normal, and displacement parameters. So in my mind, that's why you would need to mix the shaders after they've been defined rather than before.

But, perhaps I don't understand what you're thinking quite yet.
User Avatar
Member
67 posts
Joined: June 2022
Online
Yeah but you can mix those different diffuse/roughness etc before pluging them into shader. For exmaple I'm creating here blending between image textures (3 red nodes, for albedo,rgh and disp) with my second, procedural ice material, and everything is mixed before pluging them into one shader (because it has transmission it wasnt that easy, but its for another topic) generally mixing shader is good for "hard" transitions, like leafs and branches etc but when values are between 0-1 mixing shaders might work strange. The biggest advantage of mixing shaders is when you have to mix different ones (then its really only option) but if you are using everywhere standard surface then there is no need for blending shaders.
Edited by sniegockiszymon - Dec. 1, 2023 13:25:15

Attachments:
Screenshot 2023-12-01 183856.png (149.3 KB)
Screenshot 2023-12-01 183707.png (885.4 KB)
Screenshot 2023-12-01 192232.png (642.6 KB)

User Avatar
Member
65 posts
Joined: Aug. 2015
Offline
sniegockiszymon
Yeah but you can mix those different diffuse/roughness etc before pluging them into shader. For exmaple I'm creating here blending between image textures (3 red nodes, for albedo,rgh and disp) with my second, procedural ice material, and everything is mixed before pluging them into one shader (because it has transmission it wasnt that easy, but its for another topic) generally mixing shader is good for "hard" transitions, like leafs and branches etc but when values are between 0-1 mixing shaders might work strange. The biggest advantage of mixing shaders is when you have to mix different ones (then its really only option) but if you are using everywhere standard surface then there is no need for blending shaders.


Ahh okay I gotcha. Thanks for sharing, I'll use that trick for getting around it. I usually go about it by doing this sort of thing in Redshift because it avoids a pileup of nodes:



But, I set up Karma in the way you mentioned, and it's looking great now.



So thanks again for the help!


Have a great day,

- Tyler

Attachments:
saltFlatsTest_v10.jpg (37.7 KB)
saltFlatsTest_v11.jpg (242.5 KB)

User Avatar
Member
8114 posts
Joined: Sept. 2011
Offline
tbay312
Ahh okay I gotcha. Thanks for sharing, I'll use that trick for getting around it. I usually go about it by doing this sort of thing in Redshift because it avoids a pileup of nodes:

Something karma/mtlx could use is a parameter struct. This would allow for blending parameters rather than materials while keeping the network simple. In some cases like those mentioned above, blending materials is really the only way to get a realistic result, but for many situations blending the parameters is satisfactory and will probably perform better.
  • Quick Links