Jump to content
The Dark Mod Forums
Sign in to follow this  
R Soul

Blender TDM Material Manager Plugin - updated to version 2.8.0 (Blender 2.80 update)

Recommended Posts

Updated to version 2.8.0, which is for Blender 2.80 and onwards.

 

The version for 2.79 is here:

https://github.com/RSoul82/Blender-TDM-Material-Manager/tree/Blender-2.79-archive

 

Download (for Blender 2.80):

Go to the GitHub page: https://github.com/RSoul82/Blender-TDM-Material-Manager

Right click the .py file, then go to Save As and put it in some folder.

(Or go to Clone or Download and save it as a zip file to your computer).

 

Be aware that this file isn't synchronised with the one on my PC, and the latter is the one that gets uploaded to Github, not the other way round.

Edited by R Soul

Share this post


Link to post
Share on other sites

A tiny update, same links as above.

 

I found that the material name scanner woun't go to the first line in an .mtr file, so this wouldn't have found the extremely rare occurrence of the material you want being defined right at the start of the file. Most files begin with a comment. I discovered the bug due to writing some custom materials.

  • Like 1

Share this post


Link to post
Share on other sites

Thats brilliant work man, its a shame I cant seem to find any time to work on blender these past few months. Any help with setting up materials is such a blessing, its the single most annoying aspect of modeling for me, all the paths and materials and placing the textures here and there...

Share this post


Link to post
Share on other sites

I've updated this addon. Now, when a texture is shared by multiple materials, it lists each of them as values of a set of custom properties. You can then paste the correct value to your Blender material name, and set the NoChange custom property to keep the chosen material.

 

It does this for collision textures too. You'll end up with 36 custom properties to choose from.

 

Same link as before, but reposting anyway:

Go to the GitHub page: https://github.com/RSoul82/Blender-TDM-Material-Manager

Reinstalling it is very easy. Just download the above, in Blender go to User Preferences > Addons >Install from file. Select the zip file and it'll overwrite the previous version.

Edited by R Soul
  • Like 1

Share this post


Link to post
Share on other sites

I'm having a little issue with it finding me a wrong texture. The shader name is textures/darkmod/stone/brick/rough_big_blocks02 (copied from DR), but it chooses the texture from the file rough_big_blocks02_cornerstone_light.dds, instead of rough_big_blocks02.dds.

 

Meanwhile, is there a way to lock a texture so it doesn't change it when I load textures for new materials?

 

EDIT: I just installed the new version, btw, but it still chooses that wrong texture.

Edited by Skaruts

Share this post


Link to post
Share on other sites

The material can be locked by giving it a custom property called NoChange with a value of 1.

 

I'll look in to the example you gave and see if it's a code bug or if it's an error that can't be avoided. I'll edit this post with my findings, unless there's another reply to this thread in the meantime.

 

edit: On my PC the correct texture is assigned. Does your 'extracted textures' folder have the same structure as the pk4 files. E.g. some_path/stone/brick, some_path/wood/panels etc?

Edited by R Soul

Share this post


Link to post
Share on other sites

I've uploaded the files on to Github which may make it easier for people to view, and to make suggestions etc. I don't have any auto-snyching going on, but I don't expect to be making any changes in the near future. See the first post.

Share this post


Link to post
Share on other sites

Thanks for putting this on GitHub, that's a big improvement over ZIP files on download sites.

 

I'm happy to have a look at updating this for Blender 2.80, but I noticed that you haven't included a license with the code, which means that by default the code is "all rights reserved" and modifications (from other people) aren't allowed. Assuming this isn't the intention, would you mind choosing a license and putting it in a LICENSE file in the repository root? GitHub's default suggestions of either GNU GPL v3 or MIT seem pretty sensible, depending on whether you care about the "share-alike" protection or not.

Share this post


Link to post
Share on other sites

I've done that now. The master branch now has the GPL license. I also reuploaded the file addon in a "2.79 archive" branch to preserve that version while the master gets updated for 2.80. I recently thought about updating it but read about 2.80 not being finished yet, but if you're willing and able, then you have my sword.

Edited by R Soul
  • Like 1

Share this post


Link to post
Share on other sites

Excellent, thanks. I might have a look at this next week, although don't let me discourage you if you were interested in working on Blender 2.80 support yourself — it is your project, after all.

 

You are right that Blender 2.80 is still in beta, but they are saying the API is mostly stable now, with only minor tweaks expected before release, so it should be fine for script developers to start updating their scripts to 2.80.

Share this post


Link to post
Share on other sites

I've begun the process of updating this to work in Blender 2.80. I've got the panel and buttons showing up and am working my way though the errors I get when I try to run things. Material textures seem to have a different structure. Google results may be sparse for now because it's so new, so advice/assistance welcome.

 

Current file on Github: https://github.com/RSoul82/Blender-TDM-Material-Manager

 

edit: Because it's not ready, it's not quite in the Addon format (no 'info' at the start of the file) - it has to be run from Blender's text editor. The controls show up on the right (N menu, under a 'TDM' tab).

 

edit2: It set the correct name for test material I'd set up.

Edited by R Soul
  • Like 1

Share this post


Link to post
Share on other sites

I did actually make a start on the 2.8 update in my Gitlab repository, but did not post anything yet because it wasn't complete. You're welcome to pull changes from there if they would be useful. The script should now load as an Addon in 2.8, and I fixed a couple of the path-based operations to work on Linux (which I'm guessing is not the platform you're working on). I also moved the controls to the Materials panel rather than the Tools panel, since in my tests with 2.8 the Tools panel is far too narrow to contain all of the widgets (it's basically designed just for icon buttons in the new UI).

 

https://gitlab.com/orbweaver/tdm-material-manager

Share this post


Link to post
Share on other sites

Thanks. I've added your changes to my file (on GitHub).

 

Notable changes from 2.79 to 2.80:

The code for checking object visibility has changed

Reading mtr files would crash with one particular file, so I did something to do with encoding.

 

Now that I've got going and we're over the UI hurdle I'm happy to continue. So far I've made the assumption that the the texture is assigned via a material node called 'Image Texture' (the code checks for the file path not just the texture name).

Edited by R Soul

Share this post


Link to post
Share on other sites
Now that I've got going and we're over the UI hurdle I'm happy to continue. So far I've made the assumption that the the texture is assigned via a material node called 'Image Texture' (the code checks for the file path not just the texture name).

 

That seems sensible. It looks like the default for new materials is Use Nodes enabled with a Principled BSDF shader, which can then have an Image Texture applied to various properties such as Base Color. The old-style system of assigning textures without nodes enabled seems like it has been removed altogether, and turning off nodes just gives an extremely primitive material settings panel that does not appear to have any support for texturing.

Share this post


Link to post
Share on other sites

It feels like the ability to load textures is close. The existing code still finds material slots. Each slot seems to contain the actual material (i.e. mat = slot_name.material). In case the user has turned off nodes, I use the code mat.use_nodes = True to ensure they're turned on.

 

if mat.node_tree.nodes.find('Image Texture') == -1: will check if there isn't such a node, in which case it needs to be added

node_tree.nodes.new("ShaderNodeTexImage") adds an image node

 

That's it for now. Why does the day have to end when I'm getting somewhere?

  • Like 1

Share this post


Link to post
Share on other sites

I think it's working. I got a texture loaded and assigned. Updating the screenshots meant I had to test the other features (e.g. overly long material names, duplicate materials etc) and the results were what I expected.

 

I also gave the Material file extractor a test to make sure the zip (pk4) system still works, and it seems fine.

 

https://github.com/RSoul82/Blender-TDM-Material-Manager

Edited by R Soul
  • Like 2

Share this post


Link to post
Share on other sites

Very cool, man. Thanks for this. Will give it a go.

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...