Workers & Resources: Soviet Republic

Workers & Resources: Soviet Republic

29 ratings
Development of mods (basis)
By Shotkey
The guide contains a comprehensive pipeline for porting models into the game, which will be useful firstly for newbie modders. The guide is written using a building as an example, without paying attention to the intricacies of setting up the building.ini configuration file itself. I show you the basics of the file structure of game objects. You can study the features of setting up complex configs for BUILDINGS and VEHICLES from LovelyPL!
2
2
2
   
Award
Favorite
Favorited
Unfavorite
0. Initial files (my opinion)
For modeling, I recommend using Blender because it is free (available on steam), very easy to learn and has a large arsenal of tools. You should learn the software by special resources; there are plenty of tutorials on YouTube. In general, you can use any 3D editor (sketchfab, 3ds max, Maya etc). Keep in mind that you will most likely need a model editor, even if you download a ready-made model.

A texture atlas is a square image (let's start with this) containing the textures of your model. Almost any graphic editor is suitable for working with textures, but it is better to use Photoshop or at least editors that support working with layers (for example, paint-net). It is best to use photo textures, which are abundant on the Internet. If something is missing, you can find photos and crop them. In most cases, seamless textures are not required. It is highly undesirable to use textures drawn in paint, much less fill with color. If you need a uniform color, you can add a noise filter or decals for scratches and roughness.

We put all the necessary pictures into one file and scale them so that they all have a proportional size. If you want some of the windows to glow at night, then you should make at least two window textures, one of which will then be highlighted. The texture loaded into the 3D editor has unlimited dimensions due to tessellation of the texture space. Therefore, to texture large areas (for example, a wall), seamless textures can be used. In most cases, seamlessness in one direction (tiles) is sufficient: for this, the edges should smoothly transition into each other.
tile texture with an inconspicuous seam

The next feature of model rendering is that the texture can be drawn with some offset, so you need to place textures either taking into account their base color (for example, white next to white), or trim the texture with a margin, or manually paint over a few pixels around the texture (padding).
the lack of padding led to the “creeping” of the adjacent dark-colored texture and the appearance of dark stripes on the border
padding between different textures

When the texture is ready, you can color correct individual layers so that everything is harmonious, and cover up any debris or dirt that is very noticeable. If a fragment of a texture is intended to be used repeatedly, then the prominent details can create an annoying repetition pattern:
texture with pattern and after corrections

The final stage is the “night” texture (emissive), with the help of this file the game will create a glow at night, for example, windows and signs. To create such a texture, you need to paint all non-luminous objects black. Illuminated areas can be white or colored. In the game, the night texture is applied on top of the normal one as a color filter, so by changing the color and brightness you can differ results. It is important that the illuminated areas are at a sufficient distance from other textures (up to 50 pixels), since at a distance the glow will creep onto neighboring textures.
padding of highlighted textures
tile texture is too close to window texture

We save both atlases (texture - diffuse, and night - emissive) in png format and return to the model. We create a material and add our texture there.

Now you need to unwrap the model (UV map of the faces) and place islands of surfaces on a flat texture space. At the same time, do not forget that the texture space has no boundaries; if the atlas has seamless textures, it’s time to use them. We place the islands taking into account the necessary gaps (see above about padding). The islands can be stretched and deformed as you like - the main thing is that it looks the desired way on the model.
1. Export files
If it is necessary for a building to be built in several stages, then it is necessary to split the model into separate objects. (Each construction phase must be assigned at least 1 object to be drawn. Additionally, scaffolding will be located along the rectangular border of these objects.) Additionally, large objects consisting of more than 21,845 triangles must be divided into parts. Select the edges to be separated - "P" - "selection".

Simplify the model by removing all unnecessary edges, check for disconnected vertices, etc.

Check the face normals (the direction of the visible side of the face) - they must be directed towards the outside, otherwise the face will not be visible.
turn on a special visual layer and fix all red faces
pink/purple is the blend of oppositely directed faces


We check the location of the model in space. If part of the model is located below the Z axis, then it must be separated, otherwise scaffolding for this mesh may not appear. The model needs to be centered along the XY axes - the game cursor will be at the zero point of the scene's global coordinates. Finally, we mirror the models along the X axis (this axis is opposite in the game).

We rename all objects - their names will be written in the configuration file in the construction section, so we name them briefly and clearly. At the same time, we take into account that in blender all data blocks of the same type must be named differently. We check the name of the materials: all model objects using a common texture can have the same material. In general, there are no restrictions on the use of several materials and textures by one model, or on the use of one material by several models. Setting up materials will be described in detail later, now the main thing is to name everything correctly, not create “duplicates”, another thing - separate what should be separate.

Export: select all objects of one model, then select export -> “wavefront .obj” -> only selected ones, triangulate, include the material (but generated .mtl file can be immediately deleted). The game has smooth shading, so you can enable “shade autosmooth” and save vertex normals. If you have modifiers, you can enable them too. Note that the model has only one UV map.
export one model from Blender

It is important to mention that for heavy models it is highly desirable to add a lod - a low-poly model that will be used by the game at a long distance. In addition to optimization, the LOD eliminates noise at a distance. An example of creating a log is shown in the appendix.

Next we create the texture. The resolution of the picture must be a power of 2, that is, 512x512, 1024x1024, 2048x2048, etc. Rectangular options are also acceptable, for example 512x1024, 512x2048 etc. The format we use is .dds - in most cases, a compact BC1 (DXT1) will suffice. If there are transparent objects of complex shape (especially windows of vehiles), then you can use BC3 (DXT5), since 1 bit alpha is not enough for smooth transitions. We ALWAYS turn on the mipmap (generation of mip-textures, mipmap generation - look for the checkbox).

If there are no such options, then it is better to download another editor, plugin or converter. I use paint.net, there are also dds plugins for Photoshop - I haven’t tried other methods, but there are a lot of them. The presence of mipmaps in a file can be checked by looking at the weight of the file: if the size in kB is very close to the numbers 128, 256, 512, 1024, 2048, etc., then the file contains only a texture and no additional information has been added. The weight should be approximately 1.3 times greater. Use the mipmaps, Luke.
2. Conversion files
Launch modelviewer (the application in the root folder of the game), load the obj file, save it in nmf. Next, we repeat this algorithm for each model, restarting the modelviewer each time. Now we create the material: new material - save as. Indicate path to the texture and adjust the brightness of the channels.
1. Additional color of sunlit faces. (insert texture here)
2. Emissive color.
3. Basic color, without sun.

Save the material with the name custom.mtl. Typically, the texture colors in the game are significantly different from what you saw in the graphics editor. Typically, light colors become very bright and dark colors become even darker. Sunlight is applied over the base color, the color in the sun (1) is better to make it noticeably smaller than the base color in the shade (3). Luminosity (2) is usually used only for night illumination, but it can also be used to simulate glare - they will appear from the sunny side. With the right setup it can look good.

Unfortunately, the modelviewer does not display real colors from the game, so it is inconvenient to use it for color correction. The easiest way to configure the material is through Notepad:
3. Presetting the building mod
Launch the game, go to the building editor and immediately save. Minimize the game and open this project in the directory media_soviet/buildingeditor/userbuildings/"numbers_name". Add the files custom.nmf, custom.mtl and .dds texture here. We return to the editor and in the second tab select “custom nmf”. Customize the following game function tabs in a creative format. Save the mod (if desired, enable “add to game” and load map to test it).

If there are several buildings and they differ significantly, you can configure each of them in a similar way. If the buildings are similar, then it is enough to configure only one. Configuration through the editor is optional, but provides a convenient interface for configuring basic functions. However, fine-tuning the mod is only possible by editing the code in the configuration file. This can be done later using the information from the LovelyPL guides.

Copy all our templates from buildingeditor/userbuilding to any convenient place. Now it’s better to rename these folders to something understandable. Delete all "element_script" files. Move the previewimage.png file to a visible place, for example on the desktop. Next, open notepad and create .txt file (UTF-8 encoding) with a description of our mod. A couple of sentences will suffice for now, you can add the rest later. Go to the workshop in the game, on the “in development” tab, click the plus sign and fill out all the fields using previewimage.png and the created description. Once an item has been crafted, you no longer need to visit this page until the mod is completely finished.
4. Setting up directories.
Go to media_soviet/workshop_wip and paste the prepared directories into the last folder with a long number. Here we also add our “night” backlight texture (emissive), if needed. Create a copy of the custom.mtl file and open it in modelviewer. Add a night texture in the second “specular” column and save this material as night. If desired, you can reduce the brightness of the channels slightly to make the building darker at night. At night the building is illuminated by the moon, so the diffusecolor tab will have an effect similar to the sun. You don't have to create night material either - the game will use day material, but then the colors may turn out too light.

In "renderconfig" write the paths to files necessary for rendering:

If the mod does not require night material or lod, then the corresponding lines should be removed from renderconfig. Finally, in the building.ini file we change the $NAME_STR parameter - this is a name of model in the game interface. It should be as complete and understandable as possible (and preferably in English), since apart from it and the miniature icon, nothing else is visible for player. Links to folders of all models are entered into workshopconfig:

By this point, there may have been some confusion in the files and directories. That's why I displayed them all in one picture. The arrows here show the hierarchy of files - the order in which the game reads them when loading the map, starting with the workshopconfig file. If something turns out differently, then we finetune this.
Violation of this chain will lead to bugs/crash. There is no need to create .bbox and .fire files. The game creates them automatically when the model is first loaded. Because of this, scaffolding is not displayed on first launch. When replacing a model, these files must be deleted along with the old model so that they are created anew.

A special feature of vehicle catalogs is that there is no “renderconfig”. Material files are opened directly and should be named as in the picture: “material”, “material_1”, …, “material_15” (no more than 16 in total). Paths to other files are specified in the script; preview and bbox files are generated automatically.

Shared files that are used by multiple objects can be moved from model folders to the root or a separate folder. The object folder must have configuration files building.ini and renderconfig.ini, the game will look for them. The remaining files will either be found in the specified path or created automatically.

At the same time, in all links the root directory of the mod is designated as “../”. If you need to refer to another mod from the workshop, then this is an increase in two levels of directories, so write “../../” - and then the path to the desired file, for example “../../2981690321/mtl/custom.mtl "- the game will go to the root folder with mods, open the mtl directory of the mod 2981690321 and load the custom.mtl file from there.
The exception is skins. The path to the target building immediately begins with the mod number.

Let's get back to the game. To speed up the loading of the map, you can disable subscription mods in the your subscriptions tab (uncheck “display subscriptions”). Just in case, check the “logs for debugging” checkbox. We load a new game, activating the game functions necessary for the new mod. In case of serious errors, the game will crash at the initialization stage of buildings or vehicle. You can check the reason for the crash by opening log.html in the root of the game and examining the red lines in this file. Under certain circumstances, a crash may occur that is not related to the mod. Usually in this case the log ends with the line "game initialised". Just try again.

If everything is fine, then check the functionality of the mod. The building appear at the very end of the list of mods from the workshop. (If desired, take screenshots of models for icons and for the workshop here.) For imagegui.png icons, a size of 128x128 pixels is sufficient. Since the icons in the game are small, it is desirable that it be almost completely filled with the model. Pay attention to the brightness of the icon - it may appear very dark in the game. If there is no imagegui.png file, the game uses previewimage.png as the icon.
5. Publication.
If desired, we create our own previewimage.png - a square image less than 1MB in size. We paste it with replacement into the mod folder. The length of the description has some limitation, approximately 5000 characters. About formatting the text of descriptions see here. You cannot use simple "quotes" in the description. If you need them, use «spruce-quotes» (or “divergent quotes”) and any other design options. If we want to make a description in several languages, we first do it in English (the default language). If you don’t know English, you can easily paste it from Google Translator. This will be extremely useful for players who do not know your native language. Insert/write the description into the workshopconfig file in the line $ITEM_DESC "description" - instead of our plug.

Restart the game so that it reads all the changes in the mod files. Open the mod in the workshop section of the game menu, select necessary tags and enable “visibility for everyone” (don’t touch the $VISIBILITY parameter in the config). Confirm the changes and wait for the files to be uploaded to the server - the mod is published! Once you have done this, the mod will appear in the New Mods feed. Subsequent updates will not affect the location of the mod in the feed.

We open the mod in our workshop in Steam (sometimes it may be absent from the general mod feed for up to 30 minutes). All that remains is to upload screenshots of the mod: .jpg format (not .jpeg), size no more than 2MB, and add a description in other languages (if necessary). Note that the screenshots must first be downloaded and saved, and then you need to open this tab again to re-order them. Finally, if the mod uses files from other mods, you must specify the requirement to subscribe to them.

You don't need to subscribe to your mod, but you can do it. For example, if you accidentally deleted a mod from the wip folder or made incorrect changes, you can subscribe and copy the current files from the steamapps\workshop\content\784150\"number" folder.

The mod can be edited with almost no restrictions. The only thing is that it is better not to update the mod or description several times in a row, otherwise the mod may break.

After making changes, you need to restart the game, go to the workshop tab, open the mod and click the green checkmark. The game will upload the modified files to the server. You can edit any files, but changing the main nmf file of a building can negatively affect objects that players have already built on their maps. Changing just the model's UV map shouldn't cause any problems. Edited building.ini will affect only new buildings. The remaining files do not in any way affect the correct operation of existing saves. I have not encountered any problems when editing vehicles: as far as I know, the game does not write anything from the vehicle configs to the save file. Among other things, when updating the mod, a modified image previewimage.png and a description in English from the workshopconfig file are uploaded to the server.

This information should be sufficient. Both questions from beginners and comments/advice from more experienced modders are strongly welcome in the comments!
Appendix - LODS
Models of buildings are replaced by lod when the camera moves away at specific distance. For vehicle, these distances are shorter, and there can be up to three lods. It is desirable for LOD to be significantly smaller than the main model, otherwise the expenditure of resources on storing and processing the additional file will not be justified.

To create lods for vehicles, it is effective to use the “decimate” tool (modifier or in the editor “mesh - clean up”). To create a building floor, we use primitives - we create a new object and adjust its edges to our model using bindings. Matching edges will flicker and ripple as the scene rotates. Next, we add the necessary details that especially stand out from the overall silhouette and are visible from the estimated distance. In general, you need to focus on the external outlines and convex details. The distance between the surfaces of the lod and the model may vary, the baking accuracy can be adjusted.

Sounds easy, but this model also needs to be covered with texture and our atlas is not suitable here at all, because we need to paint over large edges with a uniform texture that will imitate the complex geometry of the main model. To solve this task, we need to “bake” the textures of our finished model onto the lod geometry. Baking lods using blender as an example is shown in the video:
This procedure is purely technical; you just need to set the correct settings. Unwrap lod in automatic mode, set the margin to 2-4 pixels. If you have several lods, it will be good to bake them all together, onto a common atlas (then we unwrap them all together too). We create a new material with our own name and bake all the model objects onto it. To do this, select everything you need (hold ctrl) and select our lod last (it will be active), press “bake”. Let's check what the lod looks like with this texture. If something is not baked, then we play with the “extrusion/ray-distance” parameters, depending on the distance between the lod and the model in problem areas. We save the finished file on disk and bake the night texture in the same way. Lod's .obj is exported separately from the model but according to the same principle.
5 Comments
lnsz2 13 Nov, 2024 @ 11:26pm 
wish I kmew that before starting out on my own!

Very nice tutorial. Using texture atlasses instead of auto-uv is something i am still changing words myself. Much nicer tho
reviest 16 Feb, 2024 @ 1:34pm 
Thanks for this monumental work. It helped me a lot in creating my first buildings.
Bonnie2070 3 Feb, 2024 @ 9:29am 
Thank you, have a nice day.
Shotkey  [author] 3 Feb, 2024 @ 9:27am 
@Bonnie2070 - Perhaps there will be a couple more tutorials about something important and useful. I don't plan to make tutorials about small features or how to use the blender. You see, even this guide about the basics isnt in demand.
Bonnie2070 3 Feb, 2024 @ 5:42am 
Can you make more tutorials about moding?
I'm very interested in this topic.