Jump to content

Blender & normal editing - rounded edges.


Drongle McMahon
 Share

You are about to reply to a thread that has been inactive for 2321 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Blender 2.75 is out. Thanks to Gaia, it now exports "custom" normals. These are modifiable normals at a vertex that can be different for each face meeting at the vertex. This is one of the things that has been lacking for a long time. One of the uses of them is making better slightly rounded edges. I am going to describe that here because the process is quite complicated and there are some caveats that were unexpected, at least to me.

Real things don't usually have perfectly sharp edges. Highlights from slightly rounded edges are one of the most effective ways of making objects in SL look more realistic. Simple flat shaded objects don't have these highlights. Simply using smooth shading doesn't work because the smoothing is interpolated over the whole faces, with the horrible result shown at 1 in the first picture. So the rounding of the edges has to be done in other ways. The other two picture in the top row do this with normal maps. At 2, the same smooth-shaded geometry has a normal map baked in Blender from the mesh shown at 4. This is partially effective, but the surfaces are not perfectly flat and show distorted reflections. I think this is because of differences in the "normal basis" in Blender and Sl. Some older threads have looked at better results that can be obtained with other baking software, but perfection was not achieved there. At 3, the same normals were baked onto a flat shaded version of the mesh. The distortion is removed, but now the edges have a visible seam (not easy to see here, but prominent on close inspection. This can probably be improved with better baking, but maybe not completely removed.

Another way to achieve the rounded edges is to add geometry. To get flat faces, the normals at their vertices must be perpendicular to those faces, as they are with flat shading, but the rounded edges must be smooth shaded. This can be done by bevelling the edges using two segments and a profile of 1.0. This leaves the geometry with flat faces, so that the normals within the original faces are perpendicular. Smooth shading the gives interpolated normals at the edges, providing and the illusion of rounded edges, while the faces stay flat. This is the mesh at 4 in the picture. Nearly there, but there are two awkward effects. if you look at the bottom front corner, you can see that it's sharp, conflicting with the rounded shading. If you look at the undercut edge on the right, you can see a band of dark shading, because it's shaded as if it were underneath, while it's visible because it's geometrically on the side. Again the geometry and the shading are in conflict.

The mesh at 5 uses the newly available custom normals. The edges are now bevelled with only one segment (so less geometry), which would ordinarily give nasty shading because of interpolated normals across the flat faces, as seen at 6. However, in 5 the normals are transferred onto the mesh from a flat-shaded version of the unbevelled mesh. Now the normals are all perpendicular to the right faces. So the faces look flat and the smooth shading just rounds off the edges. Not only is this less geometry than the previous solution, but it also does away with the two artefacts because the real bevel now provides an approximation of the proper rounded geometry.

edgesx.jpg

That was all using advanced lighting. Unfortunately, the relative quality of the two alternative bevelling approaches is inverted when advanced lighting is off (and of course the normal maps don't work at all). Panels 7-9 are the same meshes as 4-6 without advanced lighting. The two-segment bevel is clearly better. It even shows the illusion of a little rounded edge highlighting (although actually the wrong way round).

Here is a less artificial example of the two bevel methods, with figures showing the reduction in geometry and LI using the edited normals. The asterisk shows a point where the real bevel shows the lighting, mostly from above, darkens around the edge, as it should, in the edited normal version, but does not in the alternative version.

wrought_edges.jpg

Next I will show how the normals were edited.

 

  • Like 7
Link to comment
Share on other sites

Editing the normals is quite complicated. It is done with the Data Transfer modifier, which is complicated because it can do a whole lot of other stuff too.

A. First, to use custom (or per-face vertex) normals, you have to activate Auto smooth. Do this in the object data tab of the properties window (the small triangle icon), by checking Auto smooth (1). Keep the auto smooth angle (2) at 180 degrees. I did this for the source, flat-shaded mesh (left at the bottom), as well as the target, so that I could see the per-vertex normals in the 3-D view (pink lines). These are made visible with the middle button of the display normal settings under Mesh Display on the 3D view properties window. This isn't strictly necessary.

Note that it looks as if auto smooth allows you to control flat and smooth shading without using the edge split modifier. But don't try to use this because, at least for now, the normals adjusted that way are NOT exported to Collada, and you will end up disappointed and confused (at least I was).

B. Starting from the flat-shaded mesh object you are going to use for the source of the normals bottom left), copy it, in object mode, and make the single-segment bevels along the edges (bottom middle). This is the target object. It is absolutely essential that these two object have their origins in exactly the same place relative to the geometry. Otherwise the wrong normals will be transferred.

3. Now add the Data transfer modifier to the target object.
4. Select the source object and...
5. Turn off the global space evaluation, so that the positions are evaluated relative to the object origins.
6. Check Face Corner properties (custom normals are among these).
7. Select the face/corner matching mode. Nearest corner of nearest face works for the example, but I have had to use others for other meshes. Keep looking at the normals in the 3D view to make sure it's working. In Edit mode, you can toggle the effect on the normals with the modifier triangle button, and the shading effect with the cube button (compare bottom middle and right for both toggles).
8. Turn on custom normal transfer.

Note - You can equally well use a source with the two-segment, profile=1 mesh as the source. In some cases, this may be better for matching the right normals, as long as the bevel sizes are the same on source and target.

C. When it's right, export to Collada.

9. There's one VERY important option that you will need to uncheck if you use the SL presets. The custom normals don't survive the Blender triangulation. If you leave that option on, you will end up with a horrible mess. That had me confused for some time. Fortunately, they do survive the SL importer's triangulation!

This restriction is one example of the more general limitation that the custom normals don't generally survive any changes in the topology of the mesh. So this means they must only be applied after every other operation, or must be reapplied if you change the geometry. This presumably has implications for the order of modifiers in the stack, as well as the general principle that you should use them only after everything else is finished.

edgesy.png

ETA: I had edited part A, but now reverted it. It turns out that you do have to have auto smooth on to get the transferred normals exported. They will display and render nin Blender without auto-smooth, but will not be exported. It appears now that you have to both have Auto smooth active AND transferred (or edited) normals to get them exported*. Either on its own is insufficient (at least for now - may be a bug).

  • Like 4
Link to comment
Share on other sites

Another thing that's not clear in the stuff above. The source mesh there was flat-sgaded, and that worked because all the angles are 90 or 180 degrees. If you have curved surfaces in the source mesh (like in the wrought iron), then you do need to have smooth shading where the curves are smooth and sharp edges where you want to do the bevel. This is illustrated with the arch below. The source mesh is the same arch without the bevel. If it is flat shaded, the face-vertex matching doesn't work to get the proper result, as shown on the left. If the source has smooth shading with sharp edges just where the bevels are going, then it works correctly, as shown on the right. You can make the sharp edges on the source mesh using either auto-smooth or edge split (tool or modifier).

edgesneedasm.png

  • Like 1
Link to comment
Share on other sites

Thanks for getting this done, I tried to figure out editing normals in Blender a few weeks ago and got absolutely nowhere. Now i can try again one afternoon this week :)

Have you seen/tried this updated Normal editing tool panel in the Blend4web addon yet ?  https://www.blend4web.com/en/article/131

It looks a little  bit easier to use than what the Blender devs came up with .

And a Youtube Blend4web video showing some normal editing

 

Link to comment
Share on other sites

I haven't tried the Blend4Web addon. It looks like it's a lot easier to use for any more detailed editing. I'll have to try it. The Data Transfer modifier is pretty cumbersome even for the smple global stuff I was showing. When you get to doing more adjustable modifications to subsets of normals, it gets very uncomfortable. I'd prefer it if someone did a simple addon for just the normal editing that though, without all the other Blend4Web stuff that I don't need.

Link to comment
Share on other sites

  • 1 year later...

I wanted to resurrect this thread because I've managed to incorporate custom normals into my workflow. I model in Maya, and have recently been fighting with normal artifacts and having to add far too much extra geometry to compensate. As always, thanks to Drongle for doing the research.

For the record, I model in Maya LT 2017, export as obj to blender, then export from blender as dae.

In maya, I soften my edges as needed (Mesh Display> Soften Edges. NOT to be confused with averaged normals), then export as obj with normal information (checkbox in export options).

In Blender, the only thing I do is export out as dae. As mentioned by Drongle above, the key is unchecking the 'triangulate' option during dae export. This way, the export from blender preserves my normals from Maya. Its now apparent to me than this triangulation is responsible for a lot of normal mess...

 

Link to comment
Share on other sites

  • 1 year later...

Adding to this old post as it seems that TRIANGULATING the mesh before data transfer may be needed. In case that wasn't covered here as it appears to be some sort of new change and triangulating is sometimes needed (end of 2017) when it was not before (on a variety of meshes, not just ones with custom normals). 

Here is the thread on that: 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2321 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...