Do multiple AiMixShader's get merged?

Do multiple AiMixShader's get merged?

zenop
Advocate Advocate
1,246 Views
4 Replies
Message 1 of 5

Do multiple AiMixShader's get merged?

zenop
Advocate
Advocate

When mixing multiple aistandardsurface shaders through the aimixshader nodes, do they get merged to a single shader at shading time? Can anyone shed some light on the optimisations arnold uses behind the hood?

0 Likes
Accepted solutions (1)
1,247 Views
4 Replies
Replies (4)
Message 2 of 5

Stephen.Blair
Community Manager
Community Manager
Accepted solution

The shaders are not merged, but closures have an efficient mix op, so the returned BSDFs are mixed after. Plus things like diffuse BSDFs are cached so they aren't evaluated multiple times in the same shader network. That's roughly how it works.



// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 3 of 5

zenop
Advocate
Advocate

Sweet, that's ideal. I haven't had the time to test the speed results yet - but would you guess be that the internal closure mixing would make a custom merging tool obsolete? Since everything is slider based I was thinking of writing something that merges mix shaders into a single surface shader.

0 Likes
Message 4 of 5

Mike_Farnsworth
Not applicable

I wouldn't bother with a custom merging tool. In the future, we're fairly likely to convert many (if not nearly all) built-in shaders to OSL, and so even the multiple-node overhead will for the most part go away at that point. You already get most of the benefits of closures being combined already with mix_shader.

Note that you can combine C++ and OSL shaders in the same shader network, no problem; but when there are larger groups of OSL nodes together they will optimize among themselves and be more efficient. As we move more to OSL shaders, you'll automatically get this benefit.

0 Likes
Message 5 of 5

zenop
Advocate
Advocate

That's brilliant Mike, the ideal case scenario. Cheers for the explanation.

0 Likes