Shading in Papervision 3D

Written by:  • Edited by: Linda Richter
Updated Aug 13, 2010

With the help of the Papervision 3D engine, you can create various shading effects for your Flash gaming project. Read on to learn more.

Shading is a technique used to highlight a 3D model against a light source. In previous articles no shading at all was used – the models appeared to be uniformly lit. While fast, this lack of shading does detract from the visual appeal of the 3D model.

Papervision 3D supports a number of shading methods, 4 of which will be demonstrated here.

Object Highlights

Papervision 3D Flat Shading Flat shading is a very simple shading technique where each polygon in the model has the same lighting value. It is very quick to calculate, but the polygons do stand out giving the model a very sharp look.

Cell Shading

Papervision 3D Cell Shading Cell shading uses a number of discrete lighting levels to produce a simple, flat lighting look. This is commonly referred to as cartoon shading as the end result looks like the simplistic shading often employed by hand drawn cartoon images. It is quite fast to render, and when used in conjunction with simple textures can product quite an appealing look.

Gouraud Shading

Papervision 3D Gouraud Shading Gouraud shading attempts to highlight a model by applying lighting values to each vertex of a model, and interpolating between them. For high detail models this is quite an effective, and quick, technique. However for models with lower triangle densities the specular (i.e. shiny) lighting can appear to jump across the model. Given that all 3D rendering done with Papervision will almost certainly involve low polygon models this may prove undesirable.

Phong Shading

Papervision 3D Phong Shading Phong shading is the best looking, but most computational intensive, shading technique available in Papervision 3D. Unlike Gouraud shading, Phong shading applies a lighting value to each pixel, avoiding the issue of an inconsistent specular lighting effect. Papervision 3D also allows bump maps and specular maps to be applied to the Phong shader to add an additional level of realism.

To demonstrate the differences between the different shading techniques I have created a demo that applies each of the 4 techniques above to a sphere. Check out the Flash demo, and download the source code.

Images

Papervision 3D Demo - Phong ShadingPapervision 3D Demo - Flat ShadingPapervision 3D Demo - Gouraud ShadingPapervision 3D Demo - Cell Shading

Related Article

Away3D Screenshot Away3D Programming Tutorials - Phong Multipass Material

This free article shows you how to use the new PhongMultipassMaterial class in Away3D


Comments

Showing all 5 comments
 
Web Development Dec 13, 2011 1:34 PM
RE: Shading in Papervision 3D
I really like that your examples are written in OOP. This is important for people who are new to AS3. I also like the simple example illustrating shading material. I wish, though, that your examples would have more comments in the code. Keep it up!
Bill York Apr 7, 2011 4:51 AM
Flash demo
Great intro to shading, thanks. Suggestion: I think that the Flash demo would be better if all four cases used the same material. As it is now, the shift in materials from one example to another makes such a visual difference that it can "drown out" the effect of changing the shading algorithm.
GABE CHERIAN Sep 8, 2009 5:05 PM
Preparing Design Patent Drawings
Greetings:
I found your name and contact information when searching the web for help.
I am looking for advice or help in preparing acceptable drawings for Design Patent applications, which would be acceptable to the US Patent Office.

My biggest problem is the “shading” of the drawings.

I can prepare the “3D model” and its drawings using AutoCAD software or the like, and can print out the “picture”, either as a “wire frame” or as a “half tone” picture print. I can also hand draw a “sketch”, 2D or 3D, representing the object. Unfortunately, none of these outputs is acceptable to the Patent Office. My next step is to convert any of these “first step” outputs into a “design patent figure”, according to the USPTO rules and requirements.
Some of these Patent Office requirements are listed below. I understand that “stippling” may be acceptable too, but I am not sure.

My question to you is this.
Do you know of any software that can convert drawings or sketches into what the Patent Office would accept for Design Patent Applications?
I would highly appreciate it if you could give me any comments, advice or help.
Thank you in advance.
Gabe Cherian
PO Box 1335, Sun Valley, Idaho 83353
Telephone: 208-622-7020
Email: GABE.CHERIAN@YAHOO.COM

Some of these Patent Office requirements:
1. The design must be shown as three-dimensional using appropriate shading.
2. The use of “wire frames” to show dimensionality, i.e. figures constructed from contour lines in which the surfaces behind other surfaces are visible when in reality they would not be, is not acceptable in a design patent.
3. The drawing figures should be appropriately and adequately shaded to show clearly the character and/or contour of all surfaces represented.
4. This is of particular importance in the showing of three-dimensional articles where it is necessary to delineate plane, concave, convex, raised, and/or depressed surfaces of the subject matter, and to distinguish between open and closed areas.
5. Spaced lines
Matthew Casperson Aug 17, 2009 8:57 AM
Source Code
All the source code is available from Sourceforge. The source to this article is up at https://sourceforge.net/projects/papervisiontut/files/Papervision%20Tutorials/Shaders/
Imanuel Aug 17, 2009 7:44 AM
source code
You have a great tutorial.
Can you send the source code of Papervision 3D Programming Tutorial - Shading to my email?
Thanks..
 
blog comments powered by Disqus
Email to a friend