Cel toon shading with karma in Houdini
Cel toon shading with karma
create fill
add some object (make sure it has lots subdivisions) add mask by feature node (feed object into first input) direction from: point cloud uncheck cast shadows output -> click on white icon to see it (click it again to disable it afterwards!) add a box add transform node below the box feed into second input of mask by feature node (position it above the object, it's the light direction!) add attribute blur node (below the mask by feature node) attributes: mask blurring iterations: 30 step size: 1 (add attribute adjust float node) attribute name: mask operation: set always pattern type: remap attribute then set some steps in ramp add color node color type: ramp from attribute attribute: mask then set a two color gradient (darker to bright) dark grey, medium grey, light grey, white to see colors instead of mask: go to mask by feature node: output -> click on white icon (to disable mask preview) or click the visualizer icon (next to viewport, bottom right) add material node name it: fill
create outlines (v1, quick)
add peak node (below the color node!) distance: 0.1 (or less) add color node color: black add reverse node open display options by pressing d markers tab -> uncheck tint backfaces optimize tab -> check remove backfaces add material node name it: outlines add merge node and feed both material nodes (click lamp icon with X)
nodegraph
┌───────────────┐ │ box1 │ └────────┬──────┘ ┌────────────────┐ ┌────────┴──────┐ │ GEO object │ │ transform │ └───────┬────────┘ └────────┬──────┘ └────────┐ ┌──────────┘ ┌────┴─────┴───┐ │maskbyfeature │ └───────┬──────┘ ┌──────┴───────┐ │ attribblur │ └──────┬───────┘ ┌──────┴───────┐ │ color1 │ └──────┬───────┘ ┌──────┴───────┐ │ material1 │ └────┬────┬────┘ ┌────────┘ │ ┌────────┴───────┐ │ │ peak │ │ └────────┬───────┘ │ ┌───────┴───────┐ │ │ color2 │ │ └───────┬───────┘ │ ┌───────┴───────┐ │ │ reverse │ │ └───────┬───────┘ │ ┌───────┴───────┐ │ │ material2 │ │ └───────┬───────┘ │ └────────┐ │ ┌────┴────┴────┐ │ merge │ └──────────────┘
rendering the toon shader in karma
go to /mat context add karma material builder name it: fill base: 0 specular: 0 emission: 1 add mtlx geometry color node plug into emission color add another karma material builder name it: outlines base: 0 specular: 0 assign the materials in /obj context go to stage context (add sop import node) path: ../OUT_object add scene import all node objects: /obj/SOMEOBJECT filter: geometry objects add scene import materials node add camera node add dome light node karma tab -> light -> check Render light geometry (this renders the white background, disable for rendering transparent background) add merge node merge scene import nodes, camera and light add karma node in karma render settings node -> > rendering > geometry and shading tab cull backface: cull backface usdrender_rop node -> override output image: $HIP/render/render.exr click render to disk
convert to png
in /img context add file node load the .exr add rop file output