[Question] Need advice on how to properly apply multimat textures to ships in Blender.

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Wavern427
Posts: 3
Joined: Mon, 22. Jun 15, 23:53
x4

[Question] Need advice on how to properly apply multimat textures to ships in Blender.

Post by Wavern427 »

Using the tutorial here, I have extracted the vanilla ship model files and I am rebuilding them in Blender (version 3.1.2) for a small-ish fan animation project (i.e. the ships are not going to be re-imported into X4, so I don't mind breaking them a little). I have been able to find and apply most of the textures from the games files to the ships, but I am still struggling with properly applying the multimat textures. Specifically, the multimat_diff texture file.

Image https://imgur.com/xW8Bflj

From what I've read in a similar thread (and from what I've seen firsthand when opening the texture up), the multimat texture is a few dozen textures in one package, and "it uses vertex colour (vertex illum channel in Max) to get the needed data on which texture in the array should be used and how it should be modified." (viewtopic.php?t=433476).

In simpler terms, just applying it as an image texture like every other hull texture is not going to work, and I have no idea how to get the vertex color channel technique to work here. Now, I'm willing to do the brute-force method to crack open the multimat file in GIMP and pull all the individual textures into their own individual files so that they can be applied, but the problem is that there's 32 unique non-descriptive texture images in it, and I have no clue how to put the pieces of that puzzle together onto the ships, especially when if I were to apply the texture for the exterior cables, it would also redecorate half of the cockpit as they share the same material group.

Long story short, I'm ideally looking for the magic bullet Blender trick that can parse the multimat texture for me, or at least a way for me to manually sort the textures out.
YellowBelllyBlackSnake
Posts: 19
Joined: Sun, 12. Jan 14, 23:05
x4

Re: [Question] Need advice on how to properly apply multimat textures to ships in Blender.

Post by YellowBelllyBlackSnake »

Unfortunately there is no magic bullet trick to getting the multimat texture into Blender. As far as I know Blender cannot see or use the layers in the texture, so the only way to use it is to extract each layer as an image. Blender also has some trouble with .dds file but it seems to only be a problem with cycles.

To get the vertex colors you can use a vertex color node (or in Blender 2.79; the attribute node with the vertex color layer name) in the shader editor. If the material is being used on more than one object make sure that all the objects have the same name for each vertex color layer.
I believe the first vertex color layer is used to define the colour of the mesh, while the second layer is the one used to specify the texture, smoothness and metalness values.

I have been working on a way to apply the correct texture based on the vertex color, but currently am unsure how the multimat diffuse textures are used as they don't appear to be normal diffuse textures (they're almost look like normal maps). Here's a proof of concept node setup.

https://i.imgur.com/Rj7lMvt.png

I'm basically comparing the hex values of the blue channel, from the vertex color layer, with an RGB node, that has its colour set to the correct hex value for each texture (000014 for multimat20, 000019 for multimat25). I then use the result as the factor for a mix node (could also use a mix shader node instead) to select and apply each texture to the correct area on the mesh.

I've connected the red(smoothness) and green(metalness) channel into roughness and metallic on the principle shader. One thing I'm unsure of is if the smoothness needs to be inverted as it is technicaly the opposite of roughness.

My final node setup will be a bit different, partially because it'll be in Blender 2.79, and partially because I'm unsure how I want to mix each multimat layer (either as a color or as individual principle shader groups). But the general design should work either way.

Return to “X4: Foundations - Scripts and Modding”