In short: Paint just a specific nodepath whit cartoon shading and inking. Good to create interesting scene where only few objects look cartoonized.
- Apply cartoon shading and inking only to some of your scene objects.
- Change step function to customize the number of dark/bright regions and their relative contrast.
- Set camera spot light effect to have the shading directional light follow the camera movements.
Cartoon Painter can selectively apply cartoon shading and inking to specific nodepath of your scene. To achieve this effect it creates two extra display regions where the cartoonized nodepaths are drawn into. These regions are connected to two scenes called toon_render (for objects with toon shading) and inking_render2d (for the objects black outlines).
These regions has to be drawn before the main scene in render. You can adjust the sorting by setting the parameter in the constructor. The sort parameter is the sort value for the region of inking_render2d; the region of toon_render comes right after (sort - 1).
You can cartoon paint a model even when it’s deeply nested into any nodes hierarchy of your main scene. When you paint a nodepath you actually create an instance under toon_render. The original nodepath will be stashed but still retain its parents hierarchy under render and therefore its global transform. The CartoonPainter will take care of synchronizing position and rotation of the instances under toon_render.
Cartoon Painter comes as a Python package containing a CartoonPainter class and few shaders taken from cartoon shading Panda tutorial. The file shading.sha is a modified version of lightingGen.sha. It works not only with the model’s vertex colors but also with the flat color (if any). It takes three extra shader inputs to control the step function.
Comments and constructive critics are all welcome, especially about the shaders since I’m a noob at it. Enjoy and make the most out it!
*Cartoon shading doesn’t not apply to transparent models.
*Cartoon shading doesn’t not apply to textured models. It works only for vertex and flat colored models.
*Ink outlines are not affected by fog.
*A glgsg error is printed out when you exit your Panda script:(glGraphicsBuffer_src.cxx, line 1020: GL error 1282). Perhaps the normals buffer has to be destroyed before exiting?
*On my old machine with Intel integrated graphics card the CartoonPainter crashes my Panda script.
Thanks to Kwasi Mensah for making the cartoon shading advanced tutorial and to David for helping on display regions and tex buffers.