ZModeler2 Lesson#2: Normals calculation, knife tool. Normals Tuner.

Normals calculation.

Open Files/les2_01.z3d file. This is a shape of BMW, from basic lessons. Half of the mesh, as usually. I've switch texture off, and set BMW's material to bright green color. We shall not need texture currently, since accurate shading is our aim for now.

First of all, make sure to disable Flat-Shading mode. It's done in object's properties (right-click on the mesh and pick "Properties...") in Rendering\Technique branch. Once disabled, make sure to apply Surface\Normals\Calculate tool to an object ('C' is a hotkey). You've got default normals calculation for specified object. You might think that objects is pretty-fine shaded, but it's not. Take a look at surrounded areas on the right image. The hood is mostly dark-shaded and have an area which is a little brighter than the rest. Air intake is also shaded improperly: it looks too smooth, while sharp edges should be there. Image below shows how shading should be adjusted:

It was done by duplicating vertices on a boundary and re-calculating normals. Even if it sounds complex, it was done very easily with Knife tool.

Knife tool.

Modify...
Submesh...
Knife

This is an interactive tool and can be applied to vertices only. The aim of this tool is solely for shading-purpose: it makes incision in the mesh by duplicating vertices you specify. The only option in advanced settings box is "Update Normals" and it should be set on. To apply this tool, switch an object to vertices level, and pick a sequence of vertices by clicking on them one by one. Then hold and click to perform knife operation. Image on the right shows how knife tool can be applied to sample mesh. Notice that knife tool draws line over the mesh where it's going to be applied. First of all, head and tail segments of this line are always dashed and all inner segments are red. Red segment means that vertices on this segment will be split; dashed segment means that this segment will be split incompletely. Image below shows what I mean:

I've moved vertices away to show how they were split. Notice that the vertex under cursor was not split, but the edge going out of this point (on previouse image it is a segment between points #1 and #2) have been split. Thus, for example, to make a sharp edge of the top row, you need to pick seven points:

There is one major limitation of this tool indeed. The sequence of vertices you pick can lay over existen edges only and can not interrupt. It sounds quite obviouse, until you face over this limitation while using this tool. An example is on the right. Assume you have used area-mapping approach to UV-map the mesh and Detach tool have been used to map yellow and green areas of the mesh separately. They are now separate from each other and do not share any vertices. This means that I can not knife a line like I've drawn on the image (solid red lines), because this line interrupts under cursor. Why? Because there is pair of disjoint vertices under cursor and only one is highlighted. Thus, there are no continuous sequnce of vertices to much such an incision, it's true. But it's still possible to cut the line I've drawn - it can be done by cutting yellow and green areas separately. Image on the left shows how it was done. Notice that head and tail dashed lines are still there and leads aside from "desired incision line". It was done just to make sure that solid knife's line drawn upto where needed and not ends up where it should not. One more thing to notice here is that you have to pay attention to which vertex you highlight before clicking on it. This is a common advice, but here is't very important. -pick technqiue here is widely used. For example, to pick vertices #1 and #2 while cutting yellow area (lower image) I had to use ctrl-click to pick proper vertices (those that belong to yellow area).

There could be a case with a Knife tool that clicking on a vertex does not lead knife tool to "pick this vertex for a sequence". This is caused only by "continuous" limitation - the vertex you click on is not jointed with previouse vertex by an edge.

Inplace Detach.

Take a look at the image on the right. It's BMW air intake. To make it shaded more accurate, green, orange and yellow areas have to be separated from each others with sharp edges. Of cause you can use Knife tool to sniff orange area from green and then stiff yellow area from orange, but it's way too long. Instead, you can detach orange area from anything else (detach it from green and yellow areas). This is done by a so-called inplace detach. You have done this already while UV-Mapping, but here you can do it for shading purpose. Simply, select desired polygons (orange), switch to selected mode, pick a Modify\Submesh\Detach tool, expand it's options box and make sure none of the options is set ("to new object", "enable drag" and "keep original" are all not checked) and click in viewport. You have detached polygons. Now make sure to recalculate normals for the whole object.

Ok, you know the theory of making accurate shaping and you can practice on BMW mesh to make it accurately shaded. As it was stated before, I stronly recommend to switch texture off while adjusting shading.

Shading tuning is usually performed before UV-mapping. In our case, mesh was alread UV-Mapped, and you have to keep it in mind, in case you decide to weld some vertices or perform something UV-sensitive.

Smoothing the mesh.

I assume you've played enough with shading tuning tools and got quite accurate shading on the mesh. Image on the right is what I've achieved with Knife and Detach tools. Then normals were calculated in regular fashion.

This mesh is in Files/les2_02.z3d file. It is perfect, isn't it? Actually, not. This shading is way better than it was before, but there are some lacks still. Since this mesh was UV-Mapped, there were some "area-detach" applied to it and these operations formed sharp edges around such an areas, while on real mesh there should be no sharp edges there. Headlights and taillights are an example - they should be smoothly shaded with neighbour polygons, but they are distinguishable from the rest. The same about the trunk and the hood - they have way too sharp edges on boundaries. We shall smooth shading on such a sharp edges now.

I'll show how to smooth headlight shading only, the rest is smoothed exactly the same way. First of all, zoom closer to headlight, switch to vertices level and select vertices that should have smooth shading. Image on the right shows such a vertices. Don't be afraid to select more vertices than needed, in most of cases, undesired vertices will not be affected - only duplicated vertices with sharp edges will now be affected. Second, make sure you have a 3D view opened (the one with solid shading and without wireframe) and adjust it to look at the area you are going to smooth.

Surface...
Normals...
Smooth

Smooth tool blends normals of the vertices which have the same position only. Vertices which have the same position considered to be a "group" of vertices, but only vertices whose normals fit certain "precision" criteria will be smoothed in this group. The only precision criteria used by Smooth tool is an angle between vertices normals in each group. Nevertheless, here the whole set of options for Smooth tool in it's advanced settings box:

  • Affection - the level of affection (how much this tool will smooth. When set to 100, this tool will give full smooth: vertices in a group with normals that match criteria will have identical normals and will appear fully smoothed afterward.
  • FallOff - affection falloff point. It can range from 0 (no fall-off) to 1 (linear falloff). This value is relative to the next parameter (max angle).
  • Max Angle - maximum angle between vertices normals until vertices are taken for smooth action.

    When options set to the following: Affection: 80%, FallOff: 0.5, Max Angle: 30 (degreese), the following operations will be applied:
    * Only vertices with an angle between normals in range 0..30 degreese will be affected.
    * Vertices with an angle 0..15 degreese (15 is 30*0.5) will be 80% smoothed (80 is an affection)
    * Vertices with an agle from 15 and upto 30 will have fall-off affection smoothing from 80% downto 0% respectively.

    On the left image, vertices are selected. Notice that there are several normals going out from the most of points. That's because there are several vertices in such a points. Second, I've highlighted with blue color and painted to blue one vertex' normal on the image. This vertex belongs to a "blue-shaded" polygons (but it was selected indeed) and nevertheless, I don't afraid it will be affected. It has a pretty high angle to other vertices normals. So, with such a selection, 100% affection and 30 degreese max angle set in smooth tool, I've applied it once in selected mode. The result was just fine (see an image on the right).

    Using this tool on some other problematic areas, shading can be fine-tuned. Those who are very lasy, can select all vertices and smooth the whole mesh with this tool. As you guess smooth tool will affect only groups of vertices that match criteria and will not smooth an object as a whole.


    Well, tuning normals can lasts forever, since you will never be satisfied with shading. Evenmore, good normals can be achieved on an accurately modelled shape only and in most of cases, standard normals caluclation will produce very good results on such a meshes (of cause after using a knife tool where needed).

    Automatic shading generation.

    You can save your work and perform what's suggested below as an alternate route of achieving good shading. You can start with the same Files/les2_01.z3d file.

    3DS Max users have a so-called Auto Smooth option and don't perform such a shading stuff manually. For those who would like to use something similar, I'll explain an automatic shading generation appropach. It still resides on duplicating vertices, sharp edges and everything mentioned above, but it's done solely by ZModeler. The idea is quite simple: (i) split all vertices, (ii) calculate normals for all vertices, (iii) merge vertices with satisfying "smooth angle" precision.

    Select all vertices in a mesh and perform the following three steps in selected mode:

  • Apply Modify\Break
  • Apply Surface\Normals\Calculate (the mesh will look like it's in flat shaded mode)
  • Apply Modify\Submesh\Weld tool with the following options set:
       * Multy-target mode is On
       * Precision set to 0.001 (don't set to 0.000, due to some computation precision lacks)
       * Smooth set to 20 (or any other angle in degreese you choose)
       * UV Limit set to 0.001 (don't set to 0.000, due to some computation precision lacks)

    You can use any of approaches described - manual, automatic or both. They can be be used on certain areas of the mesh - it's all your choice.

    Reflections. Normals projection.

    But the most worse problem arise when you start care about reflections too. Open Files/les2_03.z3d file. In this file, environment reflection texture is loaded onto BMW Skin material. You can spin 3D view to see how reflections spreaded over the mesh. They are quite fine, but not perfect.

    Surface...
    Normals...
    Projection

    On low-poly models, normals are often spaced too widely apart, and often they represent too much change in angle from one vert to another to make smooth shading and reflections. The best way to alleviate this is to make high-poly models, but in the absence of this possibility, you can use Normals Projection. Normals Projection acts like "explosion" in pivot helper and all normals are thrown away like trees after massive explosion. This causes normals to have a very different effect, because the normals are no longer perpendicular to surface and may even outward from the polygons. Take a look at the image on the right. This is a normals projection for the whole BMW mesh. The shading is awful and reflections are not that good either. But what is worth noticing is reflections on the rear window. They look very good for me and now I'll show how to make such a reflections on all windows.

    First of all, select rear and front windows vertices. Select\Separated tool can do it easily. Haven't you used it earlier? Give it a try - it selects a set of vertices which are separated from the rest of the mesh (because of detaching or by some other reason). Simply right-click with this tool on one of the rear-window vertices and whole window vertices will be selected. Place axes pivot in Top view in the middle of "complete object" (complete object is an mesh made of two welded parts). Since we have currently only a half of "complete object", I've placed pivot helper exactly one the weld-line (it will be a middle of "complete object" later. On the Left view pivot helper is between rear and from window and moved lower than the windows. Switch to selected mode, pick Projection tool, hold down and click in any view (we are not bothered by viewport and axes mode for "Projection" tool currently: when Shift is held down, this tool blows normals on all axes). Once normals were projected, spin 3D view and look at reflections in the windows. They should be quite accurate now. If you are not too satisfied, you can move pivot lower in side view and project again. You can even project rear and front windows separately using different pivot point locations for them. As for me, I like the results achieved on the right image.

    We shall now project normals for side windows: select vertices for side windows. Make sure not to move pivot helper in side view, at least don't change the height it's currently on. I personally have it lying under the car. In top view, move it quite far away from side window, like on the image below and apply Projection tool:

    This is not the only benefit of projection. Projection makes normals a bit more "ordered" and "co-oriented". This makes shading more smooth and reflections more accurate. To achieve these "more smooth" and "more accurate" Normals Tuner can be used.

    Normals Tuner.

    Normals tuner allows to "blend" different types of normals. For example it can blend calculation and projection in certain proportions and achieve handy results. This tool can only be applied in selected mode on objects or on vertices level. We shall use it on objects level currently, so, switch to objects level, select BMW mesh and switch selected mode On. Since this tool will be projecting normals, move Pivot helper into an object and place it in the middle of "complete object" (just like when you projected rear and front windows in the beginning).

    Change bottom left and bottom right views to 3D. Adjust these views to observe the mesh from "rear and side" and from "front and side", so you can see the whole mesh at a time. Now pick in main menu Edit\Surface\Normals Tuner and here it is:

    Drag Projection slider to 20% and look at the mesh in 3D views. Its normals (and reflections) are changing interactively. By unchecking Lock axis option you can adjust proportions ("Current", "Calculate" and "Projection") for each axis individually. I personally prefer to add more projection for Y axis (about 40%) and less projection for X axis (10%). Then hit OK to close Normals Tuner. Here they are: good shading and handy reflections:

    The file is here: Files/les2_04.z3d.