Q100407: Apply Blend Modes faster by use of caching

Follow

SUMMARY

In Mari 3.3v1 and earlier, changing the Blend Mode could sometimes be quite an arduous process, as the shader would need to recompile. This article explains how you can use Blend Mode caching to improve performance and reduce the number of shader recompilations needed in Dynamic mode.

 

 

MORE INFORMATION

The Dynamic Shader Compilation mode improves shader compilation speeds at the cost of being a rather heavy shader. Whilst this Dynamic mode cuts down compilation rates by caching multiple operations, some artists still regularly encounter shader recompilation when switching between different Blend Modes.

As of Mari 3.4v1, Blend Modes are included within the Dynamic caching system in order to reduce the number of recompilations taking place. In Dynamic mode, if a user changes the Blend Mode of a layer, Merge node, or of the Paint Buffer, there should be an immediate change rather than having to wait for the spinning wheel to complete in the viewport.

The caching system supports a ‘history’ of five Blend Modes that the artist is able to use without running into recompilation. 

NOTE: For more information on Blend Modes please see the Paint Blending Modes section of our Mari Online Help.

NOTE: The default Shader Compilation mode is Automatic, which is ideal for most Mari sessions, as it uses both Dynamic and Optimised modes as needed.

 

 

HOW TO ADJUST CUSTOM NODES TO BENEFIT FROM BLEND MODE CACHE STATES

Developers who are using Blend Mode attributes within their custom nodes may have the following, or similar in their custom node XML:
 
 <Attribute Name="BlendMode" PrettyName="Mode" Group="" Type="userenum">Dynamic:  MriBlendMode:Comp_Default</  Attribute> 
 
In order to use Blend Modes, a developer has two possible options:
  1. Dynamic:MriBlendMode:Comp_ Default  For normal blend mode type (all modes).
  2. Dynamic:MriBlendModeNoAlpha: Comp_Default  -  For type that does not contain any alpha blend modes.
Additionally, in order to add support for the quicker compilation Blend Modes, the XML file will need to be modified to enable these changes, like so:
 
Before:

Output = $BlendMode(_Base, _Over, #Mask.r * AdvancedBlendAmount);
 
After:
 
#if defined(MRI_GENERAL_COMPOSITION)
Output = Comp_General($BlendMode, _Base, _Over, #Mask.r * AdvancedBlendAmount);
#else
Output = $BlendMode(_Base, _Over, #Mask.r * AdvancedBlendAmount);
#endif // defined(MRI_GENERAL_COMPOSITION)

 

 

FURTHER HELP

If you are experiencing difficulties please create a support ticket and provide us with the information requested in this article:
Q100090: Information to send Support when reporting a Mari issue

For more information on how to open a Support ticket, please refer to this article:
Q100064: How to raise a support ticket

    We're sorry to hear that

    Please tell us why