PETZOLD BOOK BLOG
| Recent Entries | ||
| < Previous | Browse the Archives | Next > |
| Subscribe to the RSS Feed |
September 6, 2007
New York, N.Y.
Of course I couldn't mention a technique of possible real-time cell-shading yesterday without actually trying it out. No, I didn't attempt to derive from BitmapEffect. (I'd love to take a crack at BitmapEffect but I simply cannot justify the expenditure of time.)
Instead, I tried the RenderTargetBitmap approach. Here's a rough outline:
Here's the RealTimeCellShading source code. Sorry I can't give you an XBAP, but apparently Clear and CopyPixels are prohibited methods for partial trust. (But Render and BitmapSource.Create are mysteriously OK. Hey — I don't make up the XBAP rules!)
I've used an AmbientLight at 1/4 white and DirectionalLight of 3/4 white with a direction of (2, –3 –1). I've provided a pair of scrollbars to rotate the camera relative to the teapot, and a pair of sliders to rotate the teapot relative to the camera and light sources. Here's a view with the teapot slightly rotated:
It still looks rather rough and of course the performance is terrible, but it kind of actually works, almost.
|
Buy my book and we'll both be happy! | ||
| Amazon.com | BookSense.com | quantumbooks | |
| Barnes & Noble | Amazon Canada | Amazon UK | |
| Amazon Français | Amazon Deutsch | Amazon Japan | |
| Recent Entries | ||
| < Previous | Browse the Archives | Next > |
| Subscribe to the RSS Feed |
Comments:
Awesome! Now for the outlines ;) Could WPF [2D] be fast enough for that? If you don't try it, I think I might feel compelled to ;)
— Chris Cavanagh, Thu, 6 Sep 2007 16:12:52 -0400 (EDT)
Submit comment:
NOTE: Comments are examined personally and generally posted within 12 hours.