Beetle simulation



    I once listened to a podcast in which it was said casually about writing a shader for a bug (25 minutes, 35 seconds) that imitates a rainbow surface (I don’t know how to say it in Russian, but the English language has a term - iridescence). I looked at this character and I wanted to write my shader, but imitating the more real surface of chitin, I will talk about it in the next article.
    However, there was a problem - I did not have a suitable beetle model.

    At first I looked for models on the Internet, but the free ones didn’t like the quality, and the paid ones had a too high price (~ $ 50), all the more, there was no necessary model at all. In general, I decided to make my bug, so I will describe the pipeline that I made for myself.

    1. Search for references
    2. Modeling a high poly model
    3. Retopology in low poly
    4. Creating texture coordinates (flat)
    5. Normal baking
    6. Roasting ambient occlusion
    7. Adding a displacement map to determine the color in the shader (more on that later)

    Of course, pipelines can be different, for example, such items as “creating a concept” or “character rigging” might be present in this. They are not, because in the role of the concept I had refs of real bugs and the model was not planned to be animated. In more serious models, there is also an intermediate retopology of high poly models. For different tasks, different companies use their pipeline.

    References


    Of all the bugs, I liked the color of chrysolin, or rather the subspecies of chrysolina herbacea, the most . This beetle has a beautiful, bright rainbow color, see for yourself:


    So I googled as many pictures as possible and merged them all into one. Also, for a better understanding of the structure, models of other bugs can be useful. As a result, we got a picture that loomed on the second monitor almost all the time the beetle was created (clickable):


    Modeling a high poly model


    Basically, I made sculpting in ZBrush, started with a shell, each object was molded from a sphere:



    In the process of sculpting, you can encounter one problem - pressing a section on the surface - it is squeezed out on the other hand, which is sometimes inconvenient or not necessary at all, to prevent this from happening, you need to enable the BackfaceMask option in the Auto Masking submenu of the Brush menu.

    The Lazy Mouse option in the Stroke menu may also be useful - if you enable it, the brush tracking will be averaged, which will avoid unnecessary jitter and draw smoother lines. The LazyRadius parameter changes the degree of smoothing.

    ZBrush has one cool option that helps to avoid some grid problems - DynaMesh. In fact, it rebuilds the changed part of the grid, adapting it to the geometry. Some do not like it, because after applying this modifier, the grid turns out to be ugly, sometimes it breaks the geometry slightly, but for my needs it came in handy for me. An alternative to this option is to gradually increase the model’s subdivisions and occasionally perform retopology.


    BackfaceMask, Lazy Mouse and DynaMesh

    Gradually added new parts and increased detail:



    Separately, it is worth telling about the eyes. Beetles have faceted eyes, they consist of many hemispheres, you can see that they are located as if on a hexagonal grid:



    It seemed to me that the easiest way would be to model them in 3D Max, I did them something like this:
    first you need to create GeoSphere, set the desired number of segments and convert it to an editable polygonal mesh:



    next , select all the edges and click on the Chamfer button, or rather on the button next to it with it - fields with settings will open. We select the parameters to get something like the screenshot below:



    now select all the vertices and select Weld, configure so that all the vertices at the nodal points merge into one: select



    all the polygons and apply Bevel, you need to extrude them approximately the same height as the cell size, and expand a little:



    once click on the Tesselate button to add polygons:



    and finally, using the TurboSmooth modifier, two iterations were enough for me to get a more or less smoothed version:



    On the grid itself it turned out not quite hexagonal, there are segments consisting not of six, but of five edges. This is due to the specifics of constructing this type of sphere. But for a beetle it will do.

    Retopology in low poly


    Despite the fact that ZBrush has its own tools for retopology, I conducted it in TopoGun, since it is more convenient to conduct it for me there. There is a very convenient tool for smoothing - you can make a fairly large grid, then apply it. This mesh will break into a given number of subdivs, and the new vertices will be located on a high-poly model:



    Again, the eyes are separate, since they are essentially spheres, I took ordinary spheres as a low poly mesh and cut off the invisible part from them.
    As a result of retopology, a model of 60k polygons was obtained. This, of course, is not really low poly, but for a scene consisting of only one object it is normal.


    low poly model

    Create texture coordinates


    I did the sweep in UVLayout - a fairly convenient program based on hotkeys works quickly and clearly, I especially like the way it shows the stretch / compression of polygons in color.



    Cutting the model should make as few seams as possible, but at the same time try not to stretch the polygons too much. Since I will not have a diffuse texture, the seams can appear only in the relief (with normal mapping), they will not be visible on the displacement map and closed. I was more concerned about the lack of distortion of the polygons, so quite a few seams were obtained.

    When a sweep was ready for all models, I imported them into 3D Max to adjust the relative sweep size. This is a fairly important step, as it allows you to increase the detail of critical areas without increasing the texture. So, for example, I deliberately reduced the scan for the beetle’s belly, and increased the heads on the contrary. In the end, I used the standard Unwrap UVW modifier packer, and I got this scan of the whole model: The



    packer does not pack very optimally, and I left a rather large padding so that neighboring segments do not interfere with each other on small mips.

    Normal baking


    Compiled a normal map in xNormal - a rather peculiar program with an "interesting" interface. Offtopic, in general, to be honest, it is surprising that all programs related to graphics have their own unique interface, which is sometimes difficult to figure out even with instructions that you can still find. Although if you take advantage of it for a while, you get used to it and it seems even convenient. But this is just my opinion.



    Since the model consists of several parts - each had to be baked separately, if you try to calculate them all at once - artifacts may occur. The texture size was chosen 4096x4096, for a close-up model just right, if problems arise - you can always reduce it by two or more times.



    Roasting ambient occlusion


    AO calculated in Maya the rendering engine Mental Ray (there were some problems with it in 3D Max, but xNormal did a little bit of distortion with the full list of models, it took quite a long time and by itself has few settings):



    Adding an Offset Map


    If you look closely, it is noticeable that a real beetle has places that differ in color, something like spots on the head and shell:



    To mark these places, I manually painted black and white spots on a separate layer in MudBox. Subsequently, I will use them in the shader to shift one of the color components:



    As a result, we got three cards, all of them can be packaged into one texture as follows:
    • Red and green channels - normal map
    • Blue channel - ambient occlusion
    • Alpha Channel Offset Map

    The final map began to look like this:



    In the next article I will tell you how to apply this map to the model. By the way, here is the previous one.
    The model was pretty clumsy, the grid is not very beautiful, but on the other hand I am not a modeler or artist, I am just studying, I hope the following models will be better. Hope to hear criticism in the comments from real modelers. But in general, the essence of the article is not to show how to model, but what tools exist for this, how the process of creating a static model might look like and prepare for use in the game engine, I think it is useful for a programmer in game dev to know this.



    References



    Also popular now: