Skip to content

Conversation

@Mets3D
Copy link

@Mets3D Mets3D commented Mar 19, 2025

This PR exports .json material data whenever you export a model.

While most of this data may be useless or yet-to-be-deciphered by the community, here are some of my observations:

  • "TextureMaps" obviously contains the textures.
    • "SamplerName" gives a clue as to the use of the texture. Switch Toolbox's best guess is found in the "Type" property. (eg. a sampler of "_a0" corresponds to the type "Diffuse". But at the end of the day the latter is just a guess, and the former is the true data from the game itself.)
  • "isTransparent" is always True for materials which should be transparent, but also in some cases where they shouldn't. It's never False for materials that should be transparent.
  • texture_array_index properties seem to indicate which terrain texture to use. Sometimes a material uses more than one terrain texture, and it might use the vertex colors or those edges of the mesh which only have 1 face, to blend between them.
  • uking_texture_array_texture properties seem to have something to do with these terrain textures as well, but the exact correlation is hard to gauge. A value of -1 probably means that the corresponding value in texture_array_index can be ignored (so a value of 0 there wouldn't be referring to the 0th terrain texture, but instead it should just be ignored.)
  • RenderState -> _flags is probably the alpha blend mode, among ['Custom', 'Opaque', 'AlphaMask', 'Translucent'].

That's about all I managed to figure out based on Switch Toolbox and bmubin's codebases, but this was already very useful to get more accurate material imports in Blender by using Terrain textures, either when there is an entry in TextureMaps with the texture name "MaterialAlb" or when the mesh using the material has a vertex color available.

In case this PR never makes it in, a build with my fork can be downloaded here.

Demeter Dzadik and others added 2 commits March 19, 2025 14:58
Works with:
- Right click material -> Export
- Right click "Materials" folder -> "Export All Materials"
- Tools -> Batch Export Models

Currently it's not optional, and the amount of data is pretty significant,
but I'll leave that to you if you want to make it optional.

I simplified some structures to make the data more usable, but
I did not try to filter anything so as to avoid incorrect assumptions
about what may or may not be useful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant