[Tutorial] Fixing incorrectly exported Automation materials (long and pic-heavy)

Discussion in 'Content Creation' started by shdevanski, Aug 15, 2021.

  1. shdevanski

    shdevanski
    Expand Collapse

    Joined:
    Feb 24, 2021
    Messages:
    11
    We’ve all been there. You spend hours crafting the perfect interior for your car, excitedly export it to BeamNG, open it up to check out its majesty, and… what the hell? The whole thing looks like it’s been coated in polyurethane.

    1.png

    This won’t do but fortunately it’s fixable with a little know-how. You’re gonna need two programs besides the game. First is a code editor called Notepad++ (you probably have it already if you are doing BeamNG modding) and the second is Blender, a free 3D modelling and animation program. You don’t have to be intimately familiar with Blender to do what we need to, and I’ll be writing this guide as if you’ve never used it before.

    Step 1) Before you even export your car from Automation, make sure that any fixture slot that’s supposed to be the same material (like leather, chrome, or plastic) is assigned to the same copy of that material out of the “On Car” tab rather than being left as one of the defaults. This saves us a lot of editing later.


    2) Unpack your mod from within BeamNG and open the data folder. (Should by default be My Documents -> BeamNG.Drive -> 0.23 -> mods -> unpacked -> [name of your car] -> vehicles -> [name of your car again]


    3) This is probably the most important step of the whole thing, MAKE A BACKUP OF THE main.materials.json FILE BY COPYING IT TO ANOTHER FOLDER. This file is thousands of lines of code and we are going to be editing it. A single dumb mistake like an extra period or accidentally deleting a comma is going to be impossible to find and will break the file, causing you to have to re-export the car and undo all your work. If you make a backup you can just replace the broken file with that and be on your way.


    2.jpg


    4) Now open up the original materials.json file (from that folder from step 2) in Notepad++. It looks overwhelming but once you understand the rules it’s pretty simple.

    • A) This whole chunk defines one material. It lists what material in the 3D file it corresponds to, and gives a whole bunch of parameters that affect the way it looks in game. We’re only interested in three of them.
    • B) This is the base color. The first three values are your R, G, and B for those of you familiar with image editing or digital art. Not sure what the 4th is. They’re on a scale of 0-1, instead of the usual 0-255 an image editor might give you. All other parameters are 0-1 as well.
    • C) This is the glossiness of a material, with 0 being perfectly glossy and 1 being perfectly matte.
    • D) This is how metallic a material is. Which value means “most metallic” seems to flip flop depending on what normal map is used but as long as you follow my instructions you’ll be fine.


    3.jpg

    5) First, the easy materials. They have searchable names so they are easy to find in the material file. First, use ctrl+F in Notepad++, type the word “leather”, and hit “Find Next”. It’ll jump to the first leather material in the file. You can see where the problem is, the roughness value is set to either 0 or something else extremely low, which is why it’s so glossy in game. Change that roughness value to something higher, I find 0.7 to work well for leather. It is very important not to forget the 0 before the .7. Click “Find Next” to move to the next leather instance and repeat the edit until the search box loops you back to the first one you changed.

    6) Move back to BeamNG so you can see your changes. If you have a PC capable of leaving Beam open in the background through all this, do it. To see the changes you’ve made simply swap your car for any other one, then swap back to it. It’s a lot faster than closing and relaunching your game.

    IMPORTANT: If you reload the car without closing Beam and the change you just made doesn't take effect, it may be a sign you've broken your file. Also sometimes it just happens randomly. Close and relaunch Beam to find out which it is.

    4.png

    Wow! That’s looking significantly better! You can even see the leather texture! Note: If your leather was grey it may appear significantly lighter now, but if you know what you’re doing you can modify those R, G, & B values I mentioned to darken it a bit. Values of 0.15 for all three makes a charcoal color, so start there and increase or decrease as you’d like.

    7) The cloth (here I used it in the footwells and door cards) is still glossy though. To fix it, search the file as before but for the word “alcantara”. Set the roughness for each instance to 1 since interior fabric is typically not glossy at all. As with the leather, non-black shades may appear much lighter after but you can darken them.

    5.png

    8) I also find the exported tires to be way too shiny. Search the file for “tyre” with a y. There should be 2 instances (sidewall and tread), both with a default roughness of 0.4. Change that to 0.6. If there’s a 3rd tire material with a different default roughness than 0.4, leave it as it 's the wheel lip and matches the wheel color.


    9) Alright. The easy stuff is done. If your edits didn’t break the file and you’re happy with them delete your backup and replace it with a copy of your edited file. This way if you screw up the next part you won’t lose all of your changes.

    6.jpg

    10) Now we get to poke around in Blender to find some material names. Open Blender and you’re greeted with this splash screen. Click outside of it to dismiss, then press A on your keyboard to select everything (the default cube, camera, and light source) as we don’t need them. Press Delete on your keyboard to remove them, then go to File -> Import -> Collada (Default) (.dae). A file browser appears, navigate to the data folder we’ve been working in and open (yourcarname).dae. Blender might chug for a few seconds but eventually your car will pop in.

    The only functions you need to know are moving your view around and selecting things. Zoom with your mouse wheel. Click and drag with your mouse wheel to orbit the view around an object. Hold Shift while middle-click-dragging to pan the view. Select stuff with left mouse click, and press the period on your number pad (not the main keyboard section) to center the view on anything you’ve selected.


    7.jpg


    You can see the car model is broken into chunks (called meshes). The placement is a bit wonky but that doesn’t matter. In the top right panel (A) there is a list of all the meshes. You can select one by clicking it there or in the viewport. Whatever you select is highlighted in both places. In the bottom right panel click on the materials tab (B). You can see a list of all materials in that mesh. These names correspond to materials in the file we’re editing and is how we’re gonna find them. You can drag the edge of that panel so it widens and you can see the full material name.


    8.png


    11) I’m gonna fix the inside of the wheel well first, since they always come out glossy when they shouldn’t be. In Blender, select the main body mesh, named (carname)_body0. Press Tab on your keyboard to go into edit mode. You can see the geometry in the mesh, and the other meshes get greyed out. Blender automatically selects everything (orange). Click somewhere in the void to clear it.


    9.jpg

    Make sure your cursor is set to select faces rather than points or edges (A). Select a face inside your wheel well, and if you look in the Materials panel you’ll see it highlights whatever material is assigned to that face (B). If you click “Select” (C) it’ll select all faces with the same material so you can see what surfaces are going be affected by your edit in the next step.


    10.jpg

    12) Search for that material name in our materials file. You generally only have to type the first half (don’t forget to type the underscores) and you’ll get to the right one. We can now fix that roughness value to something higher, like 0.9 or 1.


    11.png


    Tah-dah! Not glossy no mo’. You can rinse, rather, repeat this process with every material on the car that doesn’t look quite right in BeamNG. Most fixtures are part of the (carname)_body0 mesh in Blender, unless you use the vanilla interior fixtures in which case each one will be its own mesh. You’ll have to do some camera tricks in Blender to get your view inside the car.

    When you’re done with a mesh in Blender, press Tab again to leave edit mode and select a different one. The Chassis1 mesh generally has a bunch of materials, set them all to a roughness of 1. That mesh is the floor and frame of the car and is visible from outside and sometimes inside so we don’t want those to be glossy.


    12.jpg


    13) One more thing, the chrome. I don’t like the way the exported chrome looks. It’s way too bright. There’s a snag, however. You can see that when I clicked the button to select all with the same material, it didn’t. The grille chrome and window trim chrome were given their own instances so the edit will have to be repeated for each of them. That’s why Step 1 was important. Some things will always get their own instance (like if you use the same material on the body and on a trim piece) but it reduces the number of materials you have to edit.

    13.jpg

    The default chrome has an RGB value of 1,1,1, which is pure white. Reduce each of those to 0.75. It’s also full gloss and full metallic. We want to make it a bit less of a perfect mirror, so set those 0.1 and 0.9 respectively. Repeat for each chrome bit and voila:


    14.png


    15.png


    We’re all done, and our car looks significantly better! You can tweak other materials (like the wheels, those don’t always look right)) if you’re feeling confident but make sure you keep regular backups of the material file after verifying in BeamNG it isn’t broken.

    16.jpg

    Also, if you use a mod fixture with a custom texture (like wood paneling) it often won’t get exported and the surface will be white, like my seatbelts in the first few images. The easiest way to fix this is to find another material on the car that’s acceptable, copy the whole segment of code from the “Stages" line to the last bracket and comma before the next material (shown), and paste it over the same section of your bad material. There’s also a way to import your own texture file to replace the missing one but that’s for another post.

    When you’re all done, DO NOT SAVE OR OVERWRITE the .dae we opened in Blender. Just close it out.

    I hope you found this post useful, and wish you happy modding!
     
    #1 shdevanski, Aug 15, 2021
    Last edited: Aug 21, 2021
    • Like Like x 4
  2. TheCrySick

    TheCrySick
    Expand Collapse

    Joined:
    Aug 10, 2018
    Messages:
    158
    Thanks a lot mate! This tutorial is extremely easy to understand!
     
    • Like Like x 1
  3. G-Farce

    G-Farce
    Expand Collapse

    Joined:
    Apr 1, 2016
    Messages:
    585
    awesome tut
     
  4. Retrograde

    Retrograde
    Expand Collapse

    Joined:
    Dec 8, 2021
    Messages:
    64
    I cant find main.materials.json in my car
     
  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