POV-Ray : Newsgroups : povray.binaries.images : toon-shading using attenuation : toon-shading using attenuation Server Time
3 May 2024 08:41:20 EDT (-0400)
  toon-shading using attenuation  
From: Lukas Winter
Date: 22 Mar 2007 05:30:42
Message: <pan.2007.03.22.10.30.36.351543@removeit.geloescht.net>
In povray.general there is a discussion about toon-shading and I'd like to
contribute my solution. The trick is to put a slightly larger copy around
each object with a clear texture but with dense black attenuation and
no_shadow. This has the advantage that black lines only appear at
positions where the object really ends and that it works with non-curved
surfaces (although the line could be a bit brighter). However, finding
a copy that really fits well so that the line has the same thickness
everywhere is often difficult. For blobs or isosurfaces lowering the
threshold is not always enough. It works quite well for basic objects and
CSG. Meshs shouldn't be a problem if you can expand it by moving every
vertex along its normal but I have never tried that.
Here's the code for a sphere:

#default { finish { ambient .2 diffuse 1 }}
//higher diffuse because black attenuation darkens the texture
union
{
	sphere
	{
	  0, 1
	  pigment
	  {
	    color <1, 0, .05>
	  }
	  finish
	  {
	    brilliance 0
	    specular 10000 //can increase render times with anti-aliasing
	    roughness .0015
	  }
	}

	sphere
	{
	  0, 1.03
	  hollow
	  pigment
	  {
	    Clear
	  }
	  interior
	  {
	    fade_power 1111
	    fade_color <0, 0, 0>
	    fade_distance .01
	  }
	  no_shadow
	}
}

And here's a render of a small demo scene:
http://geloescht.net/allerlei/comic_small.png


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.