3D Comic Rendering
Oliver Vainumäe (superv. Santiago from Artineering)
Hello! Welcome to the wiki page of this project.
Introduction
In this project I will be learning and working with MNPR while implementing a non-photorealistic rendering style for 3D scenes in Autodesk Maya. The style will include parameters within Maya to let artists customize the rendering style.
Autodesk Maya
https://www.autodesk.com/products/maya/overview
Autodesk Maya is an industry-standard 3D modeling, animating and rendering application. Maya runs on Linux, Windows and macOS. Maya has been used to create assets for movies, games, architecture and personally I've even used it to create assets for digital paintings.
MNPR
https://github.com/semontesdeoca/MNPR
MNPR is a non-photorealistic rendering framework for Autodesk Maya. It provides artists with styles, which alter the way Maya renders scenes. MNPR is written in C++, Python, GLSL and HLSL.
Shaders written in HLSL are used in Windows operating systems while GLSL shaders are used in other operating systems.
Thesis
My project topic is related to my thesis topic.
For my thesis, I am creating a style for MNPR, which would resemble the graphic novel La memoire de l'eau or Water Memory in English. With this project I hope to learn to use and modify MNPR, so that I would have easier time implementing my thesis rendering style.
Results:
I have modified MNPR to include a rendering style called "Water Memory". This style is meant to be used in my thesis and in this project. Even though the name of the style is the name of the graphic novel, in this project I implemented Cel Shading in this style.
I have also familiarized myself with MNPR and understood some of its ideas and problems. I find that the knowledge I've gained is very beneficial, when it comes to my thesis. I know where to find some of the buffers that are essential to implementing a new style and I also know where and how I need to edit the code in order to implement my ideas. For example I know that there are seperate buffers for the colors of objects, diffused light and specular reflections or I know which part of the code I must change to have Maya provide parameters to users.
My Cel Shading style:
My Cel Shading style alters the way object surfaces are rendered and adds outlines around some areas of the objects.
My Cel Shading surface shading implementation utilizes 3 light reflection thresholds: High, Mid and Low. Each of those thresholds are selected based on the sum of diffused and specular light reflections. I decided to use just 3 thresholds, because I found already 2 to be enough to get a nice Cel Shading look and the third threshold could be used for specular reflections.
Each threshold sets the intensity of the light, which the color is multiplied with right before being output by the fragment shader.
Outlines are calculated with the help of Difference of Gaussians (DOG) edge-detection method, which is already implemented in MNPR. The DOG edge-detection method was used together with color buffer and depth buffer, but in this style I used depth buffer instead of color buffer. The result was that there were no excessive outlines, which would be calculated because of shadows that Maya rendered into color buffer. Meanwhile the outlines would be present between between two surfaces if their distances were big enough. A downside of this is that if a texture contains some of the detail in the scene, then that texture wouldn't have the style-provided outlines at texture-based details.
Unfortunately the outlines are very thin. This however could be fixed if the outlines were to be blurred a bit. Also changing the depth range in MNPR configuration can help.
I provided some parameters to customize the way this Cel Shading works:
- Parameters for the High and Mid threshold requirements.
- Parameters for the High, Mid and Low threshold intensities.
- Parameters for coefficients for specular and diffused light reflections in the sum, which determines the threshold.
- Parameter for the power of specular light reflections.
- Parameter for outline opacity.
- Parameter for the power of the outline. Unfortunately this doesn't really affect the style much.
This style also makes use of the substrates in MNPR.
Problems:
- No scene rendering other than by Maya itself.
It might have been just me, not finding it, but it seems that MNPR provides no way of rendering Maya scenes with your own pipelines. MNPR seems to let Maya render the scene into multiple buffers such as color, depth, diffused light and specular reflections. This confused me a lot and I couldn't really understand how I am to implement any rendering style with MNPR. This problem is partially solved by the fact that Maya scene renderer outputs multiple different buffers. - No Normals buffer.
I spent a some time looking for this buffer and couldn't find it. I even tried to get a normal buffer out of depth buffer, but ran out of time and couldn't really fix the issues I had while implementing it. There is a commented out code line, which adds the normals buffer rendering target, but even if I uncomment it and add it to the output targets of Maya scene renderer, the buffer will remain unused. - Unfamiliar code writing style.
I haven't really ever had to read much unfamiliar code. Since MNPR wasn't developed by me, I got to read some code, which was written in a style that I am unfamiliar with. To remedy this, I changed a lot of already existing code and made it a bit more readable to myself. This helped me recognize the functionalty of the code in different files and areas. One of my big issues were long code lines and I spent a lot of time splitting them into readable multi-line statements. I also found some areas where additional functions/methods came in handy. For example when giving shader techniques buffer parameters, the buffer index was first found and then indexed. Here I replaced the code with a helper function, which did both of these things at once and this made code lines shorter and more readable for myself. - Visual Studio just isn't for me.
I spent a while trying to understand why Visual Studio doesn't want to let me copy files in the project. After a while I gave up and just used the file explorer of my OS to copy files.
I also spent a while trying to customize Visual Studio to have shortcut keys that I used in JetBrains IDEs and also changed the way code file formatting worked. Since this is my first time really using Visual Studio, it took me a while to find all of the settings and to get through the confusing structure of settings. - Multiple IDEs in use.
This isn't all too big of an issue, but it still makes things a bit harder. For some reason, whenever I open a Python file in Visual Studio, the whitespace gets somehow messed up and Maya cannot interpret the script files anymore. Instead of Visual Studio, I use PyCharm and I have no issues with that IDE. - Maya crashes and loading it up again takes a while.
This just slows down my working process and distracts me.
Result Showcase video:
Repository
https://github.com/Yleroimar/3D-Comic-Rendering
The repository contains files from the MNPR repository. I decided to include them for now, because I needed to modify some already existing MNPR files and this way it is easier to set up the project for both me and others.
Required tools
- Autodesk Maya 2019.2
- Visual Studio 2017 Community
- CMake
Setup guide
Prequisites
- Make sure you have the required tools. CMake needs to be in PATH.
- Get the project repository and place/extract it wherever you want.
Building from the project repository source
There is a detailed guide on this in the MNPR repository readme, but I'll give some basic steps for Windows users, which might not work for everyone.
- Go to the plugins folder of the newly extracted source.
- Run _buildWindowsDebug.bat.
- Enter "2019" and press ENTER.
- Press ENTER.
The project should now have been built and is ready to be opened in Visual Studio and Maya.
Opening the project in Visual Studio
- Go to plugins/build and open MNPR.sln with Visual Studio.
You should now see the project files (in the confusing manner Visual Studio does it)
Using MNPR in Maya.
- Open Maya.
- Drag the install.mel to the open Maya window and wait a little. Some windows may pop up asking for confirmation. You will probably figure out what to do with those.
- Close and reopen Maya.
You should now see the MNPR and/or MNPR_DEV tab on the shelf. You can get a little default scene by pressing the blue ball with "test" text. The plugin usage in Maya is way more detailed over here: https://mnpr.artineering.io/tutorials