Japanese | English | Korean

Samples

Shading

Shading is a method to create shadows on the model. Two shading methods, gouraud shading and toon shading are available in MascotCapsule V3.

Table of contents

1. Gouraud shading

Gouraud shading method finds the normal vector of each vertex in the object, and interpolates the triangular surface consisting of these vertices. A smooth shading result is achieved, because pixel borders are less distinctive.

 

Gouraud shading


2. Toon shading

Toon shading method creates distinctive borders for the shadow. It creates shading effects similar to cartoon animation.

 

Toon shading


3. Shading sample code

Use the setShading( int shading ) method in the Effect3D class, in order to specify the shading setting. Specify the shading value to NORMAL_SHADING for gouraud shading, and TOON_SHADING for toon shading.

In addition to this, use the setThreshold( int threshold, int high, int low ) method to specify the threshold level for toon shading. In this method, threshold represents the threshold value of toon shading, high represents the intensity when the level is greater than the threshold value, and low represents the intensity when the level is equal to or smaller than the threshold value. Specify the intensity value 0 to 255 for high and low.

/**
  * commandAction() method
  * Process when the soft key is pressed-down (changing the rendering parameter)
  */
public void commandAction( Command c, Displayable d ){
String label = c.getLabel();

/* Changing the shading method */
if( label.equals( commandLabels[ 0 ] ) ){
effect.setShading( Effect3D.NORMAL_SHADING );
}else if( label.equals( commandLabels[ 1 ] ) ){
effect.setShading( Effect3D.TOON_SHADING );
}
}