Models, normals and sweep
In my humble opinion, the texture artist should be responsible for the scan. Not for the scan itself (it should be done by 3D artists or even individual UV specialists), but its styling. It must determine how the islands should be located, how they should be turned, and how much they can be pulled in a given situation, depending on the requirements.
It is the texture artist (and later, on the surfaces) should determine the scale (scale) of the islands (more on that later).
In this section, we consider models, sweep and normals. Create textures for the first full-fledged model (albeit a simple one) and configure it in the Unreal Engine 4.
')
Attention. It is assumed that by this time you have understood the normal map, and why it is needed. Because in this tutor we will talk about it very often.
Part 1. Pixel here .
Part 2. Masks and textures are here .
Part 3. PBR and Materials here .
Part 4. Models, normals and sweep - you read it.
Models and PBR. Practice
I will not tell you how to create models or how to clean / build a grid. This information can be obtained from a variety of courses that are both freely available and for a fee. Our task now is to sort out the specific limitations in the structures of the models for games and what solutions there are at the moment.
But first we will over texture the model, and for one look at it the first constraint. We will work on this shop:
To do this, we will need to download the mesh itself and the normal map prepared in advance for it (I will explain in more detail below why we prepared it). Link
here .
I would also like to make its base wooden, and its legs metal. Well, a little mud to throw mud. Accordingly, we will need 2 materials:
- tree
- treated metal.
We will not put the dirt into a separate material, but use the generator in the Substance Painter and create the dirt inside the program.
Let's start the practice and create a standard project, indicate the shop, textures and run it:
Please note that this time we will need to specify the Normal Map Format - OpenGL. I already wrote in the last part that normal maps are read in different ways by different programs. And this card was generated for programs that use OpenGL.
We had loaded 9 textures + main mesh.
Now we will not make any layers and folders, but let's consider the shop as close as possible. We are especially interested in the edges of the object:
I selected for example one side of the bench. Now she is the most perfect. That is, the two sides came together in one edge and created an ideal angle. No matter how much we bring this joint, it will always be perfectly smooth. In reality, the ideal angles do not exist, and even a razor blade with a proper increase will be rounded. That is why the ribs look now not cinematic. Such models look very weak, and when we see them in the game, we immediately feel all the weakness of the visual image, even if we don’t notice these angles in the models directly.
This is the first limitation of the model.
Previously, when video card resources did not allow processing millions of vertices in one frame, the solution was in the textures of normal maps. They indicated how the light should begin to reflect so that it would appear as if these boundaries have a rounding. Specifically to this shop, this normal map looks like this:
Even just looking at a set of parameters in the form of this map, you can feel how the normal map will smooth out the corners.
Now let's specify this normal map as the main map (that is, it will always be attached to the result, as the lowest layer without a mask). To do this, we need to open the basic object texture settings and specify our texture in the parameters of the normal maps:
And we look at the result:
This is the first most well-known and frequently used method of dealing with sharp edges - bake chamfer normal maps. That is, the model is still tough, but the normal map at its faces begins to distort the light, which creates the illusion of a beautiful soft chamfer. On the Internet you can find a lot of information on how to do it. For simple objects like this bench, you can not make high-poly models (and not bake it accordingly), but generate a normal map with chamfers in the programs. For example, the
Modo program can do this. Our bench has a normal map generated in Modo.
But let's skip chamfering and continue texturing the bench.
If normals are concaveIf your chamfers didn’t become as smooth as mine, and the hollows got an illusion, then when creating a project in Substance Painter you forgot to change the display format of the normal from DirectX to OpenGL.
Now we will create 2 folders for layers, create and transfer them to each of the 1st layer and paste all texture maps into each layer. Do not forget about naming, so as not to be confused:
Now the hierarchy of layers is not important to us, since these materials (metal and wood) will not intersect with each other - we will not have a situation when metal begins to appear through the tree and vice versa. But we still need masks, so now we need to limit the visibility of layers on different islands, so now add black masks to both folders:
And now let us point out which islands of the scans we should have white on the masks, and which - black. To do this, select the mask and switch to island selection mode:
Click on the model on the main bench (if you select the tree mask) and get the following result:
As you can see in the screenshot, the mask has been updated, and now there is a huge white stripe on it, which is located on the site of the island. Thus paint the entire bench around:
The material of the tree itself was not the most successful, but our goal now is not to make everything as beautiful as possible, but to understand the principles of work.
Do the same with the mask for the metal, noting the visible area with the islands of the legs. Select the metal mask and specify the desired parts of the object:
It is also necessary to climb into hard-to-reach places at the joints and mark the islands we need for both wood and metal:
If you carefully examine the legs, you will notice the
second limitation of the model .
The sweep is not done correctly, and the pattern of steel between the sides of the legs is not consistent - its texture is directed in different directions, which is visually striking (the direction is indicated by arrows):
This is precisely a limitation that can be overcome by leveling the islands and stretching them. Now the island on which the down arrow is drawn looks like this (highlighted in orange):
In order to correct the problem, it is necessary that the island be straightened in one line:
Then we will solve this restriction, but we will have something else - a tie:
Drawstrings are not terrible, if they are not very noticeable, or the texture on them does not give them out. But you need to be careful with them, and sometimes you have to put up with the fact that there may be inconsistencies of materials.
In general, the problem of seams in objects is still not fully resolved. In the future, we will look at other options for how to get rid of seams and even try really cool methods in the next section.
Scuffs on the bench
As we know, on all faces of all things, sooner or later, paint, or pieces of material, begins to split off. There appears a large number of scratches and chips:
So let's create a mask that will allow us to later display the same scuffs, scratches and chips under it.
To do this, open the settings for the main texture (where we specified the normal map), there choose
Bake Mesh Maps .
In the window that appears, remove all unnecessary checkmarks, leaving only the Curvature and bake it by clicking on
Bake [additional name] Mesh Maps :
When the texture is finished, it will be available in the shelf under the Project tag:
And also this texture will automatically connect as the main Curvature parameter in the texture settings. Remove it from there:
If we create a new layer at the top of the hierarchy and set the resulting texture as the Base Color parameter, we will see the following result:
Now we will delete this layer, since we needed it only for understanding.
Next, create a folder, name it Folder Dirt and place it in a folder with a tree OVER layer with a tree. In this folder, create a layer called LowLayer_Dirt, and on the folder itself create a black mask so that the layer does not overlap the result:
We point out that the mud mask should consist of Fill effects in order to add the texture we created (curvature) and the additional “Levels” effect.
Why do we need the “Levels” effect now? You probably noticed that the face mask is too light? Now we will need to trim the colors in such a way as to leave light white places on the edges, and make everything else completely black.
The end result you should get is this:
In this way, we have created a "
boundary of what is permitted " for dirt. Now it is necessary to limit the dirt itself. To do this, apply a black mask on the layer itself LowLayer_Dirt. After that add the Fill effect, and in it specify the Dirt4 mask, which is hidden under the Procedurals tag:
Above, in the screenshot, additional parameters of the Dirt 4 mask are outlined. The fact is that this is not a texture in the format in which we are used to representing it. This is a random number generator according to certain rules. In other words, a procedural texture, the pixels in which have the generated intensity. You can play with the parameters, for example, twist the Balance and Contrast to achieve the desired result. Now change the Height parameter in the LowLayer_Dirt layer to -0.35 and look at the result:
I repeat. Now our goal is not to perfect the perfect painting shops, and work with the basics and training work with masks.
And now homework
In general, we have now considered how to quickly apply masks for specific materials that do not intersect with each other. As you can guess, to apply varnish on the tree - we need to create a layer in the folder with the tree. But now we will not do this, but the task itself remains for homework:
- varnish the tree
- create scratches on the lacquer (those scratches that are only visible at an angle, because they push the varnish, but do not damage the wood)
- create scratches under the varnish
Throw in the comments of your crafts - I wonder the same =)
Total
We deconstructed how to texture models using masks. How to apply dirt, chips and scratches.
So that in the future you have a simple idea of ​​how this all works, remember the rule - one material - one folder for working with it. So you can better control your masks and layers. For example, placing a layer of dirt in the folder with the material you still control at the level of the folder mask the total area of ​​visibility of this material, and now also the dirt on it (or the layer under it). For example, in reality, under the texture (material) there may be another texture - plastic can hide under the metal spraying. In this case, metal is the main layer, and plastic is an additional layer under the metal (although in the tutor above we have a layer with chips and placed above the tree, in fact it is a lower layer in the hierarchy. In other words, this is an error).
Layers of materials, their hierarchy must be calculated before you start creating textures. This is important, because incorrect layouts of the layers can ultimately lead to the fact that you have to start all over again and spend long hours trying to figure out why your texture displays only the metal layer.
In general, on this we close the big topic of how to texture objects for games within the PBR. Everything else is technology. My task is to tell the essence, the basis of all this, so that you will not have further questions like “What is the difference between the Roughness map and Metallic and Normal map?” How to do better and more efficiently? ”
We have examined several constraints that have solutions.
- Chamfer constraint.
- Restriction with the location of the islands.
Both limitations can be bypassed in one way or another. In the first case, we create a normal map that simulates a bend, in the second case, we pull the islands and sacrifice details (create pulls) for the sake of the overall picture.
In the second case, it is also necessary to remember about the directions of the islands - they need to be deployed in a coordinated manner, as is the direction of the pattern in the materials. Otherwise, there will be difficulties described above.
Scan
Put aside for a while in the direction of Substance Painter. Do not close the project, it will come in handy later when we export textures to the Unreal Engine 4.
In this piece of tutorials, we consider the scanning of objects, the density of islands, and finally study the phenomenon of texel density.
And start with texel.
Texel
Texel is a texture pixel (ba-dum-s).
The density of texel and islands
In order not to confuse the monitor pixel (the physical element of the real world, which is always fixed in size) with the texture pixel (the rendered square, which can change its size on the monitor screen and be distorted as a whole), the texture pixel was called texel (Texture and pixel).
There is a fairly complete article on this topic
here . And the translation is
here .
However, we will once again consider this phenomenon, because in the future, if we do not realize the whole idea of ​​texels, then it will be difficult for us to work further. And even more so it will be difficult to become an artist on surfaces.
From this point on, we begin to speak correctly - pixel and texel. Pixel - monitor element. Texel is a textural element.
So, we repeat the traversed, texel - this is the imaginary unit of information display. It exists only in numbers (an array of numbers from various channels), but to make it easier for us to work with the render parameters, textures were introduced as a visual substitute for arrays of numbers. I think no one would be pleased to paint a spaceship with numbers alone, keeping in mind the idea that texel in row 8 and column 453 should be 1 value less than texel in row 284 and column 112. Simply poke a brush in Photoshop.
Renders (visualization systems) read these numbers and display them as squares (texels). Displaying a texel as a square is conditional. And it depends in particular on the density and tension of the islands of the sweep model.
We'll talk about the density of the sweep islands a little later, and now we will discuss the tension of the islands.
Imagine a piece of cloth (if it is difficult to imagine - take any piece of cloth that can be stretched). At rest, the drawing (or material pattern) on it remains unchanged, as the manufacturer intended. But if we begin to stretch the fabric, then the pattern will also begin to stretch. The same effect occurs when we stretch (or compress) the model sweep island:
A scan of the left and right side is arranged like this:
The example shows that having compressed the representation (island) of the left side, we stretched the texels in such a way that they are now displayed on the left side of the cube in the form of rectangular elongated sticks. That is, the texel on the object depends on how the scan of this object is performed. Often in 3D-editors of objects it is possible to trace how strongly the island of sweep is compressed or stretched. For example, in
Autodesk Maya, it looks like this:
Where red shows a strong compression, and blue - stretching.
Island density
Isle sweep should be properly cracked without creating screeds. More islands must be scaled to each other. That is, the area occupied by the island must correspond to the area of ​​the other island. Otherwise, it turns out that one island with a real area of ​​20 sq. Cm will occupy 20% of the area of ​​textural space, and an island with a real area of ​​100 sq. Cm will occupy 5% of the area of ​​textural space. And from here there will be a disagreement in displaying the number of texels on the island:
The island on the right side of the cube is very small and is able to display only 25 texels, on which it is located. In this regard, the render increases texels according to the area of ​​the island, and we see large squares.
On the left, the island is very large - it covers a large piece of textural space and can accommodate more texels, which is what happened on the screen. The upper side has an average size.
That is, in order for the model to be properly textured - it is necessary to level the area of ​​all the islands so that they are equal in relation to each other:
Above is a picture from the article by Habrochanin
Osmandos . His article is
here . Recommended to read.
Texture size
If we return to our cube, we will see that texels on it (black and white squares, in this example) are very large (again, by convention. Imagine that in the current texture the squares are texels). Even if we align all the islands, we still see black and white squares on the sides of the cube:
This tells us that the current texture size is not high enough, so we see texels. But is it?
Imagine that the current texture (it is usually called the “checker” - the texture for checking the correct settings of the islands) has a dimension of 63 by 63 texels. And now we see these texels, because the object is so close to our camera that the size of one texel takes up an area of ​​30x30 pixels of the monitor (conventionally).
And if we move the cube away from the camera?
Now try to see texels on this cube?
Now 1 texel is 1 pixel in size (but this is not accurate). And the size of such a texture is ideal, because it allows you to display all of your texels, and also does not display anything extra and does not hide anything extra. This is the perfect size for this distance.
That is, the size of the textures depends very much on the area that the model scan takes and on the object's distance from the camera. If the object is located at a sufficiently large distance from us - it makes no sense to give it 8k textures on the nail. Even if you make textures for the film - no one will simply see the white strip on the girl’s marigold, whose hand occupies 3% of the screen area.
Total
It is important to understand the scale of the models and where they will be located relative to the camera in order to correctly build the dimensions of the textures. Very often, I saw games from indie developers who neglected these simple rules, and as a result, their textures were not of the best quality.
Do not forget to align the islands relative to each other - this is important and greatly affects the perception. If you open, for example, the game Fallout 4 and start a dialogue with some the NPS, you will notice that the quality of the texture on the clothes of the character is poor, and the face has a maximum texture size:
It is worth remembering that the games are often specifically understate the size of textures in performance needs. And who looks at clothes when a character has such an interesting face with scars?
Large texture sizes take up a lot of space (in memory, I mean). Therefore, many developers make a difficult decision - what to cut and what to leave, if only the game does not slow down on your PC / console / phone. However, we will come back to this question and consider the newest techniques that allow us to avoid such troubles.
Texture baking
What is texture baking?
Texture baking is when a texture package begins to calculate the final result and save it into separate files, with which the model in the game engine is then painted.
Roughly speaking, in Substance Painter we apply layers after layers through masks and other tricks to achieve the final result. We are working on how the final model should look like by mixing various materials. But, if you notice - the harder your combination of layers, masks and materials will be, the harder it will be to process your changes to the program. The fact is that Substance Painter (Any other program for texturing) checks your every change and calculates ALL of the layers and channels you create (and I remind you that you can also add your channels to the layers for anything and everything ), which falls on texel.
And when we are satisfied with the result and are ready to upload it to the game engine, we ask Substance Painter to do the last calculations and create a texture with the parameters for the color of each pixel, and 3 additional textures with the parameters Metallic, Roughness and Normal Map. This will allow us not to unload tons of masks and additional materials into the game, not to force the engine to calculate everything anew, but simply to provide it with the finished result, which it will convert into textures for the model.
In general, with baking textures, we figured out. However, we need to see how the parameters are uploaded to the textures, so that we know how we can control which texture channels go to which data will go. This is important because in the image standards there are still only 4 channels. And we need to be able to choose which channel will go to which parameters, so that we can quickly connect them later.
Now go back to Substance Painter, in our project, and start unloading the textures. To do this, open the window of texture unloading (File - Export textures):
This is how it looks initially. If we expand the set of textures, we will see a list of files that will be uploaded as export:
As you can see, there are 4 texture files that should be exported, against the 9 files that we downloaded.
But we are not interested in them, as the default settings, but we need our own personal ones (or according to the standard of the studio in which you work). Therefore, we will go to the Configuration window :
First, we will create new presets and select them in order not to knock down the already ready ones:
Now let's look at the panel on the right:
Input Maps is the list of channels that we used. Most of them have names, as they are used for PBR for specific purposes. There are 8 channels (from 0 to 7) that are editable, but Substance Painter does not know why they can be useful to you, so the channels have standard User0 - User7 names.
Converted Maps- This is a list of textures that depend on the type of render. For example, Normal Map depends on the engine. And we need to know which API the DirectX or OpenGL engine uses to select the correct normal map for it. Therefore, the Substance Painter selects these cards in a separate category, since the final result will depend on what you choose.
Mesh Maps - those textures that you downloaded along with the object or generated while working on it. We loaded 9 textures. 8 of them belonged to layers (materials), and the 9th normal map for chamfers already belonged directly to the object. In addition to the normal map, we also created a Curvature map for applying chips on it. These maps refer specifically to the object and cannot be used as a basis for materials, therefore they are listed in a separate list.
Now let's take a look at the texture creation panel:
These are the buttons that, by clicking on which you create 1 texture file (more precisely, prepare everything to create it).
Gray - creates a texture with one channel. In this channel we can place any of our settings - Roughness, metallic, specular, emissive. All those settings that work in the same channel.
RGB - creates texture with 3 connected channels. That is, it is intended for parameters such as color (BaseColor), the normal map. That is, for all parameters that use 3 channels to fully realize themselves.
R + G + B- creates a texture with 3 unrelated channels. That is, we have a texture with three Gray - channels. We can specify a parameter with 1 channel in each channel of the texture separately. This is often used for ORM - (Occlusion-Roughness-Metallic). That is, Ambient Occlusion is stored in the first channel, Roughness is stored in the second, Metallic in the third.
RGB + A - you guessed it - 3 connected channels and 1 unrelated.
R + G + B + A - four unrelated channels.
Now, knowing this, think about how many files we need to unload all the information about how the final texture should look for an object.
Right, at least 3 textures:
- RGB - BaseColor
- R + G + B - ORM
- RGB - Normal Map
Click on the textures you want one by one, and you’ll have the following list:
Do not forget to correctly name the textures, otherwise we won’t figure out what and where.
Now we need to specify which parameters in which channels will be stored. To do this, simply transfer the parameters from Input Maps to the desired channels. The normal map needs to be transferred to DirectX, since the UE4 uses this format for reading normals.
As a result, we will have the following set:
Now we switch back to Export. We are there:
- Specify the path where to save.
- Select the presets we created in the Config parameters.
- Select texture type - Targa.
- Click Export.
And voila - the export of textures was a success. Open the BC (BaseColor) texture in Photoshop and look at it:
Do you remember how we created 2 different materials in different layers? Substance Painter folded all the layers, calculated the result of the final version of the texture that will cover the object, and “baked” all the texels exactly the way you disguised them. He did the same with Normal Map, Roughness and Metallic.
If we open the ORM map in Photoshop, switch to the channel display mode and select the last one (blue), we will see a baked Metallic map:
With this map you can imagine where the islands should be metal and where not metal.
Total
We learned how to create ready-made textures for the game engine.
Important.
Now we have learned how to bake textures, making the whole calculation of creating these textures in the Substance Painter. That is, we did everything to get ready-made textures, which we can now use in different engines (with a reservation for processing some PBR parameters). The disadvantage of this approach - if we need to radically change something - we have to go back to the program and redo the textures.
To calculate how to correctly display the color and light from texel - the video card needs to be calculated for each texel. And it will not depend on how many pixels you have on the monitor. It will depend on how many texels are used in the formation of the texture (in the interest we use the standard settings, it means that we use 1024 * 1024 texels). That is, in order to display the texture correctly, the pinter needs to count each pixel and take into account all the layers you have created. This is a laborious task, so earlier (and even now) PBR textures were created mainly in texturing software.
Unreal Engine 4
And lastly, unload our object in UE4 and see our result. I will not describe how to open UE4, how to create a project, how to install it at all, and what buttons to press. For this there are very good courses from
Flakky . Courses are all located on his website
uengine.ru .
Now we consider only the import of our shop and the resulting textures, the creation of a primitive shader and summarize.
To begin, open the project and create a folder “Bench” in it, in which we drop all our textures and object. To import all the textures - just transfer them from the browser to the project. They are imported without any problems and will not be asked for any additional settings. As for the object, when importing it, the Unreal Engine will ask you to specify some settings. In general, you do not need to change anything, except for 2 parameters. They must be disabled:
These parameters are responsible for the import of textures, and they are stored separately.
As a result, in our folder there are 3 textures and 1 object:
Now, in any free space in the project browser, click RMB and select Material:
Call it M_Bench.
Open it and drag all our textures into it. We get this picture:
These are Nodes containers that allow you to visualize the settings so that even a novice can work with them conveniently (thank you so much for the successful implementation of Epic Games nodes. Without Blueprints systems and nodes in particular, many people would have burned heads from numbers and code). White pins (outputs and entrances) on the textures (nodes on the left) indicate that three channels are being fed at once. But the red, green and blue - each channel separately. The last grayish is the alpha channel, but it is not in our textures, so we will not use this pin. On the right is a large node that takes parameters, sums them up and creates a complete material.
The whole principle of the textures in Substance Painter is used here (and in any other game engine) - you specify which parameters are necessary for what, and the program gives the result. In this case, Substance Painter took over most of the calculations, while the Unreal Engine simply adds Painter's finished results and creates a ready-made shader (material) that can be applied to the shop.
It only remains for us to correctly connect the pins and ask the engine to calculate the result for us:
And why I did not stick a red channel from the ORM texture in Ambient Occlusion? I have already mentioned that AO is considered obsolete, since AO is often calculated in real time. And in the material node there is a pin Ambient Occlusion, but it does not work. It is not even taken into account. Left here for some reason. I assume that a sufficiently large amount of work is required to remove it.
So. We have the simplest shader (material) ready, and we can finally paint our shop. To do this, open the shop in UE4 by clicking on it 2 times. And drag the material from the project browser into the material slot:
Here you go. Now you have received your first finished object.
You can see the result yourself, but I will only summarize.
Total
In a very simple form, we learned how to create the first shaders in the UE4 engine. You ask - why is it called Material, and not the shader in the engine itself? It's easier to explain what kind of texture construction format this is - this is the material that is superimposed on the object, and the object becomes beautiful. But the possibilities of shaders are much more (much, hundreds of times more) than just showing textures.
Offtop. Chamfer problem solving
Above, I identified the problem with chamfers and how to solve it. But there is a second method, which we will not fully consider in this part - it is creating chamfers on the model and aligning the normals so that the surface of the mesh creates the illusion of a beautiful chamfer. This chamfer is created by aligning the normals of vertices (tangents). And this method is even more economical for performance than the method with normal maps, and its level of beauty is prohibitively high compared to conventional chamfer texturing. Here is an example of a door that stands in one of our game projects (not yet announced):
I ran across information about this topic only on English-language resources.
Here
The advantage of this method is that we create a beautiful chamfer, while the number of vertices does not increase much, as hard edges are always 2 vertex at one point, and soft edges are 1 vertex and the number increases drawing triangles:
It is worth remembering that we need a normal object map in 99% of cases to create chamfers. A normal map for materials and some individual elements is a slightly different topic.
Total
Oooooh. Well, that part turned out to be big. But she was needed to completely cover the topic of standard texturing. And on this we can stop.
Well, the truth is, we have gone from a barely noticeable pixel element on your monitor to complex schemes of masks that determine the visibility of equally complex layers of materials. The word pixel is finally broken into two - texel and pixel. And they learned how to bake it and connect it in the game engine. At this step, you can draw a
long bold line and say that we have become very real texture artists. Everything else - the beauty of chips on objects, the cinematographic nature of the visual presentation - this is all the accumulation of time and the constant desire to learn new techniques and methods.
You can watch more lessons and improve your skill. For example, in Substance Designer there is a huge anvil of generators, having created which, you can use as their generators of layers. And all those masks that were for mud, can no longer be created manually, but implemented at the level of functions that will do everything beautifully for you.
We must always remember that we consider the range of values ​​from 0 to 1. This is important because standard textures have 8 bits per channel, and HDR textures have wider channels (16 bits or more), which means that the range of numbers there is much greater than 0 to 255. But this is still a range from 0 to 1.
And it would seem that everything is the limit. We have achieved a high level of understanding how textures are created. You can just drop everything and go to work as a texture artist at any company that shares modeling and texturing (as we do, for example).
But is it? Have we really reached the limit in texturing and it won't work out any better?
Or where to grow?
Yes! And we still have one more splint, which will lead texturing to a new technological leap and, in my humble opinion, will be the next generation of texturing.