question

Zeno Pelgrims avatar image
Zeno Pelgrims asked ·

Do multiple AiMixShader's get merged?

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?

shadinglayeroptimisationaimixshader
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Stephen Blair avatar image
Stephen Blair answered ·

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.

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Zeno Pelgrims avatar image
Zeno Pelgrims answered ·

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.

2 comments Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

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.

1 Like 1 · ·

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

0 Likes 0 · ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.