Example of toon shader for Cycles + OSL.
This includes two OSL scripts:
<ol>
<li>Toon shader using diffuse_toon() and specular_toon() closures</li>
<li>Single sided black surface used for toon edge</li>
</ol>
You can see some test videos in Youtube:
<ul>
<li>http://www.youtube.com/watch?v=WcQFs1opokI</li>
<li>http://www.youtube.com/watch?v=coYggqUHwDc</li>
</ul>
So maybe I just dont get it. There are two scripts. The Toon.osl, and the Edge.osl. How does one utilize both of those to create a simple "Cell Shaded object within blender?
When I opened up the example .blend file it has both in two separate text editor windows and one 3d view, and then the node editor.
I guess im confused on what the apply the "edge.osl" script to? Thanks ahead of time.
I didn't figured out, how he apply the edge texture so the edge becomes dark?
Hi,
The object has 2 materials assigned, one with the toon script and another with the edges script, since the edge script is only affected backfacing, you only see it on the polygons added by the solidifiy modifier.
By the way, these scripts aren't working on the current build : 2.67.1 r57177 the output is totaly black :/
More details : in fact only the toon shader isn't working, the error message is :
ERROR : Closure 'specular_toon' is not supported by the current renderer
Hi Alesk,
specular_toon() closure has been renamed to glossy_toon() in r56980, so you have to modify the OSL script and re-compile it if using latest trunk build.
specular_toon() closure became available again in svn r57362, so this .blend file should work with latest trunk build.
This is really awesome! Great work with this and thank you for sharing!
Hey I need a little bit of help I never done scripts before can someone walk me through on how to use his scripts and apply them to my character.
Thank You
specular_toon() was renamed to glossy_toon() (6 comments above) Just rename inside the script and reload inside of the script node.
If you can't get it to work even after renaming specular_toon() to glossy_toon(), follow the directions two paragraphs down at http://www.blendswap.com/questions/view/1705
Not sure if it's just me, but I also had to use CPU rendering rather than GPU rendering. Also make sure that the 'Open Shading Language' box is checked. Guess it's kind of obvious in retrospect.
Gorgeous results! This saved me a serious headache when time was an issue. Thank you!
I've downloaded the blend file, but it doesn't seem to show me the results in Blender 2.78c. Everything's black.
Any ideas?
EDIT: NVM got it working. :)
Hey Tushantin can you tell me what you did in 2.78? I replaced the glossy instead of specular. 2.77a works but still not working in 2.78.
It doesn't work for me, the edge shader seems to work well but the toon shader doesn't work and give me an error when I try to "reload" it
How did you add the second material (outline) over the first (diffuse)?
EDIT: Ah, ok. You just add solidify modifer with inverted normals
Just wanted say that the 'Edge' shader can easily be implemented with Cycles nodes so you can also use it with GPU. Just use a Mix shader with 1 transparent and 1 emission shader. Connect one Geometry node and set the Backfacing input to the factor input of the mix node. Also set a math node in between that connection and with 'Greater than' and then 0.5 on the other value. That should work. Also uploaded an image, but just wrote this text in case the image is not available anymore at some point. https://ibb.co/6bJxFjx Of course also do the Solidify modifier stuff like before.
It does in 2.93 - Make sure you've enabled Open Shading Language in your render settings under Device: GPU Compute. You should be able to enable even if greyed out.
wow a scripted shader very good!