Jump to content
The Dark Mod Forums

Suggestion: Phase out long material names (or use an ID system)


R Soul

Recommended Posts

People who use Blender for object editing sometimes run into a problem with material names. It has a character limit of 63. That's usually fine but some existing TDM materials have names which are longer than that, so it becomes impossible to use them. An FM author can make a copy of the material with a shorter name, but that might be adding unnecesary complexity for people who are just making standalone objects to share.

I've been mounting a valiant campain on various Blender forums, and some of their LinkedIn posts, to get them to increase the limit, but to no avail. So it's time to take a different approach. Would it be feasible for TDM to rename long materials? The rendering system would have to intercept and replace calls to the original names, or something like that. I'm not sure if that would be an easy thing to implement or if it would set off a chain of complex events or coding etc.

Another possible approach could be a material ID sytem, so in Blender the material name could be WoodPlanks_4ACFB987B, which would correspond to something like TDM\long\path\to\material\WoodPlanks

That might even be beneficial for shorter material names, as even they are not user friendly to look at in some interfaces.

Edited by R Soul
Link to comment
Share on other sites

  • R Soul changed the title to Suggestion: Phase out long material names (or use an ID system)

I'm not 100% sure (have not tested it) but I have read a long time ago that the material names can be any size, even a single word, like this below 

ivyloose06
{
	qer_editorimage  textures/decals/ivyloose06_ed.jpg

	diffusemap 	textures/decals/ivyloose06_d.tga
	specularmap   	textures/decals/ivyloose06_s.tga
	bumpmap       	textures/decals/ivyloose06_local.tga
}

the name doesn't need to be a path, paths are relative anyway, (relative to the texture folder) and are only important for the textures inside the material itself. 

I think the material name written as a path "textures/somefolder/materialname" is used by the editor to create the folder structure in the media browser, that's all, if you don't give the editor (DR) a "path" it just puts the material in the main "textures" ones. 

Link to comment
Share on other sites

That's my understanding too, but a material hierarchy seems like a good thing to keep. And my suggestion is aimed at helping Blender users make use of existing materials, in which case the users have to deal with what they're given.

Link to comment
Share on other sites

I've experimented with giving models nonexistent material names (for example "virtual/stone") and then using a skin to provide the real texture name ("virtual/stone" would get mapped to "textures/darkmod/very_long_path_to/actual_stone_material").  I found it more useful when trying out different textures on modular-type pieces, but it would also get you around the name limit without having to create a duplicate material definition.

Link to comment
Share on other sites

The material paths will certainly remain as they are.
I think the question is more about the workaround for 63 character limit in Blender models.

Skins can probably do, although... won't you get a warning if your skin maps a nonexistent material name into something?

Maybe we can optionally write material mapping information in some other section of Blender file?
Like description or some kind of extra?
Then take it into account in converter.

Link to comment
Share on other sites

Something could be done. A few years ago I wrote an addon that looks at a Blender material's diffuse texture and scans the .mtr files to work out the TDM material name. Any name over 63 chars long gets saved in a custom property called FullName. An export script could look in there and do a swap. It's worth noting that my addon is not linked to any export process. Any user can make their own custom properties.

I think OrbWeaver did some unrelated modifications to some of the import/export scripts, but it's been a very long time since I've been here so I don't know the current state of that side of things.

Edited by R Soul
Link to comment
Share on other sites

I remember when the Blender limit was 19 characters. At least the developers of Blender have generously allowed us a whole 63 characters to play with, although why the hell anyone thinks it is acceptable to have hard-coded name length limits in 2022 is anyone's guess.

The aforementioned "skin trick" was something I came up with as well: each model had a material name like "sk/my_model" which then used a skin to map the model surfaces onto the real textures. But this is only useful for models which have their own custom texture; it is not so convenient if you want the model to use a regular, arbitrary Dark Mod texture.

I'll have to check the state of the import/export scripts. The custom property approach should certainly solve the problem and I'm sure it has been discussed before, but I don't recall if it actually made it into the code. Perhaps if it hasn't already been implemented, the time to do so is now, given that the 63-character limit is clearly causing problems for some people.

  • Like 3
Link to comment
Share on other sites

ASE exporter now supports FullName as well.

Note that I have combined the two export scripts into a single tdm_export.py which supports both formats. This allows common code to be shared without copy-pasting. If you have an existing version of the ASE or LWO single-format scripts, you will probably want to uninstall this before installing tdm_export in order to avoid conflicts.

  • Like 2
Link to comment
Share on other sites

Interestingly, my main problem with stock materials had been that slash instead of underscore. Since I used Softimage for a long time, I had problems because it didn't preserve forward slashes. I've used underscores in spaces ever since for my own material definitions. I'd love condensed names but that would be an entire duplicate set of mtr defs just to make that possible. The DR material selection isn't all too fun as is, so if these were standard BSP world textures you'd have two of everything.

@OrbWeaver 
That skin method is something close to what I used for testing materials on a single mesh without re-export. What exactly is FullName?

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

FullName is a custom property you can set on a material in Blender, which will be used during export instead of the actual Blender material name. Since custom properties do not have the 63 character limit (I haven't established if they have any limit, but it is definitely larger than 63), this allows you to enter the complete TDM material name to bake into the mesh if it wouldn't otherwise fit in the standard Blender material name.

image.png.bdf198ddb56874e1a5b0c5bac927ba09.png 

  • Like 1
Link to comment
Share on other sites

Ahhh okay, I wasn't sure if that was a new engine feature or a Blender feature. I'm still waiting patiently for a viable fix to material edges being split by the engine at run time. :P

I've despised the material naming convention since I joined the mod. At the same time however, I understand how making the path name the same as the material name can simplify things. But to a degree. It's good rule of thumb to just copy and paste material names anyways, but the path length almost demands that to limit typos. I'm just thankful Maya preserves forward slashes in a material name.
 

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

There is actually no need for the material name hierarchy to reflect the on-disk image file hierarchy in any way (although it might confuse people looking for image files if there were inconsistencies). The material name hierarchy is purely an organisational tool. While it would be possible to have all material names like "wood_1", "metal_2", "polished_chrome" or whatever, there would be no way to browse or organise these in the editor without the virtual directory system. You would end up with every material in a single flat list, which you'd have to browse by scrolling through the 2D texture grid window. Perhaps some people would prefer this, but it seems rather impractical if you have thousands of available materials.

 

Link to comment
Share on other sites

Oh sure, I get that. I myself just give it the same name (or very close) to the model it's based for (eg. arc_transformer_001). You'll always know an Epi based product in the directory if it ends in the _001 convention. I've never had more than 50 variants of a single mesh, like ever; but I just like seeing those three numbers at the end of every name. I think it's from my time on Source modding, beyond that idk where it started. 🤣

I understand that with world building textures it's not associated directly with a specific asset. I still think the arbitrary path name was a bit of a over the top choice though.

 

36 minutes ago, OrbWeaver said:

While it would be possible to have all material names like "wood_1", "metal_2", "polished_chrome" or whatever, there would be no way to browse or organise these in the editor without the virtual directory system. You would end up with every material in a single flat list, which you'd have to browse by scrolling through the 2D texture grid window. Perhaps some people would prefer this, but it seems rather impractical if you have thousands of available materials.

I would bunch the organization under one or two keynames. And then a description. This helps me when I do modeled sets for an FM or a project that drives a whole list. This instance is specifically project related but it could be modified for generic assets too.

"The Mask of Eddius, induction cooler" would then be condensed to, edd_generator_cooler_001

Normally then anything else related to generators would always start with, "edd_generator" and then tack on the rest. Sometimes it can get a tad longer but at least everything in the title is describing the asset that way. Not just defining an arbitrary path with a vague description at the end. Then when you know your asset base, you'd just type the beginning of that and find everything on that category. Swap edd for tdm if it's a stock, generic asset and that's basically how I'd do it if I had the option to go back in time and change the hierarchy.

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 0 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...