Introduction

nb_MariTools is a mix of additions to the Foundry's Mari that should help your texture workflow.  More features will be added as the Mari Shader API evolves but here is what is included in the 1.0 release:

Shaders

  • Architectural
  • Reflection & Refraction
  • Oren & Nayar Diffuse
  • Ward Isotropic Specular
  • Ward Anisotropic Specular
  • Development

Normal Map Blending

  • RNM Normal Maps
  • RLV Normal Maps
  • UDN Normal Maps

Procedurals

  • Super Ellipse 2D
  • Super Shape 2D
  • Weave
  • Dots
  • Stripes

Installation

1. DOWNLOAD - Please read the entire project page before installation.

2. Place nb_MariTools.py and the nb_MariTools folder inside your Mari scripts directory.

  • Windows Default: C:\Users\username\Documents\Mari\Scripts\
  • Linux & Mac Default: ~/Mari/Scripts/

3. Mari's Shader API does not directly support custom blend modes so you need to edit the Merge.xml file inside your Mari installation directory.  The shaders and procedurals work fine without performing this step.  Edit at your own risk and remember to reapply this update after any future Mari upgrades.  BACK UP YOUR ORIGINAL FILE.

  • Windows Default: C:\Program Files\Mari2.5v2\Bundle\Media\Nodes\Simple\Layer\Merge.xml
  • Linux Default: ~/Mari2.5v2/Bundle/Media/Nodes/Simple/Layer/Merge.xml
  • Mac Default: ~/Applications/Mari2.5v2/Contents/Media/Nodes/Simple/Layer/Merge.xml

4. In the <Attribute Name="BlendMode" section add the following between Comp_AddRGBEncodedNormals, and Normal:

Comp_RnmRGBEncodedNormals,Comp_RlvRGBEncodedNormals,Comp_UdnRGBEncodedNormals,

5. In the same section, add the following after Add Normal Maps:

,RNM Normal Maps,RLV Normal Maps,UDN Normal Maps

Edited Merge.xml

Additional Information

  • Mari 2.5v2 Required
  • Please report any bugs or feature requests here.

Version History

  • 01/27/14 - 1.00 Initial Release
  • 02/09/14 - 1.01 Fixed OSX Reserved Word Error
  • 02/10/14 - 1.02 Fixed ATI issues on OSX
  • 02/11/14 - 1.03 Fixed more ATI issues on OSX
  • 02/12/14 - 1.04 Fixed displacement issues
  • 03/06/14 - 1.10 Fixed ATI issues on OSX, Updated RNM Normal Maps

Shaders

Architectural - This shader has almost all of the features of the Nvidia Mental Ray mia_material_x designed by Master Zap.  It is based on the 3Delight mia_material RSL code and adapted for Mari.  The implementation should be familiar to what you might have seen in Maya/3dsMax.  I included a Reflection & Refraction shader I created as a proof-of-concept.  The goal was to use an equirectangular (LatLong) HDRI to provide a view-independent (changes as your tumble the camera) preview of an environment and provide reflection & refraction.

Examples

Features

  • Energy Conservation: Diffuse + Reflection + Refraction <= 1.
  • Accurate reproduction of the mia_material_x specular lobe.
  • Ability to accurately preview reflections/refractions with an HDR image as a 'World Space' background.
  • Option to "Use Fresnel" or adjust the BRDF "Curve".
  • Anisotropy for brushed metal effects.
  • Extra controls like 'Specular Balance' and 'Additional Color' included.
  • Additive channel composite for more accurate results.

Limitations

  • 'Refraction Glossiness' and 'Reflection Glossiness' are approximations (require ray-tracing).
  • Linear workflow required (set Mari 'Color Management' to 'Linear').
  • 32-bit HDRI (should already be linear) is required for an 'Environment Map' to ensure correct Reflections & Refractions.
  • Translucency will be added in a future version.
 

Oren & Nayar Diffuse & Ward Specular - These BRDFs (bidirectional reflectance distribution functions) should be familiar to anyone currently working with Mental Ray, VRay, Arnold, etc. so I won't go into too much detail about them here.

Left: Oren & Nayar Diffuse, Middle: Ward Isotropic Specular, Right: Ward Anisotropic Specular

Development - I found it useful to be able to visualize the Mari Shader API MriFragmentState Struct Members while developing these shaders. It includes a few commonly used vectors and dot products as well.  Also, there are options to suppress values to better isolate the information you need.

Left: State.NormalInEyeSpaceFromViewCamera, Middle: State.TangentInEyeSpaceFromViewCamera, Right: State.UV


Normal Map Blending

Currently there are two methods to blend detail normal maps with a base normal map: 'Mix' and 'Add'.  I did some research and came across an amazing blog post called "Blending in Detail" by Colin Barré-Brisebois and Stephen Hill.  I highly suggest viewing the original post for the full explanation.  Here is a (very) brief summary and another example can be viewed here:

 

Methods like 'Mix' and 'Add' create a linear (or overlay type) blend of two normal maps, typically a base map with a detail map over-top.  Problem: You lose some detail in the process because you are using 2D math methodology on 3D normal data.  Solution: Use 3D math to "reorient" the normal of the detail map to the surface map and then combine.

 

Examples

Features

  • No detail loss.
  • Respects original geometry.
  • RLV Normal Maps or RNM Normal Maps are the recommended blend modes for working with multiple detail normal maps and a single base normal map.  Note: Previously RNM Normal Maps only worked with one detail and one base, this has been fixed.
  • UDN Normal Maps is regarded as the best of the "other" methods and is included for comparison.

Limitations

  • The Mari Shader API does not support custom Blend Modes.  Please see the installation documentation for instructions on how to install these.

Procedurals

Super Ellipse 2D - AKA the "Squircle", this looks like a rounded rectangle and is a good alternative for making tile patterns. The '2D' denotes the procedural works in UV Space.

 

Super Shape 2D - AKA the "Superformula", this is a "formula that can be used to describe many complex shapes and curves that are found in nature". The '2D' denotes the procedural works in UV Space.

 

Weave, Dots & Stripes - The dots & stripes are enhanced versions of the stock Mari procedural shaders.

 

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program.  If not, see www.gnu.org/licenses.