Cycles OSL toon shader setup

  • April 27, 2013
  • 5,810 Downloads
  • 30 Likes
  • Blender 2.6x
  • Render: Cycles
  • Creator: irie
  • License: CC-0
You must be logged in to download.

Description:

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>

Comments:

  • chillahannes profile picture
    chillahannes

    wow a scripted shader very good!

    Written April 27, 2013
  • loaf profile picture
    loaf

    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.

    Written May 12, 2013
  • loaf profile picture
    loaf

    NM after a "re-investigation" I figured it out. Duh!!

    Written May 12, 2013
  • okitam profile picture
    okitam

    I didn't figured out, how he apply the edge texture so the edge becomes dark?

    Written May 13, 2013
  • Alesk profile picture
    Alesk

    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 :/

    Written June 03, 2013
  • Alesk profile picture
    Alesk

    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

    Written June 03, 2013
  • irie profile picture
    irie

    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.

    Edited June 10, 2013
  • irie profile picture
    irie

    specular_toon() closure became available again in svn r57362, so this .blend file should work with latest trunk build.

    Edited June 11, 2013
  • OrigamiOrchid profile picture
    OrigamiOrchid

    Thank you for sharing!

    Written October 01, 2013
  • wolfesteiin profile picture
    wolfesteiin

    Thank you very much for your scripts, it helped me a lot :)

    Written January 13, 2014
  • secheung profile picture
    secheung

    These scripts are going to be very useful to me. Thanks.

    Written March 14, 2014
  • Wright profile picture
    Wright

    specular_toon() was renamed to glossy_toon() in some recent builds

    Edited November 07, 2014
  • twinmoons profile picture
    twinmoons

    This is really awesome! Great work with this and thank you for sharing!

    Written February 12, 2015
  • BUNIGPRO profile picture
    BUNIGPRO

    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

    Written April 19, 2015
  • hashir profile picture
    hashir

    Great work,thanx for sharing.

    Written August 05, 2015
  • xoro profile picture
    xoro

    this not working on 2.76 solid black nothing more

    Edited January 24, 2016
  • freakypie profile picture
    freakypie

    This script isn't working on 2.76: Blackness

    Written February 19, 2016
  • robojumper profile picture
    robojumper

    specular_toon() was renamed to glossy_toon() (6 comments above) Just rename inside the script and reload inside of the script node.

    Written April 05, 2016
  • lpjunior999 profile picture
    lpjunior999

    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

    Written May 03, 2016
  • xseeks profile picture
    xseeks

    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.

    Written May 04, 2016
  • NoctumSolis profile picture
    NoctumSolis

    Gorgeous results! This saved me a serious headache when time was an issue. Thank you!

    Written June 12, 2016
  • tushantin profile picture
    tushantin

    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. :)

    Written April 02, 2017
  • elibaba profile picture
    elibaba

    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.

    Written May 15, 2017
  • hisyam08 profile picture
    hisyam08

    not work too on 2.78c

    Edited June 30, 2017
  • L0Lock profile picture
    L0Lock

    specular_toon() was renamed to glossy_toon()

    Written August 11, 2017
  • Rawrington profile picture
    Rawrington

    Thank you for sharing!

    Written July 11, 2017
  • L0Lock profile picture
    L0Lock

    Hey. As that script doesn't work with recent versions of Blender and all people don't get it how to fix it, I made an updated version of that shader. You can find it here. Still CC 0. Enjoy.

    Edited August 11, 2017
  • amieldanaoreal profile picture
    amieldanaoreal

    Thank you very much

    Written October 18, 2017
  • Azagwen profile picture
    Azagwen

    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

    Written May 11, 2018
  • SatyrTai profile picture
    SatyrTai

    Thank you for sharing!

    Written July 08, 2018
  • v0van1981 profile picture
    v0van1981

    How did you add the second material (outline) over the first (diffuse)?

    EDIT: Ah, ok. You just add solidify modifer with inverted normals

    Written April 22, 2019
  • AtotheB profile picture
    AtotheB

    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.

    Written May 22, 2019
  • AtotheB profile picture
    AtotheB

    Of course also do the solidify modifier stuff like before

    Written May 22, 2019
  • portthames profile picture
    portthames

    Does this exist for 2.79x or 2.8? I can't get it to work.

    Written April 29, 2020
  • Wolves profile picture
    Wolves

    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.

    Written November 08, 2021