How to manually optimize your 3D models¶
If you have a particularly heavy model, let's say over 200 000 triangles, you will need to simplify it in order for it to be processed in Minsar. That is called decimation, or retopology. This will give you a simplified model onto which you will have to project the original textures.
This tutorial aims at providing you with free ways to do these two important steps: decimation and baking. At the end of this tutorial, you will have exported a decimated model and at least one texture (Normal Map).
To apply these textures to your decimated model, we will show you to the second part of the tutorial which deals with that precise question.
We have recently designed a tool which allows for an automatic processing of all the steps you will find explained in this tutorial. However, keep in mind that some objects will not be treatable correctly by this tool.
Part one: Decimation¶
There are mainly two ways to decimate a model: manually or through automatic process. Manual retopology consists in manually reconstructing the mesh, and it gives you great control over the output. However, it can be a fairly long endeavor. Automatic decimation, on the other hand, provides you with a quick way to decimate a model, but you will have less control on the output (though that depends on the tool you use).
In the world of 3d production, there are three main cases for which automatic decimation should never be used. First, if the object must be animated after. Second, if you want to create the texture manually. Third, if someone else must intervene and might need to modify the object.
In this tutorial, however, we will show you the simplest and fastest way to import already-existing, but much too heavy objects into Minsar.
Download Blender and import your object¶
1.1. Go and download Blender 2.80, which is also free and OpenSource.
1.2. Once installed, open Blender. You should see a small welcome window. Just click anywhere to close it.
1.3. Import your model by going to "File/Import...". You must choose the format of your object. For instance, if your object is a .obj, then go to "File/Import.../obj".
In case your model is too large
You might be surprised when importing your object, and see only a portion of it. You can see in the image below that the object is not fully visible. This can often happen with 3D scans. In order to be able to see your model correctly, you can adjust the "View" to about 10 000 (more if you still can't see the object fully).
Keep in mind, though, that if you don't scale it down, it will actually be imported as a very high object in Minsar :) ! We will show you how to do so in the end of this tutorial.
1.4. Select your model by "left-cliking" on it, and hit the "period" key on your numeric keypad. This will center the view on your object. Your model should now be outlined in yellow.
Decimate your object¶
2.1. Duplicate your object by hitting "Shift+D+Enter" on your keyboard. On the top right-hand side of your screen, you have a window with several elements in it. It is called the "Outliner". It shows you all the objects you have in your scene. You can now see that your object has been duplicated.
2.2. Rename both your models in the "Outliner". To do that, "double-click" on each one. Name them "HighPoly" and "LowPoly".
2.3. Hide your HighPoly for now, by clicking on the little eye beside it.
2.4. Select your LowPoly and hit "Tab" on your keyboard to go into Edit Mode. Your object should turn entirely orange. If not, then select the "Face" mode in the tool bar, and hit "A" on your keyboard.
2.5. We are going to clean the mesh, and make sure there are no anomalies. To do that, go to "Mesh/Clean Up/Merge by Distance".
2.6. Hit "Tab" again to go back to "Object Mode". Select your LowPoly, and go to the wrench icon in the panel just below the "Outliner".
2.7. Drop down the "Add Modifier" menu, and select "Decimate".
2.8. In the decimation options, you have a blue bar called "ratio". Currently, its value is 1.00, that is to say that the mesh is still whole, we have not decimated it yet. You can also see that the Face Count is at 500 000 triangles. We will need to decrease the ratio in order to decimate our object. To do so, you can either "click" in the ratio bar and drag your mouse towards the left, or directly enter value to which you want to decimate. For instance, if you want 50 000 triangles, you should put a ratio of 0.10, that is to say reduce to 10% of the current ratio.
2.9. If your object still looks right, you can go lower, and try 0.01. But as you can see in our case, the dress seems to have lost too much detail.
2.10. Let's try about 0.03, which would give us about 15 000 triangles. As we can see, it is better.
2.11. To have a better idea of the general shape of your object, especially if it's organic like this dress, "right-click" on your object and select "Shade Smooth".
2.12. Apply the decimation by clicking on "Apply".
Each case is different
As you can see, each 3D model is different. The decimation part is really a subjective part of the process: you decide whether you would like to favor optimization (and thus less triangles) over quality (more triangles), and thus how much you can decimate. It is really a question of balance. Keep in mind that Minsar can support about 120 000 triangles in one scene. It means that if you put a single object with that quantity of triangles, you cannot put anything else in your scene.
Part two: Transfer textures and details¶
When you decimate a model, logically, you will lose a great deal of detail. However, you can still make sure that these original details will still be visible on your decimated model. How? By creating something that is called a "Normal Map".
The "Normal Map" is basically a texture which will indicate to the renderer (in our case Minsar) how each triangle (or polygon) of the model is supposed to react with light. Indeed, details on a model are actually induced by the orientation of each triangle constituting the detail itself. That is what creates shadows, and, consequently, volumes.
For instance, let's say you have a small cavity on the surface of a high-poly model (the model with a lot of triangles). That cavity is itself made of triangles. It is their orientation which creates the relief, the shape of the cavity.
Let's assume that on the decimated model (the low-poly model), that cavity has disappeared, because the triangles that shaped it are now oriented flat. By asking Minsar to take into account the "Normal Map" I will have created for that model, Minsar will understand that at this precise spot, the triangles are supposed to react to light as though they were shaped in a cavity.
That is how, on our decimated model, a cavity will appear, though it will be pure illusion.
So how does one create that "Normal Map"? Well, we have to "bake" it, from the high-poly model to the low-poly model. This is done into a 3D or texturing software such as Blender or Substance Painter.
Baking basically means asking the software to create a map of the high-poly model's relief, and report it to the low-poly model.
Let's see how to do that in Blender.
Position your models¶
3.1. Let's go back to our dress. In order for the baking to work, you must ensure both of your models are right on top of each other, exactly positioned. But first, especially if your models are not in the center of the scene, you should check their point of origin, that is to say their pivot point. Start by pressing "Shift+S" and select "Cursor to World Origin".
3.2. Then select one of your models, and go to "Object/Set Origin/Origin to Center of Surface". You should see a small yellow dot at the center of your object. Do the exact same thing for the other one.
3.3. Now select one of your models, and hit "Shift+S". In the radial menu, click on "Selection to Cursor". The mode should snap automatically at the center of the scene. Do the exact same thing for the other one.
3.4. Now select both of your models and hit "Alt+G" on your keyboard to ensure they really are on top of each other.
Check your models are UV-Unwrapped¶
In order for a texture (Color, Normal etc...) to be set on a model, the software rendering that model litterally needs a map. That red part has to be there, whereas these small orange dots have to be over there.
That map is called the "UV-Map". To keep it simple, let's say that it is exactly like when you take a paper cube and cut its edges to unfold it and make it completely flat.
Thus, in order to bake a high-poly relief onto a low-poly one, the software will need the two models to be UV-mapped (or UV-unwrapped), that is to say to have a precise map of where to put the reliefs and colors. So let's get back to our dress.
4.1. In your Blender scene, hover your cursor on the corner, just between the "View" panel and the "Outliner". You should see a little cross appear.
4.2. Once you see your cursor change into a white cross, "left-click", and while not releasing your click, drag your mouse to the left. You should see a new window appear. Release your click when the second window is open.
4.3. Click on the "Editor type" on the top left corner of the new window, and select "UV Editor".
4.4. Select your LowPoly and press "Tab" to go into Edit Mode. Once there, press "A" to select all the faces of your model. You should see something like the image below. On the right part of the screen, you have a sort of very distorted bunch of triangles. These are the current UV's of your object.
If you can't see anything on the right side, even though your model is fully selected, that simply means your object has no UV's yet. You will have to unwrap them anyway as explained in next step. That also means you will have to do the same thing for the HighPoly!
As we have just decimated our model, it is good to unwrap it again to smooth its UV's. Basically, there are two methods for unwrapping a model.
The first one, the best, is to unwrap manually. It consists of selecting the edges along which the model will be cut: the seams (remember the flattened cube: you want to unfold your model along seams which will allow for sewing the cube back together). But this is usually a long, meticulous process, and here we will choose the automatic unwrapping.
Automatic unwrapping is way faster, but it can lead to visual artefacts, such as obvious seams. Yet it remains useful if you don't have much time and want a faster pipeline. However, feel free to go and watch this tutorial if you want to learn how to manually unwrap UVs in Blender.
4.5. With all the faces of your object selected, press "U" and choose "Smart UV Project". In the dialog box which appears, in "Island Margin", type something like 0.02. It will make sure that the different parts of your model don't overlap on the map, which could cause a lot of visual troubles. Then click "OK". Let Blender work for a few instants: you will soon see the result on the right side.
4.6. Go back to Object Mode (hit "Tab" on your keyboard), select your HighPoly, and check if this model has UV's. If it does, then proceed to the next step. If it doesn't, then repeat what you have done for the LowPoly.
4.7. If you haven't done this before, "Shade Smooth" your LowPoly by "left-clicking" on it and choose "Shade Smooth". Do the same for the HighPoly.
Prepare the baking¶
5.1. We now have to set the first steps of the baking. You have to start by making sure that the Normal Map will be actually baked on something, that is to say that the data will be "drawn" onto a texture, by the renderer of Blender. Select your LowPoly and go the the "Material" panel.
5.2. You can see the list of materials that are attached to your object. Delete every one of them by clicking on it and then on the "-" sign beside.
5.3. Once the materials are all cleared, create a new one by clicking on "New".
5.4. Click on "Use Nodes".
5.5. At this point, we need to open a third window. Below the 3D View and the UV Editor, you can see that third window. Hover your cursor over the junction between the UV Editor and the window below, then click and drag it up.
5.6. In the "Editor Type" of that window you have just dragged up, choose "Shader Editor".
5.7. In the Shader Editor, you can see two boxes that are linked together by a white string. These are called "nodes". They are little agents that are attached to your object, and define its material. In this case, we have the "Principled BSDF", and the "Material Output". The "Principled BSDF" is a type of material to which we are going to attach the final textures. The "Material Output" is the node that will actually attach the material to your object.
5.8. We will now create the image onto which the Normal Map will be baked. In the UV Editor, start by closing the texture displayed if there is one.
5.9. Click on "New".
5.10. Name your image "Normal_Map". By default, the resolution is 1024x1024. You can write 2048x2048 if you want a higher definition, but beware not to use too many 2048 textures in your Minsar scene, as they are very heavy. If your object is supposed to be alone, then go ahead and put 2048x2048.
5.11. Your image is now created. We now need to attach it to our shader. Click in the "Shader Editor" window, and hit "Shift+A". Choose "Search" and write "Image Texture" (you can also go to "Texture/Image Texture").
5.12. A new node appears. Don't hesitate to scroll up in order to zoom in the window. Next to the "Open" and "New" options, you have a small dropdown icon. Click on it and choose the image you have created in step 5.10.
5.13. Click on the "Color" output of your new node, and while not releasing your click, drag your mouse until you reach the "Normal" output of the "Principled BSDF" node. You will see a white string attached to your mouse. When the nodes are attached, put the "Color Space" of your image node to "Non Color".
Your material is ready. Now we need to create a "cage", that is to say an enveloppe which will make sure your HighPoly will be correctly baked onto the LowPoly. It is very useful, especially for complex concave objects, to avoid that some parts of the object be baked at the wrong places.
5.14. Select your LowPoly, and duplicate it ("Shift+D+Enter"). Name it "Cage".
5.15. Hide your LowPoly, and un-hide your HighPoly.
5.16. Select your Cage, go to the Material tab, delete the material and create a new one as we did earlier. Choose a color by clicking into Base color.
5.17. Activate the viewport render in the 3D View in order to see the colors.
5.18. Select your cage, and go to Edit Mode. Then hit A in order to select all the faces. Your entire object should turn orange.
Selection in Blender
When you want to execute an action on your object in Blender, you must make sure your cursor is in the same window. Blender works by context. If you are trying to hit A but your cursor is still in the Outliner, it is not going to work.
5.19. Hit "3" on the top of your keyboard (not the numeric keypad) to make sure that the faces are selected. By default,you are in vertex mode. You can also switch to the different modes by clicking on the buttons next to the Edit Mode button (which itself allows you to switch between Object and Edit Mode)
5.20. Alright! Now, we need to make sure the cage covers the HighPoly, but just very slightly. We need it to be slightly thicker, so that it encompasses the HighPoly within it. Exactly like a mold. To do that, hit "Alt+S" on your keyboard, and slowly drag your mouse down, very slowly. You will see that the cage will thicken, until the mesh below disappears beneath.
5.21. When you release your click, you can see a small option appear at the bottom of the window, entitled "Shrink/Flatten".
5.22. Open this option by clicking on the small arrow. You can see an "Offset" value. It shows how thick your cage is, and you can adjust it manually to see which value covers best.
5.23. Go back to Object Mode, and observe your object. The color of the cage must be entirely covering your object. If you find some parts that are not well covered, then go back to Edit Mode, select all the faces, repeat the "Alt+S" command, move your faces a bit more, and adjust the whole with the offset value.
Bake that Normal Map¶
Congratulations! If you have survived until now, you are ready to bake your first Normal Map!
6.1. Un-hide your LowPoly.
6.2. Go into the Render tab, and choose "Cycles" as the rendering engine.
6.3. Still in the Render tab, you have an option called "Bake". Unfold it by clicking on the dropdown arrow.
6.4. In the Bake Type, choose "Normal".
6.5. Just a little further down, you have an option "Selected to Active". Check it, and open it by clicking on the arrow. Inside, tick the "Cage" option. A "Cage Object" slot appears. Click inside, and choose your cage.
6.6. Alright it's time to bake! Select first your HighPoly, second your LowPoly. In the Shader Editor, make sure the node containing the image on which we are going to bake is selected, that is to say outline in white. Then hit bake and wait for Blender to work its magic!
6.7. Your Normal Map is now baked! Save it by going to "Image/Save As...".
Now you have two possibilities. If your object does not have a color map (that is to say a colored texture), you can hereby export your model with it's Normal Map. For that, proceed to the "Export" section. If you do have a color map on your model, then you will need to transfer it as well from your HighPoly to your LowPoly. To do that, proceed to the "Bake Diffuse Map" section.
Bake Diffuse Map¶
The "Diffuse" Map is another name for the "Color" Map, that is to say basically the color texture of your model. The baking process is exactly the same as for the Normal Map,, except a few options.
7.1. In the UV Editor, close the Normal Map by clicking on the cross.
7.2. Create a new image, exactly like we did in step 5.9. Name it "Diffuse Map". For the best result, put the resolution at 2048 x 2048 pixels.
7.3. Into the Shader Editor, click on the Normal_Map node and hit "Shift+D" to duplicate it, then place it anywhere in the window by clicking again. You can also hit "Shift+A" and add a new texture node, as we did in step 5.11.
7.4. Open the image menu inside the node, and choose the Diffuse you have just created.
7.5. Attach the diffuse node to the "Base Color" input of the "Principled BSDF" node.
7.6. Let's go back to the Render tab. All you have to do is change the Bake Type from "Normal" to "Diffuse", and then un-select "Direct" and "Indirect" so that only the "Color" option remains blue.
7.7. Then do exactly what we did in step 6.6. Select first your HighPoly, second your LowPoly. In the Shader Editor, make sure the node containing the Diffuse Map is selected, that is to say outline in white. Then hit bake.
7.8. Your Diffuse Map is baked, you can now save it as well.
Part three: Export your model¶
7.1. Select your LowPoly. You can hide the cage as well as the HighPoly you don't need them anymore.
7.2. Start by checking the size of your object. As you can see, our dress is 700 meters high, which is a little bit too much!
7.3. Hit "S" on your keyboard. You will see a double arrow appear. Slide your mouse towards the center of the scene to scale your object down until the dimensions are less huge.
7.4. You will see that at some point, you cannot get further down in the dimensions. Hit "Period" on your keypad to center the view back on the dress, and repeat the scaling down until you have the size you want.
Another way of scaling down
A faster and easier way to scale down an object is to put a ratio directly into the "Scale" values of the object. In X, Y and Z, put something like 0.10 to reduce the size at 10% for instance.
7.5. In the 3D View, hit "Ctrl+A" and choose "All Transforms" in order to bring back all the scales values to 1.
7.6. Your object is now ready to be exported. Go to "File/Export.../.gltf 2.0 (.glb/.gltf).
7.7. In the export options, check the "Selected Objects" option, to ask Blender to export only your LowPoly. Choose the .glb format. Then choose the folder where you want to save it, and export by clicking on "Export glTF 2.0".
You have optimized your object for Minsar! You can now import it and admire it in your scene.
For further information
To know more about baking, feel free to go check Blender Guru's "How to bake perfect normals" as well as AT3D's "Bake Normals in Blender 2.76". If you want to know more about applying textures to your object, you can go check our tutorial about converting a 3D model to glTF..
Where to find the dress
This dress is a scan from the collection of the Santa Cruz Museum of Art and History.