EDIT: As of Hotfix 2, this post is outdated, and the script are removed.
The functionalities are integrated in the Library itself, under the "Add to Library" button.
Refer to the docs for usage scenarios and limitations.
The attached script will at some point be better integrated with the library itself.
For now, we'd like for the most adventurous of users to try this out and provide us with actionable feedback.
Installation:
The attached archive (very bottom) contains two files: the script and a max file.
*)The max file needs to be placed in the v-ray install folder, "assets" subfolder.
For example, in
You may need elevated privileges to write in there.
*)The script can instead be opened and run from the maxscript editor, or from the maxscript/scripting menu.
Its location isn't important.
Limitations:
The script will try to detect the material library installation folder.
Currently, the script expects this library to exist and be valid.
Should this not be the case, the script will warn and close.
The script expects the Swatch max file to live inside the correct assets folder in the v-ray install.
Should it not find it, it will warn and close.
So, for now, no custom locations for new material libraries, nor the chance to choose custom location for the assets.
This may or may not change in the future.
Operation:
The script has two main modes of operation:
a1) Select (or -recursively- scan for) a material library, then process it as per the chosen options: copy and repath the textures to the assets' folder in the library, render the previews, and copy/refresh the material library file in the V-Ray Library folder.
a2) Select (or -recursively- scan for) a Max file, then process it as per the chosen options: copy and repath the textures to the assets' folder in the library, render the previews, and create/refresh a material library file in the V-Ray Library folder.
Both buttons can be used, and the script will process the .mat files first, and the .max files afterwards.
The script offers options:
The defaults can be overridden for both resolution and quality (more on this further down.): from 64 to 4096px can be rendered in final or preview quality.
The default is 512px, which is mostly fine.
For those wanting bigger samples (to be clear, those are the images shown when the samples are double-clicked and open in a new window), the option is there.
Be mindful of higher resolutions: the 2048 one will take 16 times the default one to render.
Because the script can scan folder trees, using the preview quality and the small resolutions will allow for a very quick pre-pass to create matlibs from any number of max files, as quickly as possible.
As a second stage, the ones worthy of being kept can be rendered at higher quality and resolution.
Below the render options, there are choices for copying the textures to the asset folder in the library, and to convert to .TX (currently not working. Will arrive for the final, integrated version.).
To handle duplicates, the script now offers choices: "Always", "Never", or "Ask" are available for textures, preivews and material library files.
Lastly, options can be saved and reset to defaults easily.
Resetting options to defaults will still remember the last path used for either of the browse buttons.
Usage:
Simply run the script, click (or CTRL+Click, or ALT+Click. See tooltip.) on either of the two buttons, and once the "Process" button is active, click it to let the script do its job.
At factory defaults, the script will produce results identical to those the Library ships with.
Keeping the ESC key pressed (with focus on the script UI, not the VFB) will quit the process.
It's provided with tooltips, so there should be no need to get back to this post for instructions.
If anything is terribly wrong, the script should warn the user, and then close.
Thank you in advance for all the feedback, and the reporting of any bugs.
EDIT: The version is now v 0.05, it simply adds the "Skip existing" checkbox.
This will skip existing previews, regardless of their size (the check is on the file name alone.).
While checking sizes is entirely doable, it'll also get quite slow (the script would need to open each sample picture, and once in RAM check its size. then close it and garbage collect. Checking for file size alone could work too, but it'd be risky due to jpg compression), so i'd rather the user did the manual work of cleaning up offending images from their library previews.
Should it prove hard or a long slog, i'll reconsider this.
EDIT #2: The version is now v 0.06. Added the automatic Asset Browser refresh to the operations, and a little "R" button to manually refresh it.
EDIT #3: The 007 version implements custom .mat file usage (i.e. pick any .mat file.), process quitting on ESC key hold-down, and graceful exit if terminal errors are found (no max file for sample rendering, no material library is found.).
There are still a couple of things to get done (rationalisation of texture assets copying, VFB history suspecnsion from saving during sample rendering.), but usability should be about fine.
EDIT #4: V 008 has now an option to copy texture files over to the material library assets path. Defaults to off, so it won't repath and copy textures when a new material library is created from an open max file.
EDIT #5: V 103 is a complete rewrite, to finalise the script and prepare it for integration into the library. The post has been updated to describe the features.
EDIT #6: V 104 fixes two issues; the first has to do with matlibs containing corrupt entries. The script now detects those and fixes the matlibs transparently. The second was with the asset copying for matlibs (only. max files were good.). It didn't quite work as intended, and didn't copy and repath the textures at all. Now it does.
EDIT #7: V 106 fixes an issue which didn't allow for recursive search, and makes a few minor QoL changes to he UI elements and tooltips.
EDIT #8: V 106b only fixes an inconsistency which lead to a bug.
EDIT #9: V 107 fixes a silly, terminal bug.
EDIT #10: V 108 adds a cleaning of custom attributes and bad class IDs, via the Autodesk's own scene converter methods present in either Max files or matlibs.
The original files will *not* be changed in any way, however, only the created matlibs will be cleaned.
It also shuts max up completely (that's the hope, at least) on file load, so batch operations should flow to their rightful end now.
EDIT #11: V 111 holds and fetches the currently open max scene. Fetching should happen in any case, also if the user holds the ESC key, at any stage of the process.
The behaviour of the pick buttons for when the user wants folders scanned (CTRL or ALT modifiers) has changed, and now will display a folder picking dialog, instead of a file one. Tolltips have been updated to reflect the change.
This is now actively going through QA, and is considered feature-complete for this stage. It will be integrated into the material library with the next public hotfix.
Please upgrade from previous versions.
The functionalities are integrated in the Library itself, under the "Add to Library" button.
Refer to the docs for usage scenarios and limitations.
The attached script will at some point be better integrated with the library itself.
For now, we'd like for the most adventurous of users to try this out and provide us with actionable feedback.
Installation:
The attached archive (very bottom) contains two files: the script and a max file.
*)The max file needs to be placed in the v-ray install folder, "assets" subfolder.
For example, in
Code:
C:\Program Files\Chaos Group\V-Ray\3ds Max 2021\assets\
*)The script can instead be opened and run from the maxscript editor, or from the maxscript/scripting menu.
Its location isn't important.
Limitations:
The script will try to detect the material library installation folder.
Currently, the script expects this library to exist and be valid.
Should this not be the case, the script will warn and close.
The script expects the Swatch max file to live inside the correct assets folder in the v-ray install.
Should it not find it, it will warn and close.
So, for now, no custom locations for new material libraries, nor the chance to choose custom location for the assets.
This may or may not change in the future.
Operation:
The script has two main modes of operation:
a1) Select (or -recursively- scan for) a material library, then process it as per the chosen options: copy and repath the textures to the assets' folder in the library, render the previews, and copy/refresh the material library file in the V-Ray Library folder.
a2) Select (or -recursively- scan for) a Max file, then process it as per the chosen options: copy and repath the textures to the assets' folder in the library, render the previews, and create/refresh a material library file in the V-Ray Library folder.
Both buttons can be used, and the script will process the .mat files first, and the .max files afterwards.
The script offers options:
The defaults can be overridden for both resolution and quality (more on this further down.): from 64 to 4096px can be rendered in final or preview quality.
The default is 512px, which is mostly fine.
For those wanting bigger samples (to be clear, those are the images shown when the samples are double-clicked and open in a new window), the option is there.
Be mindful of higher resolutions: the 2048 one will take 16 times the default one to render.
Because the script can scan folder trees, using the preview quality and the small resolutions will allow for a very quick pre-pass to create matlibs from any number of max files, as quickly as possible.
As a second stage, the ones worthy of being kept can be rendered at higher quality and resolution.
Below the render options, there are choices for copying the textures to the asset folder in the library, and to convert to .TX (currently not working. Will arrive for the final, integrated version.).
To handle duplicates, the script now offers choices: "Always", "Never", or "Ask" are available for textures, preivews and material library files.
Lastly, options can be saved and reset to defaults easily.
Resetting options to defaults will still remember the last path used for either of the browse buttons.
Usage:
Simply run the script, click (or CTRL+Click, or ALT+Click. See tooltip.) on either of the two buttons, and once the "Process" button is active, click it to let the script do its job.
At factory defaults, the script will produce results identical to those the Library ships with.
Keeping the ESC key pressed (with focus on the script UI, not the VFB) will quit the process.
It's provided with tooltips, so there should be no need to get back to this post for instructions.
If anything is terribly wrong, the script should warn the user, and then close.
Thank you in advance for all the feedback, and the reporting of any bugs.
EDIT: The version is now v 0.05, it simply adds the "Skip existing" checkbox.
This will skip existing previews, regardless of their size (the check is on the file name alone.).
While checking sizes is entirely doable, it'll also get quite slow (the script would need to open each sample picture, and once in RAM check its size. then close it and garbage collect. Checking for file size alone could work too, but it'd be risky due to jpg compression), so i'd rather the user did the manual work of cleaning up offending images from their library previews.
Should it prove hard or a long slog, i'll reconsider this.
EDIT #2: The version is now v 0.06. Added the automatic Asset Browser refresh to the operations, and a little "R" button to manually refresh it.
EDIT #3: The 007 version implements custom .mat file usage (i.e. pick any .mat file.), process quitting on ESC key hold-down, and graceful exit if terminal errors are found (no max file for sample rendering, no material library is found.).
There are still a couple of things to get done (rationalisation of texture assets copying, VFB history suspecnsion from saving during sample rendering.), but usability should be about fine.
EDIT #4: V 008 has now an option to copy texture files over to the material library assets path. Defaults to off, so it won't repath and copy textures when a new material library is created from an open max file.
EDIT #5: V 103 is a complete rewrite, to finalise the script and prepare it for integration into the library. The post has been updated to describe the features.
EDIT #6: V 104 fixes two issues; the first has to do with matlibs containing corrupt entries. The script now detects those and fixes the matlibs transparently. The second was with the asset copying for matlibs (only. max files were good.). It didn't quite work as intended, and didn't copy and repath the textures at all. Now it does.
EDIT #7: V 106 fixes an issue which didn't allow for recursive search, and makes a few minor QoL changes to he UI elements and tooltips.
EDIT #8: V 106b only fixes an inconsistency which lead to a bug.
EDIT #9: V 107 fixes a silly, terminal bug.
EDIT #10: V 108 adds a cleaning of custom attributes and bad class IDs, via the Autodesk's own scene converter methods present in either Max files or matlibs.
The original files will *not* be changed in any way, however, only the created matlibs will be cleaned.
It also shuts max up completely (that's the hope, at least) on file load, so batch operations should flow to their rightful end now.
EDIT #11: V 111 holds and fetches the currently open max scene. Fetching should happen in any case, also if the user holds the ESC key, at any stage of the process.
The behaviour of the pick buttons for when the user wants folders scanned (CTRL or ALT modifiers) has changed, and now will display a folder picking dialog, instead of a file one. Tolltips have been updated to reflect the change.
This is now actively going through QA, and is considered feature-complete for this stage. It will be integrated into the material library with the next public hotfix.
Please upgrade from previous versions.
Comment