Cycles OSL toon shader setup

Description

Example of toon shader for Cycles + OSL.

This includes two OSL scripts:

  1. Toon shader using diffuse_toon() and specular_toon() closures
  2. Single sided black surface used for toon edge

You can see some test videos in Youtube:

  • http://www.youtube.com/watch?v=WcQFs1opokI
  • http://www.youtube.com/watch?v=coYggqUHwDc

Comments (33)

C
chillahannes about 13 years ago

wow a scripted shader very good!

L
loaf almost 13 years ago

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.

L
loaf almost 13 years ago

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

O
okitam almost 13 years ago

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

A
Alesk almost 13 years ago

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

A
Alesk almost 13 years ago

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

I
irie almost 13 years ago

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.

I
irie almost 13 years ago

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

O
OrigamiOrchid over 12 years ago

Thank you for sharing!

W
wolfesteiin over 12 years ago

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

S
secheung about 12 years ago

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

W
Wright over 11 years ago

specular\_toon() was renamed to glossy_toon() in some recent builds

T
twinmoons about 11 years ago

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

B
BUNIGPRO about 11 years ago

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

H
hashir almost 11 years ago

Great work,thanx for sharing.

X
xoro over 10 years ago

this not working on 2.76 solid black nothing more

F
freakypie about 10 years ago

This script isn't working on 2.76: Blackness

R
robojumper about 10 years ago

*specular\_toon() was renamed to glossy\_toon()* (6 comments above) Just rename inside the script and reload inside of the script node.

L
lpjunior999 about 10 years ago

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

X
xseeks about 10 years ago

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.

N
NoctumSolis almost 10 years ago

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

T
tushantin about 9 years ago

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

E
elibaba almost 9 years ago

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.

H
hisyam08 almost 9 years ago

not work too on 2.78c

L
L0Lock over 8 years ago

specular_toon() was renamed to glossy_toon()

R
Rawrington almost 9 years ago

Thank you for sharing!

L
L0Lock over 8 years ago

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](https://www.blendswap.com/blends/view/89187). Still CC 0. Enjoy.

A
amieldanaoreal over 8 years ago

Thank you very much

A
Azagwen almost 8 years ago

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

S
SatyrTai almost 8 years ago

Thank you for sharing!

V
v0van1981 about 7 years ago

How did you add the second material (outline) over the first (diffuse)? EDIT: Ah, ok. You just add solidify modifer with inverted normals

P
portthames about 6 years ago

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

W
Wolves_1524284 over 4 years ago

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.

Sign in to leave a comment.