Modding for Empyrion - Blocks, items, decals, terrains... with Blender !

Discussion in 'Scenarios' started by Kassonnade, Jan 24, 2021.

  1. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Getting ready

    -------------------------------------------------------------------


    I will use this thread to explain how I use Blender (2.83 and up) to make content for Empyrion. I will try to make this as easy to understand and as complete as possible. I will provide more information in following posts regarding materials, UV mapping and texturing tricks to use in Blender to achieve better results, and will refer to external links sometimes for more complete information. That's where I got everything anyways, Google has always been my great friend! :)

    =====================================================================

    In the following posts you will find information regarding the following topics :

    - Exporting to FBX from Blender to Unity
    - Making textures with Gimp for models and decals
    - Making a simple model in Blender to make a prefab in Unity
    - Adjusting UV map on a model
    - Making a prefab in Unity (to do)
    - Working with Decals (to do)
    - Making custom Terrains and Stamps (to do)

    At the end of this post I will join 2 ".blend" files with "helpers" to get the right dimensions and positions for models when working in Blender (to do). Details about these are in the following posts.

    ======================================================================

    First I would suggest to get a copy of Blender, and the one I use is 2.83 because it's the LTS version (Long Term Support) which is the most stable right now, and has most of the popular addons working fine. I always prefer the standalone version so I can set up things my way, and it comes packed with everything needed to get started.

    Get Blender (portable) from here :

    https://www.blender.org/download/Blender2.91/blender-2.91.2-windows64.zip/

    Unzip this anywhere you want, and make a shortcut on your desktop by right-clicking "Blender.exe" - send to desktop (create shortcut).

    I suggest you also get a copy of Gimp as it has many cool features to make textures and edit them easily. It will also be required for Terrain and heightmaps editing ( "stamps") :

    https://www.gimp.org/

    I will also make a short tutorial for textures in gimp, regarding decals and models.

    You will also need to install Unity, and for this you will have to create a free account and provide your e-mail address. No big deal, and once it's done it will allow you to download and install the "Unity Hub" which is required to run any recent version of the Unity Editor.

    Get it from here:

    https://store.unity.com/download-nuo

    For first time users, it's the "start here" button on the bottom left. For others... no need to explain . :D

    Once the Unity hub has been installed, go get the Editor that Eleon recommends to be able to mod the game. The link was provided on the blocks modding thread, so I copied it here:

    https://download.unity3d.com/downlo...4EditorInstaller/UnitySetup64-2020.1.11f1.exe

    Install this thing where you want, and when it's done "link" it (find it) by opening the Unity Hub you installed in the previous step, by clicking on "installs" in the left column, then on "locate" in the top right corner. This will open the browser, and just point it to the Unity install you did in the previous steps (usually it installs in Program Files\Unity\Editor\Unity.exe). Unity 2020.1.11f1 should appear in your Unity Hub after this.

    Unity hub-install-editor.png

    Once you have completed that step, go get the "Example Project" that Eleon provided and put it anywhere you want. The link requires a password, so I will put that link here also :

    This will download a zipped file that you can unzip anywhere on your hard drive. In the Unity Hub, click on "projects" in the left column, then "add" in top right corner, and navigate to the folder you just unzipped which is the "Example Project" to use for modding blocks and items:

    Unity-get-example=project.png

    That's it for the "setup" part. By clicking on the "BlockModelsAndSuitPropsModding" project, Unity will open with everything ready to start. :)

    Next step : basics of Exporting a Model from Blender. I will give more detailed information regarding making models and headprops in following posts, let's just start things by simply seeing if all the workflow elements are linked first.

    .
     
    #1
    Last edited: Jan 25, 2021
    cgw 2, byo13, zaphodikus and 7 others like this.
  2. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Exporting to FBX from Blender to Unity

    ------------------------------------------------------


    Ok. So I will take for granted that modeling and texturing is already done on your model, and you re ready to "export" it into Unity to make it into a prefab to be used in the game.

    First thing to do if not already done is to install Blender's addon to export to fbx format. For this simply go in the top menu's Edit (top left corner) - Preferences and check for the fbx addon, then make sure it's enabled (see picture) :

    .
    enable-fbx-addon.png

    .
    When this is done, make sure that your model's origin is centered on Blender's grid origin, at 0,0,0. Your object's origin is where the little gizmo sticks when we move an object, and the precise origin is the tiny orange dot at the center of the gizmo :

    .
    object-origin.png

    .
    The object's origin will be the point in space that Unity will refer to when showing coordinates, so it's important to have this point precisely where we want it. If the origin is not where we want it to be we can change it simply by placing the desired "origin location" to be at the center of the grid in Blender (move the model) then in "object" menu simply choose "origin to 3d cursor". By default the 3d cursor should be at the center of the 3d grid, and our model's origin will then be placed there.

    If you moved the 3d cursor somewhere else by mistake, simply select it in the toolbar on the left, then press shift-s and a "pie" menu will appear : select "cursor to world origin" to get it back at the center :

    .
    center-cursor-to-origin.png

    .
    Next step is to make sure that Blender's units system is set so the object's scale will be the same in Unity, and that our object is ready to export.

    In the "scene" tab on the right side (see image below), set units to either "metric" or "none" and the scale to 1.000. Next, like I mentioned previously, make sure that your object's origin is where you want it, and centered on Blender's origin (0,0,0) by going in the object menu (see image below) and clicking "Set origin/ origin to 3d cursor" :

    .
    step-001.png

    .
    Once that is done, we have to place the model so it will not be "offset" in the game relatively to where we want it to be. In the previous image there is a big cube representing a BA / CV block, but in Blender and Unity it is only 1 Unit/ meter while in game it should be 2 meters. I put a male model beside it, and it is scaled to be at the same size as the player character in game, so I can have a reference in Blender when making models.

    Next step is to move our model to take into account the fact that the blocks in Unity have their origin at the center, and that once in the game the block will be "pushed up" because it has to rest on one of its faces on the floor or a wall. Move your model down by 0.5 meters to be like in the image :

    .
    move-object-below-origin.png

    .
    Next step is to apply all changes so there is no leftovers from scaling/ rotating/ moving in our model's data that may cause problems with the fbx exporter. This step has already been done in the image above, that is why the object's origin is shown "above" the model, but I will explain this next.

    Now go in the "object" menu at the top, click on "Apply - All transforms" :

    apply-all-transforms.png

    This is the action that will set our object's origin at the right spot so that when we drop it in the scene in Unity it will snap to the exact relative spot to have the right "offset" when we place the object in game. So it looks at the bottom of the cube now, and it will look the same in Unity, but in the game it will be "on the floor".

    The model's "origin" should now be visible in the center of Blender's grid, while our model is "below" it, and this is exactly what we want for this step.

    Now is a good time to save the file. Next step is to prepare textures so the fbx exporter will know where they are, and we don't have to setup the fbx exporter for this. It also makes things easier in Unity when trying to change our textures.

    After saving the file, in the main "file" menu, click on "pack all into .Blend" and this will take all external files we used and save them locally in the blend file, but not in a readable format. For this, still in the "File" menu, now click on "Unpack all into files" and this will write down the textures files individually in a "textures" folder where we saved our Blender file :

    .
    pack-all-into-blend.png

    .
    When clicking on "Unpack All Into Files" a prompt will appear with several options : choose the 2nd one from the top which tells us it will overwrite files in the destination folder.

    Now we can export our model. Before doing anythig else, double-check that only your model/ object is selected (it should be surrounded by a pale orange contour line).

    Still in "File" menu, click on "Export - fbx"...

    .
    export.png

    .
    This will open the exporter window. In there, no need to change anything, just make sure that the items are identical to what I pointed at in the next image :

    .
    export-as-fbx.png

    .
    1- make sure that only your object was selected, to avoid exporting the lamps or the whole scene!

    2- Normally this is by default, but if not then these settings always work reliably (for me). The "!Experimental" button is very important as it will fix the bad rotations when we open our model in Unity. The other options will not have any effect because we chose "selected objects".

    3- Click to export when ready. Warning : the exporter will not prompt you that you may overwrite a file, but at least Blender will put your file name in red to show the problem .

    That's it! From there, I usually "copy" the model (.fbx) into the BlockModelsAndSuitProps\Assets\BlocksModels folder, and this avoids having Unity using its own importer and changing things without telling us.

    Next step will be to make a simple prefab, materials and importing our textures in Unity.

    .
     
    #2
    Last edited: Jan 25, 2021
    cgw 2, byo13, zaphodikus and 5 others like this.
  3. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Making textures with Gimp for models and decals

    --------------------------------------------------------------------


    We can use Gimp to make images and special textures (normal maps, bumps maps, alpha transparency, etc) to be used either as decals or for models in blender, to make prefabs. Here are some basic instructions on how to make some of these "images" and "textures" in Gimp.

    First, the main window when we open Gimp (I will refer to some of its elements) :

    Main-window.png

    We can get any image in Gimp by simply dragging and dropping it in the "Main Window". When right-clicking anywhere in this main window, we have access to the same options (and more) that we can access via the main menu at the top of the window.

    When making something new with Gimp, we can't simply "save as" but we have to "export as" and I will explain the required steps in the first example for Alpha channel image.

    For the following examples I will use a simple "wall" texture taken from a screenshot from the game, to which I added a little bit of color.


    Alpha channel image ================================================

    To make a texture have "transparency" we need to give it an alpha channel and define "what" will be transparent in our image. Drag and drop your image in Gimp's main window, then right-click anywhere on the image to see the "options" menu, and navigate to "Colors / Color to Alpha" and you should see a menu appear with options. I reproduced my starting image with the "Color to Alpha" menu to show the result :

    colors-to-alpha.png

    First step is to choose which color will be the "guide" for the transparency tool. Use the eyedropper tool at the right of the "Color" empty field, and pick a color with it from your image. You should see immediately this color being "faded" behind a checker pattern.

    Making Alpha maps is easier when making our image with a white or black background and then picking this "color" to be "transparent", so we can plan things ahead when drawing our image. If I want to make a window, I can make the "glass" part black or white, and use color for the other parts, to be able to easily make my Alpha channel later in Gimp. In reality, any color can be used as "guide" but this can yield unwanted results because the "Color to transparency" function may make other colors than only the one we want to be transparent.

    The first slider, "Transparency Treshold", will determine "the limit below which colors become transparent". Moving the slider will show its effect.

    The second slider, "Opacity Treshold", will determine "The limit above which colors remain opaque". Here again, moving the slider will be self-explanative, and the results will show on your image as you try different settings.

    These are the only two settings we need to adjust, and the documentation for this can be found here :

    https://docs.gimp.org/2.10/en/gimp-filter-color-to-alpha.html

    ----------------------------------------------------------------------------------------------

    When satisfied with the results, click "ok" and export your image, or overwrite it by right-clicking anywhere and simply choosing "File / Overwrite (your image name)".

    To export the image as something new, right-click "Export as" :

    export-as.png

    You will have to choose the file extension type first, then you can change the name of your file. Gimp will then prompt you with an "export options" menu, and you can set it up like follows :

    export-options.png

    ======================================================================

    Normal map ======================================================

    A normal map gives "relief" to a texture, but it is not shown itself: its role is only to add a "depth" value to another image to simulate 3d with fake shadows. It is a trick to save resources when rendering 3d models in game to make them look more "detailed" than they really are, without the performance costs of elaborate geometry.

    To make a normal map, we can use the same image as the one we use as "diffuse color" and Gimp will apply a simple trick to make a decent "normal map" out of it. This is not the best way to do it, but it is evidently the simplest, and the resulting normal map is usually satisfying for game content.

    Like previously for the Alpha map, simply drag and drop your image in Gimp's main window, then right-click anywhere on the image and choose " Filters / Generic / Normal Map " and this should lead you to an options menu to adjust the normal map :


    normal-options.png


    Here again, the results should show immediately in Gimp's main window, with your original image turned into a weird color. Options are also pretty self-explanatory, and playing with sliders will update the results on the image in the main window.

    normals-show.png

    "Scale" is obviously the most important option, as it will determine the amount of "fake shadow" that will be applied on some parts of the image. You can test many variations, and the best results can be obtained with a simple grayscale image, that will be treated like a regular bump map.

    When satisfied, click on "ok" then "export as..."

    ======================================================================

    Emissive maps =========================================

    An emissive image is simply a "guide" image to show where "light" will be, relative to another image. For example, I can make a wall with a "fake" light on it and this saves up on geometry and performance because it's just a texture exhibiting a "fake" light behavior. An emissive texture does not have to be "transparent" in Unity because just like in Gimp we can chose the precise color that will be "emissive" (like for transparency/ Alpha) with a color picker, but we can save texture space (file size) and avoid visual artefacts caused by secondary colors by making the whole image black and only the "emissive" parts with color or plain white, which makes it easier to change color later down the road.

    Very simple example of "emissive texture" :

    emissive.png

    On the left side, a simple white square and nothing else on the image (black can't emit color). When choosing this (left) image as "emissive" for a decal or in a model's material, we can then specify what color the "emission" will be, and the white square will be there just to show "where" the color should be emitted from. It will then show "through" the other texture (the "diffuse" image/ texture = "visible color" ).

    .
     
    #3
    Last edited: Jan 25, 2021
    cgw 2, byo13, SteveEmpyrion and 3 others like this.
  4. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Making a simple model in Blender to make a prefab in Unity

    -------------------------------------------------------------------


    This post will explain how to make a simple cube in Blender to be used as a CV/BA block. The same procedures can apply to Head Props, with the difference that scale will not be the same, but everything else is identical.

    Explaining how to make various things in Blender would require too much space and time, so I will describe a very straightforward method to make an object, apply a material/ texture to it, UV unwrap/ map the texture on the object, then export it to FBX format to make a prefab in Unity.

    Anyone not familiar with Blender can find it difficult at first, but almost everything can be achieved with just the mouse and a very tiny set of keyboard shortcut.

    Open Blender and delete the default cube. We will make another one right away, but I want to show where things are so delete that poor guy that gets deleted in 99% of all Blender tutorials on the web.

    Now in the "Add" menu, select "Mesh - cube" and the cube should be back in the middle of the scene.

    create-cube.png

    1- this is where we can change "modes" from "object" to "edit". In "Object" mode, the tools at the left only allow certain operations on the object as a whole, and in "Edit" mode we can modify everything "in" the object in a much more detailed and controlled manner, with many more tools and options.

    2- In the "add" menu reside all the "basic solids" we can make, and also cameras, lights, etc.

    So now that we have a cube, let's give it a color by clicking on the "materials" tab on the right side of the window:

    assign-material.png

    1 - select "materials" tab
    2 - click on "new"
    3- click in the "base color" color square (this is the diffuse color)
    4- choose your color in the color picker circle (the ball behind the menu should change color)
    5- give a name for this material, ex. "blue"

    From there, go to the top menu bar of the main window, and click on "Shading" :

    shading.png

    This will open the Shading editor, where we can make more sophisticated materials and effects. For now we only choose an "image" texture and a "normal map" which gives the illusion that the texture has relief and bumps (see post above this one for texture-related tips).

    In the shader editor you can see the basic setup of the simple material "blue" for the cube. Follow the instructions to get an image texture as shown in the picture :

    select-image-texture.png

    This will generate a small "node" that you can place on the left side of the tall node from the "default setup" :

    imagetext-1.png

    Repeat these last 2 steps to get another "Image Texture" node in the interface below the first one, and when it is done click on the top node's "Open" button to get the first image :

    select-image.png

    This will open the Blender file browser. Navigate to your image, select it then click "Open Image" and you should see your image's name in the top node's field :

    1st-image.png

    Repeat these steps now to get your normal map (if you have one) in the second "Image Texture" node. When this is done, you can link both images to the "default" material's main node by clicking on the tiny yellow dot on the right side of the image nodes right besides the word "Color" then drag the "wire" that will appear to connect it into the big BDSF node, on its left side. Link both image nodes like in the following picture :

    nodes-connected.png

    Make sure to connect the first image (the "diffuse" color) into "base color" and the second image (the "normal map") into the "normal" socket of the big node. Your "material" should change in the material browser on the right side, and you should see your object also gets the new material.

    One last step to complete is to add one last node, a "vector". Click once again on "Add" and this time go get a "Vector / Normal Map" :

    get-vector.png

    Once the "node" is generated, just drag it on top of the "wire" linking the lower Image Texture node (the normal map) to the main node, and drop it there : the "links" should connect themselves on each side of the "vector" node. If not, you can connect them by hand so it looks like the following image :

    material-complete.png

    You can lower the "specular" value on the main node if your object looks too shiny, and add some roughness to get a more matte finish.

    That is all for the "material" setup. Next will be a short example how to edit the UV maps for the model to make it ready to export.

    .
     
    #4
    Last edited: Jan 25, 2021
    cgw 2, byo13, zaphodikus and 4 others like this.
  5. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Adjusting UV map on a model

    --------------------------------------------------------------

    Once we have a model with textures and materials, we have to properly UV "unwrap" it so the textures scale properly on our object's faces. This is a simple but sometimes tedious step as we have to check all faces of the model, but fortunately there are many shortcuts and tools to make this easier. The desired results always direct the procedure to follow, but here I'm just making a cube-box so this will be simple.


    Following the previous post, I am now in the UV Editing window of Blender (access from top menu bar) :

    UV editor overview.png

    By default, the left side of the screen shows the UV editor, and the right side shows the standard 3D viewport in Edit mode (1), so we can rotate the view around the object (do not rotate the object!) to select its different faces (2), or we can use the "select" menu (3) and its various options.

    When making a base solid, Blender usually assigns "default" UV coordinates, but this does not translate when exporting a model in fbx format : we have to "unwrap" our model so it generates a UV map to be saved in our object's data. The "cube" here is already "unwrapped" by Blender, but it has no image as reference behind to see where the texture will be on each face.

    To unwrap we use the 3 main tools : move, rotate and scale, to place faces on the parts of the image that we want them to show. In the 3D viewport we use mainly the Edit mode (object mode to see results from time to time), we make sure the "faces" context is selected (#2 icons), and we can either select multiple faces by shift-clicking on them, or using "select all" from the select menu, or any other option. The Faces will not appear in the left side as long as they have not been "unwrapped". The following is a very simple trick to do the unwrapping of a simple object and have total control of each individual face.

    First load the image to be "wrapped" on your model. The image that was loaded in the "shading editor" in the previous steps as base texture (+ the normal map) should now appear in the image menu, so get your image there:

    select-unwrap-image.png

    Your image should now appear in the left window. In the "select" menu from the right window (3D viewport), choose "all" and the whole object should be highlighted. Then in "UV menu, click once on "unwrap" (first item at the top of the menu) and see what this gives as result in the left view : nothing changes, because Blender already "mapped" this cube when it was generated, and we did not change its geometry. But try the same with any other kind of solid and you will see how different "UV unwraps" can look like.

    For this example, I want to map some faces to the same part of the image, and some other faces to have a unique part. In the UV menu, choose "reset" this time :

    UV-reset.png

    This stretches all "faces" so they fit the entire surface of the image, and it makes them all nice and straight to work with, even on models with unregular faces. Now when we pick any face of our model, it will show easily on the left side image. When unwrapping with other methods, some faces will be so small they will be hard to find, and we need to scale them a lot to see how they are placed.

    Now I simply click on one face of my cube, and I can adjust it on the image on the left, while changes are reflected in real time on the right side:

    editingUV.png

    You can click on any vertex, or shift-click several, or use the box select tool to grab them all (click, hold and drag to adjust the box select tool). Most tools have "variants" we can access by simply holding "click" on them (the options will show after a delay) or by right-clicking. For selection there is also "lasso" and "circle", for example, but "circle" is not useful for vertex editing.

    We can also use the "snap to grid" option, expecially when working with flat angles and faces. To rotate a whole face, box-select all 4 corner vertices at the same time, then simply use the rotate tool - works best with grid snapping on, since it rotates in fixed increments.

    I will select all faces on my cube 1 by 1, "scale" them (or just select 2 vertices from one side and move them to same effect) so they fit 1/4 of the image. I can rotate them so the text is showing correctly.

    UV-complete.png

    When this is completed, I can export my model in FBX format and use it in Unity (follow steps in 2nd post of this thread starting from here).

    One important thing to remember when mapping UVs is to check the results regularly, because when stretching faces of a model it can look bad, because some faces will show too many pixels relative to their size, or not enough. Some angled faces have to be mapped and tweaked carefully to avoid showing a distorted texture.

    ===================================================================

    To make head props we can follow all the same steps I explained up to now, with one main difference : the scale and position will require a different setup in Blender, but I will provide an example Blender files (.zip file) in the first post of this thread to help with this. This file has the "player's head" (a copy I made of the same size and proportions) at the exact location required to fit exactly on the player character head, so making anything correctly placed in Blender on the "guiding head" will be placed correctly in game.

    To help make regular blocks and devices at the right "scale" relative to the player (ex. chair or desk) I will provide a .Blend file with a male model (the one shown in some examples above) scaled at the same size as the player character in game. The file will contain the "player model" in 3 positions : standing, sitting in a chair and sitting in a SV open cockpit's position.

    For items, there is presently no definitive solution to place any object precisely on the player (I only found a difficult workaround) because of the weird rotations and positions involved to see "how things end up" in the game when viewed from Blender. I can provide a file with a fake weapon correctly placed so we can use it to make some items held "like a gun" but we can't make weapons for now, and putting something in the player's hand causes glitches with the head turning when we move the player around.

    More to come on this.
    .
     
    #5
    Last edited: Jan 25, 2021
    cgw 2, byo13, SteveEmpyrion and 4 others like this.
  6. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Making a prefab in Unity

    -------------------------------------------------------


    Prior to making anything in Unity, make sure that your destination scenario has the correct folder setup to export the prefabs and other content from Unity. In the "main" folder of your scenario there should be all or some of these :


    Empyrion - Galactic Survival\Content\Scenarios\MyScenario :

    Content\Configuration << where we put our custom config files (Blocks, Items, etc)
    Extras\Pda << just copy the PDA folder and the localization.csv file from Empyrion\Content\Extras
    Playfields\ << for custom playfields
    Prefabs << for your POIs and ships - required for decals
    Sectors or RandomPresets << one or the other, get "RandomPresets" from the Default Multiplayer scenario
    SharedData\Content\Bundles << this is where the "bundles" from Unity will be placed (for crosshairs too)
    SharedData\Content\Bundles\ItemIcons << this is where the custom icons are placed
    SharedData\Content\Bundles\suitprops << this is where the head props from Unity are placed
    SharedData\Content\Prefabs << this is where custom images, sounds and videos for decals are placed
    gameoptions.yaml << get this one from the Default Random scenario folder
    preview.jpg << image shown when choosing your scenario in the game menu
    description.txt << short text presenting your scenario, shown in the game menu

    -------------------------------------------------------------------

    Follow the instructions given in the first post of this thread and open the example project as explained.

    Here is a video tutorial explaining how to make a basic prefab, starting from the last steps in Blender as shown in the post #2 of this thread, just prior to exporting the model to .fbx format (sorry for the sound) :



    Some details might be missing in this video, so feel free to ask on the thread here.

    Among other things, I forgot to mention where Unity puts the Bundles when it has finished building them. They should be in the same location as the example project, in a sub folder called "bundles", so for example:

    C:\...your path to Unity...\Unity\BlockModelsAndSuitPropsModding\Bundles

    .
     
    #6
    Last edited: Feb 11, 2021
    cgw 2, the last TRUE gamer and byo13 like this.
  7. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Working with Decals

    --------------------------------------------------------------

    To get started working with decals, I suggest reading the instructions found on the main decals thread first :

    https://empyriononline.com/threads/v1-3-decals.96511/

    Make sure you have your images ready and refer to the Gimp instructions in post #3 of this thread for specific information regarding how to make transparent or emissive images if needed.

    Here is a small summary of the "default" method explained on the main decals thread :
    -------------------------------------------------------------------------------------------------------

    Point at the location (ex. angled surface or middle of a block) where we want our decal to be (its center), as precisely as possible.

    Open the console (without moving our crosshair) and type " decals clip " and press Enter.

    Alt-Tab out of the game, and in the decals.txt of the savegame simply paste (press CTRL-V ) what the console "decals clip" command has copied.

    Clean up the unneeded decimals that may appear for some values (keep 2 decimal positions) and watch for any "e" in there = it must be removed.

    This gives the exact rotation needed for the decal to fit on the surface, and also its position. Now just format these data pieces into the proper place in you decal definition.


    =========================The basics first ====================



    In our scenario, we should have the following folders set up for decals :

    YourScenario\Prefabs << where we put the blueprint and decals settings file
    YourScenario\SharedData\Content\Prefabs << where we put the images and videos

    In the Prefabs folder, we should have a blueprint and a decals config file with the same name, like explained in the main decals thread. So for example if my blueprint is called "BigBadBase.epb" then my decals config file will be called "BigBadBase.decals".

    Every structure and ship has the core as its center, and even if it can be placed anywhere in a playfield all blocks belonging to the structure will have their position measured in "blocks" distance from the core, apart from the vertical axis (Y) : the vertical axis " 0 " is placed 128 blocks below the core, so the first block above the core will have Y coordinates = 129.

    If we open the console in game and enable the debug info window (di), when pointing at the core we will see its position (x, y, z) as " 0, 128, 0 " :

    NewGame_25_2021-02-11_06-16-25.png

    From there, we know how to calculate the position of our decals without having to point at a block. This can be practical if we want to make a special effect floating in the middle of a room without having to put blocks there to know the position. The decals gun and the console "decalsclip" method both require to point at blocks, but we can use simple coordinates to place decals anywhere.


    ====================Position, rotation and scale ===============================


    In the following image we can see where the origin of the structure grid really is :

    axisorigin-1.png

    Block's positions are all measured from that point, at the bottom corner of the core.

    Warning : the following section is for geeks like me who like to know all details. For simpler methods just jump to part -----

    By default, a decal with a scale of (1,1) as set up in the decals file will always match one block's size. If we want to place a decal to fit exactly over the face of one specific block, since the decals are positioned by their respective center, there will be an offset of 1/2 block if using integer numbers for positions, as seen in the image above.

    If we want to make a symmetrical design with decals (with the core as the middle point), we also have to add an offset of 1 block for all axis in positive values ( +x, +y and +z) because the grid is not centered on the core, but on one of its corners. This means that to place a decal precisely on the center of the first block at the left of the core (so block's x = -1) we have to place the decal at (x = -0.5), while placing the decal precisely at the center of the first block at the right of the core will have to be placed at (x = +1.5)... because the core is 1 block's size too (see image above). The same rule applies in all axis.

    This can be confusing, but a simple trick to remember when trying to make symmetrical designs is to think "axis positive is plus ( + ) then I add one".

    Rotation ===

    Decals can be rotated around the 3 axis, X Y Z, following the directions shown in the following image :

    checkaxis_2020-12-16_20-36-10.png

    For example, the red " F " decal has the default rotation or 0,0,0 so it faces the observer looking towards Z+ direction. The Y axis is not shown but it is the vertical axis.

    Rotation uses degrees, so a rotation of 90,0,0 for the red " F " decal would have it looking upwards, while a rotation of 0,0,90 would have the F turn 90 degrees to the left. Negative values go against the direction shown by the green arrows.

    Because there can be positive or negative rotations, no need to go above/ below 180 degrees. It can happen that when applying rotation on the 3 axis in one change/ edit, the decal does not end up the way we wanted it. To avoid this, it's more reliable to rotate one or two axis at a time, and to avoid big values when doing 2 rotations in one Edit.

    ========================================================================

    I have linked an example scenario with 2 decals below this post, so decals and some settings can be seen in a simple context, and the base structure can be used to test placing /scaling /rotating the decals.


    Unzip this file in this folder : Empyrion - Galactic Survival\Content\Scenario

    There are 2 decals that can be seen in the scenario's Prefabs folder, in the Ba_000_Blue.decals settings file. Note that it's worth repeating that the decals settings files needs to have the same name as the blueprint but just a different extension. The pictures for these decals are in the scenario's SharedData\Content\Prefabs folder.

    When looking at the Ba_000_Blue.decals file, this is what we should see :


    TD-1.png

    There are more parameters for decals than the ones used in this file, this is just an example. I will put a list of all parameters at the end of this post, with information regarding each.


    Start the scenario from the game menu.

    Once in game, we will be looking at a central pillar in front of us, with a decal just above our head. There is also a big transparent grid decal under the base.

    Let's ALT-TAB to get out of the game in Windows, open our favorite text editor and navigate to our Empyrion savegames folder. There we find the savegame for the game we are currently playing:

    Empyrion - Galactic Survival\Saves\Games\NewGame_X\Shared\

    In this Shared folder, there should be one folder named [1001] which contains 3 files. The file we are looking for is the decals.txt file, that we can open in our text editor.

    Note : in the savegame Shared folder, there can be as many files with names like [1001], [1002], [1003] as there are POIs in the playfield's yaml file. They should be in the same order in the decals.txt file as they are in the playfield.yaml file, from top to bottom. This is useful to know to find what folder contains the proper decals.txt file for a specific structure.

    In the present case there is only 1 structure/ POI so only one [100x] file.

    Now we can try changing the rotation of the second decal, for example replacing 0,0,0 with 0,90,0. Save the decals.txt file, get back in the game, point the crosshair at any part of the structure (else this will not work) the open the console and type "decals" then press enter.

    This should update the rotation of the decal on the central pillar, which should now be facing the sun (left side).

    ----------------------------------------------------------------------------------------------------------------------

    This is all what is required to use decals, and from there we can use the decals.txt file in the savegame folder to add other decals and precisely place/ rotate/ scale them, and to quickly see the results in game. We can simply copy/ paste text blocks (the decals definitions and parameters) and just change the image name, position and rotation, etc. Always save the text file before using the "decals" console command, and always point the crosshair at the structure/base so the game knows what structure to update.

    ----------------------------------------------------------------------------------------------------------------------

    The decals control device

    In the example scenario provided with this post I included a Decals Control Device (block) which is linked to the grid floor decal under the base. The block is located 2 blocks below the core and is painted green, and it can be found in the Devices tab of the creative menu.

    When opening the control panel of the base, selecting the control device, we can turn the decal on/ off (visible/ invisible). The Decals Control Device can also be linked by signal logic like any other device.

    ----------------------------------------------------------------------------------------------------------------------

    Alternative methods to place decals

    When we try to place decals so their edges fit neatly to form a 3d shape, or when trying to place them further than the 128 blocks distance from the core, we have no reference since we're out of the structure's grid, there's nothing to point at to get coordinates. Finding the right rotation and position can be very difficult, but there are some ways to make it easier.

    We can simply use the block's coordinates, to be able to place decals precisely even if outside the structure's max grid limit of 200+ blocks (theorically 128 blocks from the origin, in all directions). Since the decals were designed for scenario/ POI makers to be used in POIs and AI vessels this method works best when placing the structure at 0,0,0 in the playfield, but it is not mandatory. In my examples I will consider that the structure was placed at 0,0,0 in the playfield, so when working in Blender the measurements will match those of Empyrion.


    Method 1 : ------------------------------------------------------------------------------------------------------

    One simple trick is to make a scaled-down version of our decals setup, so we can still use structural blocks as guides to place decals, then we can multiply values to get to the desired size and locations. To get the precise location of the decal (its center position) on an angled surface, the easiest way is still to grab the coordinates with the method explained by Hummel-O-War on the main decals thread.

    Here is a brief recap of the method : ------------------------

    Point at the location (ex. angled surface) where we want our decal to be (its center), as precisely as possible.
    Open the console (without moving our crosshair) and type "
    decals clip " and press Enter.
    Alt-Tab out of the game, and in the decals.txt of the savegame simply paste (press CTRL-V ) what the console "decals clip" command had copied. Clean up the unneeded decimals that may appear for some values (keep 2 decimal positions) and watch for any "e" in there = it must be removed.

    ------------------------------------------------------------------

    This gives the exact rotation needed for the decal to fit on the surface, and also its position. Now just format these data pieces into the proper place in you decal definition.

    When all the decals have been placed on the scaled-down model, then just multiply the positions values to what is needed to place the decals out of the 128 blocks limit. Multiplying the scale of decals is much easier than trying to find the precise location of their center position, and can be adjusted last.

    One important point to remember when multiplying position values : do not multiply decimal values, just multiply the integers. This is because 1 block remains 1 block, even if located at 2x the distance, and the decimal value is just used to offset the decal precisely relative to 1 block.

    An example : I have a block at position X = 8, and the decal on it is at 8.5
    I want to place the decal on a block at position X = 19, so I multiply the integer value of X for the decal ( 8 x 2 = 16) but I keep the same decimal, because it's just an offset relative to the block at position X = 16. If I multiply the whole value ( 8.5 x 2 ) then the decal will end up at position X = 17.


    Evidently, this method is not very "visual" but it works, and it implies a bit of maths...

    Method 2 : ------------------------------------------------------------------------------------------------------

    We can also use Blender to help find this information, and this method is much more visual and intuitive, although it requires using Blender, of course.

    In the following video I explain how to work with Blender to solve this problem :

    (Video WIP)



    WIP

    .

    ---
     

    Attached Files:

    #7
    Last edited: Apr 26, 2021
    cgw 2 and the last TRUE gamer like this.
  8. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Making custom Terrains and Stamps

    ----------------------------------------------------------------
     
    #8
    the last TRUE gamer likes this.
  9. Yarbles

    Yarbles Ensign

    Joined:
    Nov 1, 2020
    Messages:
    17
    Likes Received:
    7
    Amazing! Thanks :)
     
    #9
    Kassonnade likes this.
  10. RexXxuS

    RexXxuS Rear Admiral

    Joined:
    Jan 31, 2016
    Messages:
    860
    Likes Received:
    1,437
    Wow, didn't think my export question would trigger such great documentation about everything :D
    Good job and I think this is the joy of self taught things and sharing the knowledge.

    I asked about the export because I must say I had semi fun with the .FBX format. Reading the web it seems even though it is the industry standard, many don't like it really. It became obsolete/outdated here and there. I can't value or devalue such opinions but personally I like the .glb/.gltf format. Maybe I made mistakes with the .fbx pack/unpack process but the same setup with same textures etc. looked different in-game with .fbx and .glb models.
    Also all this rotation/origin float point thing seems more easier with .glb. No guarantee though x)

    Maybe you tried it out yourself already but just in case for research:
    1. I used this addon / package: https://github.com/ousttrue/UniGLTF
    2. I'm using those export options
    upload_2021-1-25_12-26-4.png
    3. Plug and play in Unity really.

    Especially in terms of Specular/Metallic there is a difference how it looked ingame. (the visir)
    I also had different outcomes if it's about the possibility to color your own models with the Texture Gun.

    Anyways, once I finished my work with Config stuff, I can't tell how much I'm excited to build my own models and what not.
    I love Blender :) (btw. you can also find Blender on Steam)

    Keep up the good work @Kassonnade
     

    Attached Files:

    #10
    byo13, Yarbles and Kassonnade like this.
  11. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Thanks @RexXxuS !

    I will try the .glb format to see what you mention about textures. When I complete the part of the instructions regarding making a prefab (above) in Unity, I will address how to make materials. I showed a simple method to get things ready for Unity, but materials and textures can be customized and tweaked extensively in Unity itself, that is why it's not really important that the FBX "materials" system be really good, because I just use it for the model and the UV mapping. In fact there is no need to apply textures in Blender to our models (but it helps visually) : what is the most important is the UV mapping, because that is used by Unity to know how textures / materials should be "mapped" on the model, and we can make these materials inside Unity directly - but not the UV mapping. As for materials, even if they are "included" in the models, the "textures" (images) are not packed in the model and need to be imported separately in Unity in order to be able to edit the materials included in the FBX file.

    The FBX format's main advantage is that it allows to export animations and rigs, which other formats don't support. For simple models we could also simply import the .blend file directly since it's now natively supported by Unity, and we can then see all our objects correctly without having to correct the rotation/ position. But this method has one major drawback : we can't share the "models" and in fact it's not a "pure" .blend file that Unity opens : behind the scenes, Unity uses its own FBX importer to generate the .blend scene's objects, and if the scene has animations or rigs these will not be imported correctly.

    For simple blocks we don't need to import animations, because Unity has nice tools to animate models. But for more complex things or motion, and since FBX and Unity do not understand "constraints" (to restrain movements along certain axis) we then need to use "bone" systems like the ones used in character animation, even for simple things like door hinges or a spinning wheel.

    We can make some blocks have a rotating child in Unity with the template that Eleon provided, and I will try to show examples of "unconventional" rotation (off-axis) to simulate a complex machine, just with a few "bones" and the simple rotation script that is available (on my to-do list).
     
    #11
    Last edited: Jan 25, 2021
    Tsnonak, byo13 and RexXxuS like this.
  12. Tsnonak

    Tsnonak Ensign

    Joined:
    Jun 19, 2018
    Messages:
    10
    Likes Received:
    4
    Very awesome and helpful thread, hats off to you for investing the time helping others learn the pipeline!
     
    #12
    Kassonnade and byo13 like this.

Share This Page