Page MenuHome

Update online_mat_lib to new group API
Closed, ResolvedPublicPATCH


This patch updates online_mat_lib to the new group API introduced in 2.67.
Adds support for nested groups
Adds support for multiple groups in one text block/file - normally only material export

Smaller changes -
multiple instances of <?xml...?> header string to global var
duplicate instances of many replace()'s for bad filename chars moved into function
material name saved as attribute and used on re-creation

Known limitations -
nested groups saved to multiple files don't import - they may link with an existing group with a matching name on import
I updated the blender version to 2.69 - I believe it should work with 2.67 or higher. I have not included any version tests to support older versions.

Event Timeline

Shane Ambler (sambler) raised the priority of this task from to 90.
Shane Ambler (sambler) updated the task description. (Show Details)
Shane Ambler (sambler) edited a custom field.

I also found a fix for frame nodes, which also expands node data to include width and height

Brecht Van Lommel (brecht) lowered the priority of this task from 90 to Normal.Dec 21 2013, 11:30 PM

hi sambler,
I'll look at this patch soon. thanks & sorry for delay.

A few changes have been made to the online_mat_lib addon since my previous patch. This new patch replaces both previous patches to be applied against the current master of online_mat_lib with some newer fixes as detailed below.

Previous (2) patches updated to recent changes in master
Includes whitespace cleanup
Use of height and width properties changed to node_height and node_width to prevent conflicts with script input names
Update bundled pool_tiles which used an external group file to have the group within the bcm file.
As the blender version in bl_info has been increased to 2.74 I have removed code to support blender < 2.67
Fixed curves within groups (RGB and Vector curves)
Adjusted brick texture properties to work with node position data
Change print statements that are only needed for debugging to debugout()
Change error message for missing external files to a warning to prevent stopping mid creation.
When an osl script is not available we catch the exceptions from missing sockets so that the rest of the material can be linked, this allows a more complete node tree when only one node fails to link.

Added support for new nodes -
volume absorption
volume scatter
subsurface scatetring
point density
separate/combine xyz
separate/combine hsv
vector transform

Known issues - bcm files linking to external group files fail to load the external group. As I am only aware of one material with this I have merged the group into the one file.

hi, thanks very much for the update, I will test out over the next few days with some feedback :)

@Shane Ambler (sambler)
hi, thank you very much, I do prefer files to patches, I know you have invested much time in this addon with your osl files & library. I wonder if we could move the online part to github address. Any ideas on this?
Thanks again, update seems to work fine, just a few more tests to do with editing categories & adding new content, looks great so far.

committed update rBACf801871441f6fc4daabb1098ac5e9c6db0521f90
I will leave this open as I have also a content update to add.

Content update adds new category's & materials. I have made this as small as possible without giving the user nothing.
to test, replace the bundled folder in the addon with the new one.
As this adds 380kb to contrib addons I won't commit until approved.

This is using addons for asset-storage, for some presets - it can be handy.

But not so keen on storing entire material library in our addons repo. Especially since different people probably like to make their own material libraries.

Why not allow access for online materials so its not needed to include so many?

I had noticed the cache and user materials being saved to the installed addons folder but haven't addressed the issue. While including some bundled materials is fine, the online cache and user saved materials should be moved.

I think the cached files (downloaded from the online collection) should only go into bpy.utils.script_path_user()

Then user saved materials should go into either bpy.utils.script_path_pref() or bpy.utils.script_path_user().

@Campbell Barton (campbellbarton)
I understand your concerns. It's not the idea to supply a fully fledged materials library from within this addon. It is the idea to supply a basic set of usable materials to get users started with Cycles materials from within this addon as "Bundled Presets or Samples".
The existing "Bundled Materials" were outdated & incomplete. As we finally have the correct update from Sambler, I took this opportunity to fully test & update the "Bundled" materials. I have been very selective & aware of keeping this low size without harming the integrity of the now completed "Bundled" materials. I started with 900 materials & broke this down to around 100 to keep the file size low, there were many quality materials left out, to keep the low file size. We have had this addon in contrib for considerable time in an unfinished state. It would be nice to finalize the "Bundled" section.
After this I will look at the "Online Section".
@Shane Ambler (sambler)
hi again, I don't like/understand with the cached materials online section stuff, I think it would be easier to add a button to d/l at once all the extra content from github directly to the addon. I have some example code for that here:

that should do the job well. I'm prepared to do the materials & index & use your existing osl matlib files.
I would keep testing & release folders, but populate them via an "Add Extra Content" button.
This would of course be read only, any new materials people want to add to the library would need to do pull request or submit the material via mail for evaluation.
let me know what you think.

@Brendon Murphy (meta-androcto)
I think the addon update is a good idea but expect it to be less useful if we can get this accepted as a standard addon. After downloading an update it would be nice to reload the addon automatically. While it is possible to disable and enable the current addon I don't know if it would be 100% reliable and doubt it would be acceptable practice.

@Campbell Barton (campbellbarton) - how bad is calling addon_utils.disable(__name__)/enable(__name__) in an operator? Could a reload() be easily added to addon_utils to allow an addon to safely reload itself after downloading an updated version?

As for updating the materials and caching the downloaded files, it is easy to keep the bundled materials small but an online repo could grow to many gigabytes. The cache allows downloading just the materials you are interested in looking at without forcing a complete download, for those that look through each material - only new or changed materials will need to be downloaded (provided they don't delete the cache).

I would be interested to hear whether @Peter Cassetta (petercassetta) is still interested in maintaining this addon and/or his online collection.

I have an idea to re-code this to make it easier to maintain and also make some improvements to the xml, just not sure if I want to replace this addon or start as a new addon. I also have some ideas of using a github repo for the online source, allowing a user to add someones github account and have their collection listed in the available materials.

@Brendon Murphy (meta-androcto) 100 materials is still a lot, improve whats there - ok. but really this is not good use of our git repos.

@Shane Ambler (sambler), updating the addon its self is something we could support but each addon shouldn't be writing their own code to handle this (though we dont explicitly prevent - its a can of worms, how to handle auto updates, mismatch with blender versions, trusting the upstream repos... code signing... etc.).

I just meant this in relation to downloading data-files for the addons use.

hi, I've considerable reduced the size of the updated "Bundled" Library to around 160kb larger than the original. Old redundant materials removed, line endings added to all files.

Considering the addon is dated 2.63 I think this is a very reasonable upgrade.
@Campbell Barton (campbellbarton) I hope this is better.

Brendon Murphy (meta-androcto) changed the task status from Unknown Status to Resolved.Jan 4 2016, 10:40 AM