[Tutorial] Fix Missing Materials

Discussion in 'Content Creation' started by BiscoMix, Oct 11, 2013.

  1. BiscoMix

    BiscoMix
    Expand Collapse

    Joined:
    Sep 29, 2013
    Messages:
    57
    Correctly Copying Materials From Existing Maps

    If you plan on using existing materials from another map, you’re going to run into some errors. The first problem you’ll have is the missing materials texture that will replace your materials when other people play your map on their computer. This is because the directories are incorrect in the ‘materials.cs’ file located in your terrains folder. In other words, it doesn’t know where to find the materials, so it replaces them with the orange “no material” texture.

    Normally you would add new material to your level using the BeamNG editor. When you save a new material for the first time in the editor for your new map, it will create the materials.cs file for you with the correct directory to your level folder, but it won’t work like that since you’ve copied it from another map folder, and the file is already in the folder. The materials.cs file is the core file that tells the BeamNG engine the material settings, where they’re located on your system, etc.

    NOTE: You will also have this problem when copying terrain and level objects, and there is another file you’ll have to edit in your maps main root folder normally starting with the name of your level and ending in a .mis extension. The same process I’m showing you now can be done to fix missing objects and terrains.

    How to Fix the Directories

    Rather than deleting the materials.cs file and adding the textures again from the BeamNG map editor, we’re just going to fix the directories in the materials.cs file manually with a text editor of your choice. You can use notepad if you don’t have anything else.

    Step One

    Make sure BeamNG is not open, and locate and open the ‘materials.cs’ file located in your 'terrains folder' for your map. Levels/[your level folder]/art/terrians/material.cs. You should probably make a copy of this file just in case you mess something up.

    In this example, I'm using the map Small Island for my screenshots.

    materials_file.jpg

    Step Two

    When you open the materials.cs file, you’ll see something like the image below. This is all of material properties for the terrains in your map. I want you to look at the directories and see if their correctly pointing to your map folder. There is more than one directory throughout the entire file, and they must all be changed.
    materials_file_code.jpg

    Example:

    Let’s say you copied the materials from Small Island and your map folder is called rocky_mountains. It would look something like this after editing the directories.

    Incorrectmaterials.cs file:
    "levels/small_island/art/terrains/Grass-01-D";

    What it will look like after changing the directory to your map folder:
    "levels/rocky_mountains/art/terrains/Grass-01-D";



    Step Three

    Once you’ve correctly changed all of the directories, save over the old materials.cs file. Open your level in BeamNG and make sure that everything is working properly. Now your materials should successfully be pointing to your map folder rather than the folder you copied your materials from. Now people will be able to see your materials for your terrain when they install your map on their PC.

    - - - Updated - - -

    I rewrote this tutorial now that I've had some sleep and I'm not staring at the screen with one eye open like a pirate. I also added a note for terrains and missing objects as well. :cool:
     
    #1 BiscoMix, Oct 11, 2013
    Last edited: Oct 11, 2013
    • Informative Informative x 1
  2. jammin2222

    jammin2222
    Expand Collapse

    Joined:
    Sep 15, 2013
    Messages:
    386
    Thank you for the tutorial, its really helpful!

    I was wondering if you could help me figure out why some of my objects i made in sketchup have lost their textures? I used the material editor on one of my buildings to change the tint of the walls, it seemed to work fine until i reloaded the map. Now i have several missing textures on this and other buildings that had the same textures on it.

    I exported my .dae objects from sketchup into a folder located at level/mymap/art/sketchup.

    for each object there is a folder with textures, a .dae file and a cashed.dts file. There is also a materials.cs file.

    in the material.cs file there are references to objects that i have deleted from level/mymap/art/sketchup. and are no longer in my map because they didn't look right when i imported them. Is this a problem? Do i need to get rid of them? whats the best way to do that?

    I am guessing that the material.cs file is not at fault because this seems to be the correct location of the missing roof texture on my building called stonehouse.

    singleton Material(Roofing_Shingles_GAF_Estates_mat)
    {
    mapTo = "Roofing_Shingles_GAF_Estates";
    diffuseMap[0] = "levels/mymap/art/sketchup/stonehouse/Roofing_Shingles_GAF_Estates.jpg";
    materialTag1 = "Industrial";
    materialTag2 = "Industrial";
    materialTag0 = "beamng";
    };

    The texture is in the folder so why isn't it showing up?

    If i select the building and open the material editor there is a drop down box with the names of each texture on the object. sometimes when i pick a texture from that list the texture appears on the building again. But after reloading the level its gone again.

    I have even deleted the material and tried to add it again but this doesn't work as the texture is stretched or distorted. If i export the building from sketchup again the same problems are still there. even if i give the building a new name.

    I wish i never messed with the material editor!

    I don't know what to do now. What would happen if i deleted the material.cs file in my level/mymap/art/sketchup folder? I guess all my objects would be missing all textures?

    should i delete all my sketchup objects from the map and then the level/mymap/art/sketchup folder and spend ages exporting them all from sketchup and plonking them all down again? I really don't want to have to do that though.

    Cheers for any help, my head hurts.


    EDIT: I found out what the problem is, but its not ideal. When i deleted the old versions of my objects it didn't remove the materials for it. So every future item i tried to import or existing objects that use the same materials would show no material. I fixed this by putting back the texture folders for the old versions of the objects i deleted. This is fine however now i have a ton of duplicate textures in my map folder that are redundant. I don't know why it does this, I would have thought it would just treat the textures for each object individually.

    Is there a way to clear out unneeded / unused assets from the map to reduce the overall file size when it comes to packing the map for download?
     
    #2 jammin2222, Jan 29, 2014
    Last edited: Jan 30, 2014
  3. FunkyHunk

    FunkyHunk
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    126
    I found an easy way to get the materials to stick relatively easy.

    I just copied the material references in the materials.cs from the map I copied the object from.
    In this case from the industrial map to the leap of death map i'm working on.
    I just went to the folder the .dae was placed in, and copied the relevant lines in the materials.cs for the object.
    Then I saved the .cs and loaded the map.

    Worked like a charm.

    Oh, and it seemed that I didn't have to name the whole path for the object either, as long as the .dds was in the same folder as the .dae.

    Example for the bridge in the industrial level, "ind_obj_04_b.dae"

    Code:
    singleton Material(ind_bld_rustymetal_01)
    {
       mapTo = "ind_bld__2__rustymetal_01";
       diffuseMap[0] = "ind_bld_rustymetal_01_d.dds";
       detailMap[0] = "detail_grunge_02.dds";
       detailScale[0] = "0.1 0.1";
       normalMap[0] = "ind_bld_rustymetal_01_n.dds";
       specularPower[0] = "1";
       pixelSpecular[0] = "1";
       specularMap[0] = "ind_bld_rustymetal_01_s.dds";
       doubleSided = "1";
       translucentBlendOp = "None";
       materialTag0 = "Industrial";
        materialTag1 = "beamng";
    };
    
    singleton Material(ind_planks_01)
    {
       mapTo = "Ind_planks";
       diffuseMap[0] = "ind_planks_01_d.dds";
       normalMap[0] = "ind_planks_01_n.dds";
       specularPower[0] = "1";
       pixelSpecular[0] = "0";
       useAnisotropic[0] = "1";
       alphaTest = "1";
       alphaRef = "121";
       materialTag1 = "beamng";
       materialTag2 = "Industrial";
       specularMap[0] = "ind_planks_01_s.dds";
    };
    
     
  4. NkosiKarbul

    NkosiKarbul
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    438
    Nice Tutorial, but i have a strange problem with the material.cs file of some meshes i created.
    It is not about terrain directly, but as its about material.cs files i will just ask for help here, so other people with material.cs problems get more information on the same place. ;)

    I imported the .dae files and the editor did create a material.cs file.
    I fixed some failures of it after playing around with textures and settings a little and everything did work fine.
    Now i removed the materials.cs file to see if he would either create a new one, just fail on displaying the textures or fail and recreate a new material.cs file once i reassign the first texture in the editor.
    But instead, i still see all textures perfectly working fine... i searched the whole map folder for materials.cs files and for references within them, calling my texturenames or polygontag names "singleton Material(Straight2b_Surface)".
    Nothing... Not even in the .mis file inside the main folder of the map. Not a single reference to either my textures or polygon/vertex Tags.

    So my question would be:
    how the hell does the game still know which texture file is supposed to be assigned to which polygon/vertex Tag?

    I want to know this to fully understand material.cs files and texture assignmend, to erase possible failures on the release of my Modular Mesh Road Pack.
    The Torque3D documentation only speaks about the ingame editor and very few lines are about the material.cs file.
     
  5. ultranew_b

    ultranew_b
    Expand Collapse

    Joined:
    Nov 12, 2013
    Messages:
    140
    Open up the .dae file with a text ed and you will see references to your materials in there.

    :D
     
  6. NkosiKarbul

    NkosiKarbul
    Expand Collapse

    Joined:
    Aug 8, 2013
    Messages:
    438
    Hehe, yeah thank you! i found that a little later.
    But still there is only a reference calling the diffuse map, nothing is referencing the normal and specularity map, while the game did know/remember that settings too.
    Does he still get this right because i called them Name_d, Name_n and Name_s and have the .dae in the same folder as all texture maps? So just as all vanilla textures are structured too.
    Can't imagine another way.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice