Smooth Shading and Sharp Edges for OpenSim
This is what started the Blender Bytes classes. My friend Tenbears Running was using a program in Second Life to make simple optimized mesh, then bringing them into OpenSim. Some low-poly columns that he made for a steam boat had an annoying "glow" near the top. We brought the mesh into Blender and found the problem existed there as well. What caused the effect was his mesh-making-tool marked all the faces of the cylinder as "smooth shaded". The normal of the top pointed straight up while the normals on the sides of a cylinder pointed straight out. You can look at the surface normals with the Overlays menu on the 3D Viewport's menu bar. A normal is an imaginary vector pointing perpendicular to a polygon. Smooth shading interpolates a new normal for every pixel across edges, which works really well around a cylinder. But across the top sharp edge it goes a little crazy and produces a highlight up there. Tenbears called this the "glow" since the top of his cylinders were rendered bright and reflective. You would think that marking the top and bottom of the cylinder as flat shaded would fix the issue but it does not. This does fix the shading of the top and bottom, but the normals on the sides still try to interpolate smoothly as they approach the sharp corner. You would think that marking that edge of the cylinder as "sharp" in Blender would fix the problem, but it does not. So far I have been unable to make 'sharp edges' do anything useful. Even if this had worked in Blender, it is unclear if OpenSim would have correctly interpreted this mark. By bringing cylinder prims out of OpenSim and into Blender then taking them apart we found a way to fix the problem: Splitting the top and bottom away from the sides. In Edit mode, in the Mesh menu, the Split-Selection tool will do this. What it does is duplicate all the vertices on the edge so that the side and the top no longer share any points. Now the normals on the sides don't have any contact with the normals on the top. So when the cylinder reflects light, it does so evenly from top to bottom. You may complain that this increases the complexity of the model, adding extra vertexes. True, but since this is a column that is built into the floor and ceiling, we can now delete the top and the bottom and save a bunch of vertices and triangles! In fact, if we had removed the top and the bottom in the first place we never would have had this problem. You may notice that right next to the Split-Section tool in the Mesh menu there is something called the Separate-Selection tool. What is the difference between Split and Separate? Well, Split creates separate vertices and keeps them in the same object. While Separate creates separate vertices (if necessary) and then puts all the selected vertices in a new object. This increases the prim count in OpenSim and therefore the complexity of the build. But occasionally you may wish to create separate objects. I often forget which is which and have to try it one way or the other. So I taught Tenbears how to bring his mesh primitives into Blender, Split off the ends, and save them back as DAE files for use in OpenSim. He commented "I thought Blender was difficult to use, but that is actually pretty easy!" This was my inspiration to break Blender lessons into little Bytes that are easy to learn.
This is what started the Blender Bytes classes. My friend Tenbears Running was using a program in Second Life to make simple optimized mesh, then bringing them into OpenSim. Some low-poly columns that he made for a steam boat had an annoying "glow" near the top. We brought the mesh into Blender and found the problem existed there as well. What caused the effect was his mesh-making-tool marked all the faces of the cylinder as "smooth shaded". The normal of the top pointed straight up while the normals on the sides of a cylinder pointed straight out. You can look at the surface normals with the Overlays menu on the 3D Viewport's menu bar. A normal is an imaginary vector pointing perpendicular to a polygon. Smooth shading interpolates a new normal for every pixel across edges, which works really well around a cylinder. But across the top sharp edge it goes a little crazy and produces a highlight up there. Tenbears called this the "glow" since the top of his cylinders were rendered bright and reflective. You would think that marking the top and bottom of the cylinder as flat shaded would fix the issue but it does not. This does fix the shading of the top and bottom, but the normals on the sides still try to interpolate smoothly as they approach the sharp corner. You would think that marking that edge of the cylinder as "sharp" in Blender would fix the problem, but it does not. So far I have been unable to make 'sharp edges' do anything useful. Even if this had worked in Blender, it is unclear if OpenSim would have correctly interpreted this mark. By bringing cylinder prims out of OpenSim and into Blender then taking them apart we found a way to fix the problem: Splitting the top and bottom away from the sides. In Edit mode, in the Mesh menu, the Split-Selection tool will do this. What it does is duplicate all the vertices on the edge so that the side and the top no longer share any points. Now the normals on the sides don't have any contact with the normals on the top. So when the cylinder reflects light, it does so evenly from top to bottom. You may complain that this increases the complexity of the model, adding extra vertexes. True, but since this is a column that is built into the floor and ceiling, we can now delete the top and the bottom and save a bunch of vertices and triangles! In fact, if we had removed the top and the bottom in the first place we never would have had this problem. You may notice that right next to the Split-Section tool in the Mesh menu there is something called the Separate-Selection tool. What is the difference between Split and Separate? Well, Split creates separate vertices and keeps them in the same object. While Separate creates separate vertices (if necessary) and then puts all the selected vertices in a new object. This increases the prim count in OpenSim and therefore the complexity of the build. But occasionally you may wish to create separate objects. I often forget which is which and have to try it one way or the other. So I taught Tenbears how to bring his mesh primitives into Blender, Split off the ends, and save them back as DAE files for use in OpenSim. He commented "I thought Blender was difficult to use, but that is actually pretty easy!" This was my inspiration to break Blender lessons into little Bytes that are easy to learn.