ID #1077

What is the effect of surface normals and smoothing groups?

This article explains how Strata Live 3D CX uses smoothing groups to compute vertex normals. If you are having issues with the way your models are lit in Strata Live 3D, particularly if you notice differences when the model is published to the web, you should read this article.

For models which use Phong shading, the shade of the surface color or texture, and the behavior of specular highlights, are all controlled by vertex normals. A vertex normal is a 3D vector which indicates the direction the surface is facing at that vertex. 

In Strata Live 3D, as in almost all 3D modeling programs, the vertex normals are computed by averaging the surface direction of triangles touching that vertex.  This leads to smooth shading across the transition from one triangle to another, making a fundamentally polygonal object look round.

In some cases, you do not want adjacent faces to have smooth shading. Suppose you have modeled a cube. Averaging face normals to compute vertex normals leads to strange lighting effects, since the boundary between triangles actually shoud be a sharp edge in this case. 

In Strata Live 3D this is handle by smoothing groups. Each face of the box can be placed into a different smoothing group, and when vertex normals are computed, a single vertex will end up with multiple normals, depending upon which face is being shaded.

These smoothing groups can be computed five different ways:

1) If you use 3ds max, and the Kaon export script (use the Help > Extras menu item), then the smoothing groups used by 3ds max are used directly by Kaon's software. The only catch is that we only support 24 smoothing group bits, not 32, so you need to make sure you only use the bottom 24 smoothing groups.

2) If you use a 3D program that exports normals into the VRML file, Strata Live 3D will look at those normals and compute smoothing groups which match those normals as closely as possible at import time. Note that many 3D programs have a checkbox in the exporter to choose whether normals are exported: make sure you turn it on!

3) If you use a 3D program that does not export normals (such as Lightwave), Strata Live 3D will look at the topology of the mesh. If two faces share a vertex (the vertex is "welded"), then they will be placed in the same smoothing group. If two faces share a vertex location but use different vertices (the vertices are "split"), then the faces will be placed into different smoothing groups.

4) After import, you can assign new smoothing groups to any object by right-clicking it in the hierarchy and choosing the Object Smoothing item from the menu.  This item allows you to compute smoothing groups based on the angle between faces.

5) When you use the Generate LOD feature of Strata Live 3D to reduce polygon count, you can also generate new smoothing groups as part of that operation.

Suppose you have a cube with a finely rounded edge. In this case, a single smoothing group leads to attractive lighting effects. But suppose you need to eliminate this fine edge while generating LOD to reduce triangle count.

After decimation, it is better to have the adjacent faces in different smoothing groups. By using the smoothing group recomputation feature of the Generate LOD panel, you can make this correct at the same time you decimate the mesh.

Although it is rare, sometimes after compressing your model for the web, the lighting will change. This can happen because one step of web compression is welding. Vertices which are very close spatially are automatically welded together, to save space during compression.

If the smoothing groups are correct, this will have no impact on the visual appearance. But if the smoothing groups do not accurately describe the way lighting should be after welding, then edges that were sharp can become smooth.

To correct this, right-click the problem object in the object hieararchy, and choose Generate LOD.  Move the slider slightly to the right, and do a decimation.  Generating LOD also welds vertices, as well as giving you the opportunity to compute new smoothing groups.

Tags: -

Related entries:

You cannot comment on this entry