Assets Porting assets to Source 2
Moving to s&box requires our assets to be converted to new formats. This post will cover the full process on how we ported both our testing map and kart model to Source 2 in preparation for early access.
Back in the day in Garry's Mod, it would be a cycle of pure hell to get the model you want into the game. With new technologies such as ModelDoc and the wide variety of tools Valve supplies for Source 2, it's now easier than ever. Today I'll be covering the journey we've had so far with porting assets from Source 1 to 2.
Firstly, to port our assets to Source 2 we're going to need a game that uses it as its engine. Originally, we were going to use the SteamVR workshop tools to avoid paying for a copy of Half Life: Alyx, but after several tries it became clear that it's certainly worth paying for the extra tools (and the ability to walk in your map preview).
Porting our testing map
Porting our map was by far the easiest (for us at least). In our situation we already had the VMF (source) file of the map, which means we can cut out the decompilation steps. Not like this would've been difficult anyway, the Valve modding community is insane when it comes to tools like this, so if you didn't have the source file of the map you can use a tool such as BSPSource.
Hammer 2 is extremely friendly towards VMF files, so all you have to do is open the VMF file and let it convert. We did have the odd issue with texturing, but as our testing map uses only two textures it was as simple as selecting all faces and applying one, and then applying the other to the floor. Pretty simple!
Other tweaks were made too, seeing as we had Hammer open already we did a few extra improvements such as applying a nicer sky-box and lowering the warmth of the sun lighting in the map. Overall these changes made it feel much more comfortable to work in, which is certainly important when we'll be spending a lot of time in it when we get access to s&box.
Whilst porting our testing map was relatively easy, the same cannot be said for our kart model (likely due to its complexity). Currently, there's not many tools out there to assist in porting models from Source 1 to 2. The major one as of right now being source2utils, without this tool I'd definitely be stuck converting our materials still, so shout out to the maintainers of the project.
Once our materials were ported we moved on to porting the model. The first issue we had to overcome was getting the source files back from a compiled MDL file from Source 1. Luckily, when we mentioned tools for decompiling maps, the same applied for modelling, in this case the tool being Crowbar. Crowbar is extremely easy to use, all we have to do is target the game that the model came from and in one easy click of the "Decompile" button we've got the model in a format Blender can handle, well with the use of a plugin called Blender Source Tools. When we got the model in to Blender, all we had to do was export it in FBX format and proceed to ModelDoc.
ModelDoc is extremely powerful, which is great if you know what you're doing. But as our team currently is full of programmers and web developers, we're useless to it. Luckily, with help from the s&box community we managed to import the mesh and apply the materials we ported earlier on.
Of course, it wouldn't be a learning experience for us without coming across several issues. Some of the problems we had were:
- The old physics model doesn't work at all in Source 2.
- Bodygroups need to be re-added when imported into ModelDoc.
- Colour tinting applies to everything. So things that shouldn't be changed, such as the tyres, steering wheel and chassis were being coloured.
As usual, each and every one of these problems was resolved (otherwise this post wouldn't be live). So firstly, our physics problem was easily resolved as ModelDoc allows you to build physics meshes in the software. In our case we don't need super-realistic physics so we can get away with a singular box around the entire kart.
Bodygroups were the easiest to fix, as we only need one bodygroup for the glider all we have to do is create a BodyGroupChoice node in ModelDoc, one being empty for the default option, and then another for when the glider should be visible.
Colour tinting wasn't as simple to fix however, in Source 1 it used the alpha channel of the texture to define whether it should be tinted or not. Source 2 does this differently, it requires you to make a seperate texture where the white spaces are classified as tintable parts. The resolution to this is to; open the texture in your preferred image editing software, select everything in the texture that has an alpha level greater than zero and then fill the selected area with white. After that, export the image as a PNG, go back to ModelDoc, ensure the shader of your material is set to VR Complex, enable tint mask option under colour in the shader settings and then add the tint material you created. This problem definitely took the longest to fix, as you can see from the amount of steps involved.
The final results of these efforts can be seen below, as you can see there's a visible improvement from Source 1 to 2, which is exactly what we expected.
There's definitely room for improvement when it comes to tools that assist in porting assets from Source 1 to Source 2, more specifically on models. As Source 2 is still relatively new technology compared to Source 1 there's still plenty of time for people from the community to arise and make tools for this, which is very likely to happen. For now, we'll make sure to stay as far away as possible from bringing over old assets to s&box as it can be very time consuming, most of the models we need are available now anyway, but we're almost certain there'll be problems when we put them into s&box. Assuming we get a key some time soon.... Thanks for reading today's post as always, it's definitely been a struggle finding things to write about recently, as we're extremely limited on things we can do without access to the game. But anyway, let us see where we are by the next post.