Samples
Shading
Shading is a method to create shadows on the model. When the lighting is enabled in MascotCapsule V3, two shading methods are available: gouraud shading and toon shading.
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 shadows in a cartoon animation.

Toon shading
3.Shading sample code
Use the IMICRO3D_Render_setAttribute() method to specify the environment attribute for shading. Specify M3D_LIGHTING as the third-argument to enable lighting. Also, specify M3D_TOON_SHADING to enable toon shading.
In addition to this, it is necessary to specify the 256-step threshold level, and light intensities of two areas surrounding the threshold level for toon shading. To do so, use the following method:
IMICRO3D_Render_setToonParam( render* This, hi_sint32 threshold, hi_siont32 high, hi_siont32 low )
In this method, threshold represents the threshold level for toon shading, high represents the intensity when the value is greater than the threshold level, and low represents the intensity when the value is equal to or smaller than the threshold level. Specify the intensity value from 0 to 255 for high and low.
#define THRESHOLD 120
#define THRESHOLD_HIGH 255
#define THRESHOLD_LOW 0
/* Shading setting by the key check */
if ( ( mask & SOFT1_MASK ) != 0 )
{
IMICRO3D_Render_setAttribute( pMe -> pIM3D, &pMe -> mc_data.render, pMe -> mc_data.attr | M3D_LIGHTING );
if ( ( mask & SOFT2_MASK ) != 0 )
{
IMICRO3D_Render_setToonParam( pMe -> pIM3D,
THRESHOLD,
THRESHOLD_HIGH,
THRESHOLD_LOW );
/* Enabling toon shading */
IMICRO3D_Render_setAttribute( pMe -> pIM3D,
pMe -> mc_data.attr | M3D_LIGHTING | M3D_TOON_SHADING );


