MNPR
MNPR is an expressive non-photorealistic rendering framework for real-time, filter-based stylization pipelines within Maya.
Install / Use
/learn @semontesdeoca/MNPRREADME
For a production-ready version of MNPR, please refer to MNPRX
MNPR
MNPR is an expressive non-photorealistic rendering framework for real-time, filter-based stylization pipelines within Maya (2016.5+). It extends the Maya API and simplifies the creation of Viewport 2.0 render overrides, while still preserving all the low-level options that the Maya API provides.
The framework was originally created by Santiago E. Montesdeoca during his PhD studies at the Nanyang Technological University (Singapore), as a product of his conducted research in:
His research was supervised in Singapore by Hock Soon Seah, Hans-Martin Rall and Davide Benvenuti, joined later with supervision in France from Joëlle Thollot, Pierre Bénard and Romain Vergne.
MNPR is now open-sourced under the MIT-license through the publication:
Valuable contributions coding MNPR were given by:
- Pierre Bénard
- Amir Semmo
- Yee Xin Chiew
Downloading MNPR
For animated projects, please refer to the actively maintained MNPRX.
The latest stable release of the MNPR prototype can be found here (Maya 2017 and 2018):
Building from source
The easiest way to build MNPR is using CMake, just make sure cmake is added to the system PATH.
If you've never built anything with CMAKE, please consider watching Chad Vernon's Compiling Maya Plug-ins with CMake tutorial.
Windows
Simple: Double click on the _buildWindows.bat file under plugins and follow instructions.
Advanced:: Open the command prompt (or PowerShell) and run the following commands
cd %MNPR_LOCATION%/plugins/build/
cmake ../ -G "Visual Studio 15 2017 Win64" -DMAYA_VERSION=%YEAR%
cmake --build . --config Release
You need to replace %MNPR_LOCATION% and %YEAR% with the location of MNPR on your computer and the Maya version year, respectively. You can also choose to build with Debug configuration, which enables the MSVC debugging tools.
Note: When building with Release configuration, the shaders need to be built, as well. Run or refer to the _compileHLSL.bat to compile the HLSL shaders.
MacOS
cd %MNPR-LOCATION%/plugins/build/
cmake -G "Unix Makefiles" -DMAYA_VERSION=%YEAR% %MNPR-LOCATION%/plugins
cmake --build . --config Release
You need to replace %MNPR_LOCATION% and %YEAR% with the location of MNPR on your computer and the Maya version year, respectively.
Linux
cd %MNPR-LOCATION%/plugins/build/
cmake -G "Unix Makefiles" -DMAYA_VERSION=%YEAR% %MNPR-LOCATION%/plugins
cmake --build . --config Release
You need to replace %MNPR_LOCATION% and %YEAR% with the location of MNPR on your computer and the Maya version year, respectively.
Stylization Semantics
Visual effects in non-photorealistic rendering can be generalized into four distinct categories:
- Pigment-based effects
- Substrate-based effects
- Edge-based effects
- Abstraction-based effects
These four groups can be used to directly correlate the stylization control parameters between different styles, using common semantics. The semantics need to be sufficiently generic, yet semantically meaningful to be adapted to different styles and accepted by the NPR development community. Additionally, these effects need to adhere to a control scheme, which defines what semantics goes to which channel in the stylization map---so that these can be interpreted by other styles.
The stylization control parameters are rendered by the MNPR object-space shaders into stylization maps, representing each effect group and following the following control scheme:
| Channel | Pigment-based effects | Substrate-based effects | Edge-based effects | Abstraction-based effects | |---------|-----------------------|-------------------------|--------------------|---------------------------| | R | Pigment variation | Substrate distortion | Edge intensity | Detail | | G | Pigment application | U-inclination | Edge width | Shape | | B | Pigment density | V-inclination | Edge transition | Blending |
Stylization pipelines supporting the same effect categories, respecting the semantics and following the control scheme, would enable e.g., to map an art-directed rendering in a watercolor style to an oil or charcoal style.
Effect semantics, explained
Pigment-based effects
- R: Pigment variation, controls the degree at which the reflected color of a pigment deviates towards one or another color. E.g., green pigmentation that deviates to a more blue or yellow color in certain parts.
- G: Pigment application, controls how the pigment is placed over a substrate. This can be interpreted as the amount or pressure at which pigment is applied to achieve an effect. E.g., dry-brush application, thick application.
- B: Pigment density, controls the concentration of the pigment placed over a substrate. This is especially relevant to transparent and translucent media ( i.e., watercolor, ink, colored pencils), but can also influence opaque media. E.g., dilution, lightness, saturation.
Substrate-based effects
- R: Substrate distortion, controls the distortion caused by the substrate roughness on the rendered image. This is especially relevant for fluid media (i.e., watercolor, graffiti).
- G and B: U-inclination and V-inclination, control the inclination of the substrate, which generally affects the direction at which patterns or marks from fluid media evolve. However, generalizing upon this, these parameters are used to define the offset of existing patterns or marks in a horizontal or vertical direction. E.g., bleeding direction, cross-hatching direction, stroke direction.
Edge-based effects
- R: Edge intensity, controls the edge strength/intensity within the stylized render. E.g., linework darkness, edge darkening.
- G: Edge width, controls the edge thickness of the stylized render. E.g., linework width, edge darkening width.
- B: Edge transition, controls the edge transition of the subject in relation to neighboring elements. E.g., edge softening, gaps and overlaps.
Abstraction-based effects
- R: Detail, controls the amount of detail at different parts of the stylized render within the subject. E.g., detail blur.
- G: Shape, Controls the amount of shape abstraction/distortion of the subjects. E.g., hand tremors.
- B: Blending, controls the color blending at different parts of the stylized render. E.g., smudges, color bleeding.
By adhering to these semantics throughout the stylization pipeline, art-directed scenes can predictably change style and, for the most part, keep the intended effects and look of the expressive render. While these semantics are neither final, nor applicable to all styles and effects, they provide a starting point to address cross-stylization paradigms in expressive rendering.
Modifying MNPR
Creating your own stylization pipeline is quite straightforward, but it's best to learn by doing and taking a look at how existing stylizations are made. Here is a small breakdown of how things are set up in MNPR.
Please also read the Coding Guidelines and the Tips & Tricks
Add style to Framework
- Add style string to STYLES global variable (mnpr_renderer.cpp)
- Add your style as the default value in the engine settings (mnpr_renderer.h)
Create your stylization pipeline
- Copy and rename a style file (e.g., style_watercolor.hpp -> style_crosshatching.hpp)
- Adapt the new style source file
- Change to a custom namespace
- Add the desired render target(s)
- Add the desired render operation(s)
- Add switch clause in addCustomTargets() and addCustomOperations() (mnpr_renderer.cpp)
Create custom attributes in the config node
- Add attributes as engine settings (EngineSettings) or effect parameters (FXParameters) (mnpr_renderer.h)
- Copy and rename the node_watercolor.hpp file e.g., node_crosshatching.hpp
- Adapt the new node source file
- Add MObject representing the new attribute(s)
- Change to a custom namespace
- Initialize the attribute(s) in initializeParameters()
- Parse attribute(s) in computeParameters()
- Add switch clause in initializeCustomParameters() and computeCustomParameters() (mnpr_configNode.cpp)
Add a flag to the mnpr command
- Add short name and long name strings (mnpr_cmd.cpp)
- Add flag to newSyntax()
- Parse command in doIt()
Create your custom quad shaders
- Copy and rename a shader file (e.g., quadBlend10.fx -> quadHatch10.fx)
- Write your fragment shader
- Create a technique that uses your fragment shader
Note: as MNPR evolves and more stylizations are implemented within it, more shaders will be available for general use. Try to always reuse existing shader code, as this will enable you to iterate faster towards your stylistic goals.
Creating mapped and material effect control widgets for paintFX and noiseFX
- Open mnpr_FX.py and carefully read the schema
- Define your MNPR_FXs in the
getStyleFX()function - Add the switch clause at the bottom of the
getStyleFX()function - Double click on pFx and nFx buttons in the shelf to reload the python file and UI
Coding Guidelines
Some brief coding guidelines for the framework to have a con
