1. Welcome to VRCat! Please note that this message board is not related to VRChat in any official manner. It is run entirely by the community, and moderated by the community. Any content present has not been reviewed by VRChat moderators or staff. Your use of these forums implies understanding of this message. Thanks!
    Dismiss Notice

Avatars Material Combiner Blender Addon (2.0.3.2)

Discussion in 'Tutorials and Tools' started by shotariya, Aug 18, 2018.

  1. shotariya

    shotariya Member

    Joined:
    Nov 16, 2017
    Messages:
    12
    Likes Received:
    13
    VRChat:
    shotariya
    An addon that allows to get lower draw calls by combining textures without quality loss and avoiding the problem of uv larger 0-1 bounds.

    If you like an addon you can support my work on Patreon.

    [​IMG]


    FEATURES

    • Combining multiple materials. (allow to apply diffuse colors and choose each image and atlas sizes)
    • Multicombining. (add layers for each image which are combine into different atlases, allow to generate Normal map, Specular map, etc atlases)
    • Packing UV into the selected scale bounds by splitting mesh faces, compatible with rigged models. (Currently Disabled)
    • Atlas image compression.


    INSTALLATION
    1. Download an addon: Material-combiner
    2. Go to File > User Preferences > Addons
    3. Click on Install Add-on from File
    4. Choose material-combiner-addon-master.zip archive
    5. Activate Material Combiner


    CHANGELOG
    2.0.3.2
    1. Installation changed to user environment
    2. Combining logic edited
    2.0.3.1
    1. Fixed install bug (If you have installed Blender on Program FIles, be sure to run Blender as Administrator to install third-party modules)
    2. Some titles changed
    2.0.3.0
    1. Added multicombining, allows to combine albedo, normal map, specular map, solid color, etc in atlases
    2. Improved code logic
    3. More flexible settings
    4. Reworked GUI
    5. Image compression
    6. Auto updating
    1.1.6.3
    1. Some minor fixes
    1.1.6.2
    1. Some minor fixes
    1.1.6
    1. Some minor fixes
    1.1.5
    1. Fixed same material combining
    2. Some minor fixes
    1.1.4
    1. Added combining materials by different IDs to be able to use different shaders but keep use one combined texture
    2. Fixed Save Textures by UVs wrong material selection
    3. Allow to work with multiple models, Hide models which you do not want to change
    4. Some minor fixes
    1.1.3
    1. Attention message on texture combining
    2. Some description added
    3. Some minor fixes
    1.1.2
    1. Auto-assigning .blend path as save path
    2. Materials with only color support
    3. Checking for file existing
    4. Other file formats support
    5. Mac support

    BUGS / SUGGESTIONS

    If you have found a bug or have suggestions to improve the tool, you can contact me on Discord: shotariya#4269


     
    #1 shotariya, Aug 18, 2018
    Last edited: Dec 8, 2018 at 7:53 PM
  2. Tupper

    Tupper The Strongest
    Forum Staff

    Joined:
    Nov 14, 2017
    Messages:
    110
    Likes Received:
    103
    VRChat:
    Tupper
    This is quite impressive! High quality atlas, done in about 30 seconds. No need for manual moving around of UVs or re-baking or etc.

    A few suggestions:
    • By default the images should just save wherever the blendfile is saved to. A bit cumbersome having to select a dir to save the textures and atlas, but it isn't a killer.
    • Sometimes the atlas isn't organized in the most smart way resulting in non-square textures, but considering it is automated this is not a huge problem.
    Other than that, this is beautiful. Super easy atlasing done in no time flat. MUCH higher quality results than smart UV project in CATS (not trashing CATS, but the auto-atlas isn't super great).

    If this got widespread use, it would be quite good for everyone involved.
     
    shotariya likes this.
  3. e-lady

    e-lady New Member

    Joined:
    Jul 11, 2018
    Messages:
    1
    Likes Received:
    5
    VRChat:
    e-lady
    This looks great a github would be better instead of a dropbox though
     
    Mr.Crane, OwlBoy, Eremite and 2 others like this.
  4. Hotox

    Hotox Member

    Joined:
    Nov 19, 2017
    Messages:
    102
    Likes Received:
    43
    VRChat:
    Hotox
    Awesome tool, this really outshines the smart UV project.
     
    shotariya likes this.
  5. Lyuma

    Lyuma New Member

    Joined:
    Jun 13, 2018
    Messages:
    5
    Likes Received:
    4
    VRChat:
    Lyuma
    Hi,
    First of all, seeing this plugin literally made my day!!! I love you for making this!

    CATS style atlasing works in such a way that the original UVs coordinates are mixed up, and it seems to make different choices each time which makes material swaps impossible. Keeping the UVs intact is also critical for doing some effects.

    This plugin does exactly what I want and no more: It combines the textures and moves the UVs to the correct part of the combined texture.

    Troubleshooting:

    In case you run into "Error: bpy_prop_collection[index]: index 0 out of range, size 0", this happens if you are in edit mode. Just go to object mode and try again.

    If you have two models in the scene, the plugin seems to have difficulty (it often selects the first mesh too). In this case you should save and then delete the other models. Later you can import the other models from the original blend file using the File->Append feature so this isn't too bad.

    Finally, I'm using this plugin on my Macbook. If you are not on Windows, the plugin needs you to download a copy of Pillow.
    First, I recommend running blender from the terminal, so you can see the output prints when something goes wrong:
    Code:
    cd /Applications/Blender/blender.app/
    Contents/MacOS/blender &
    
    After adding the plugin, you will be unable to check the box. This is due to the plugin coming with a windows version of Pillow. Don't worry. This is easy to fix: Go to https://pypi.org/project/Pillow/5.2.0/#files and find the version of Pillow matching your OS for "cp35" -- this is the version of python my Blender install uses. In my case, I use Pillow-5.2.0-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.6 MB)

    Now you will want to unzip it such that it overwrites files. Easiest way to do this is in the Terminal. Go to the plugin install directory. This will show up in the error messages but it probably is the same for everyone.
    Code:
    cd ~/Library/Application Support/Blender/2.79/scripts/addons/material-combiner-addon-master
    unzip ~/Downloads/Pillow-5.2.0-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
    
    When it asks you to replace answer A for All:
    replace PIL/__init__.py? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
    
     
    #5 Lyuma, Aug 21, 2018
    Last edited: Aug 21, 2018
    shotariya and OwlBoy like this.
  6. OwlBoy

    OwlBoy Member

    Joined:
    Nov 19, 2017
    Messages:
    10
    Likes Received:
    9
    VRChat:
    owlboy
    Thank you for doing the work needed to verify it works on Macs too!
     
    #6 OwlBoy, Aug 21, 2018
    Last edited: Aug 21, 2018
    shotariya likes this.
  7. Garret2727

    Garret2727 New Member

    Joined:
    Aug 23, 2018
    Messages:
    1
    Likes Received:
    4
    VRChat:
    Garret2727
    Brilliant idea for combining materials. I tested the addon and I noticed that it only combines the diffuse maps. Could there be an option to combine other maps like normal, specular/metallic, ambient occlusion? I would use this addon like a madman
     
    shotariya, Mimi, OwlBoy and 1 other person like this.
  8. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    24
    Likes Received:
    20
    I encounter an error trying to activate the plugin. But I've been running the development build of 2.79 for something, so maybe that's missing something required?

    Code:
    Traceback (most recent call last):
      File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\modules\addon_utils.py", line 351, in enable
        mod = __import__(module_name)
      File "C:\Users\Silent\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\material-combiner-addon-master\__init__.py", line 30, in <module>
        from . import one_mat, uv_fixer, uv_splitter, gen_tex
      File "C:\Users\Silent\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\material-combiner-addon-master\one_mat.py", line 33, in <module>
        from PIL import Image
      File "C:\Users\Silent\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\material-combiner-addon-master\PIL\Image.py", line 64, in <module>
        from . import _imaging as core
    ImportError: cannot import name '_imaging'
    
    Otherwise, it works really well! Combination for other kinds of maps would be perfect, too.
     
    #8 Silent, Aug 23, 2018
    Last edited: Aug 23, 2018
  9. FlameG102

    FlameG102 Member

    Joined:
    Jan 4, 2018
    Messages:
    23
    Likes Received:
    4
    been getting this sort of thing too

    [​IMG]
     
    shotariya likes this.
  10. Ryasa

    Ryasa Member

    Joined:
    Jan 25, 2018
    Messages:
    18
    Likes Received:
    8
    Now there really is absolutely no excuse for unoptimised avatars. You have done the community a fantastic service with this tool.

    Many thanks!
     
    shotariya and Mr.Crane like this.
  11. Maebbie

    Maebbie New Member

    Joined:
    Nov 28, 2017
    Messages:
    4
    Likes Received:
    2
    VRChat:
    Maebbie
    true hero right here
     
    shotariya likes this.
  12. Lyuma

    Lyuma New Member

    Joined:
    Jun 13, 2018
    Messages:
    5
    Likes Received:
    4
    VRChat:
    Lyuma
    This error means you are in Edit mode. Please see if it still happens when you switch to Object mode.

    ------

    @Silent if you are using a development version of Blender, it's possible it comes with a different version of python than the plugin was made for (3.5.x). You can check which Python version you have by opening the python console in Blender.

    If you see a version like 3.6 or 3.7, then you can fix this by downloading the Pillow library that matches your version of python, for example Pillow-5.2.0-cp37-cp37m-win32.whl for Python 3.7.0. See here: https://pypi.org/project/Pillow/5.2.0/#files

    Once you have it, you will want to extract all the files into the PIL folder in the plugin (in your error message it listed C:\Users\Silent\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\material-combiner-addon-master\PIL) and overwrite all the .dll files.
     
    Silent and shotariya like this.
  13. AirGamer

    AirGamer New Member

    Joined:
    Apr 15, 2018
    Messages:
    4
    Likes Received:
    1
    "Packing UVs by splitting mesh" added over 1K extra Tris, Is this expected?
     
  14. shotariya

    shotariya Member

    Joined:
    Nov 16, 2017
    Messages:
    12
    Likes Received:
    13
    VRChat:
    shotariya
    splitting mesh by uv divide faces into 2 or more parts to be able to move due to this splitted uv loops closer to bounds, so you are getting more tris but keep texture sizes still same
     
    #14 shotariya, Sep 1, 2018
    Last edited: Sep 1, 2018
  15. ACiiL

    ACiiL New Member

    Joined:
    Sep 1, 2018
    Messages:
    1
    Likes Received:
    1
    VRChat:
    ACiiL
    Been nice using this, really speeds up the process of aliasing in a lossless textures stack method.

    Several issues to report using 1.1.6, final atlas does not guarantee to be a power of 2 squares, and Blender material color Diffuse does not always apply on the final bake:

    For a not powers of 2 texture example, a complete atlas became 6144x5120, which may create undefined texture issues in unity's mipmap and texture setup systems; Can you enforce the results to be squared? The next is the issues of "material as color" where the material comes from Blender's color Diffuse, I observed this addon is having mixed results grouping the empty UVs and baking the diffuse... Solid diffusion with no texture is baked, BUT, diffuse applied onto a texture (for example the source texture was just a plain greyscale of cloth) is not being baked on. Can you modify the addon so it always color multiplies the diffuse onto the material so all cases are handled? This will also save many cases where MMD authors generally do slight paint edits by creating a new material with a diffuse paint over (and not manually fixing their textures).

    Also please implement means to regroup texture masks and normal maps with this, i know how i can manually build a texture stack, as this atlas result is lossless and in order: placing the alt textures on the generated atlas manually and fill the spaces with normal map blue or masks black.

    Lastly, can you explain and reorder the addon's UIs functions and menu order? For example i understood how the "Mover" functions, and no idea how the "Packer" works and when to use the "Retexturer". I feel i had been mashing keys in order of: mover -> packer -> retexturer -> combiner, to get results, which is practically out of order these operations appear in the tool tab.
     
    shotariya likes this.
  16. AirGamer

    AirGamer New Member

    Joined:
    Apr 15, 2018
    Messages:
    4
    Likes Received:
    1
    This seems unnecessary when the material in question is a solid colour and not a texture, but the combiner required me to split the mesh anyway.
     
    shotariya likes this.
  17. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    24
    Likes Received:
    20
    Thanks, this is great advice! That fixed it!
     
  18. InfJager

    InfJager New Member

    Joined:
    Oct 28, 2018
    Messages:
    1
    Likes Received:
    0
    VRChat:
    InfJager
    I don't entirely know if I'm to reply here for errors involving this, but I get this big error trying to use the atlas tool on CATS. I've no idea what to do in the slightest.
     

    Attached Files:

  19. shotariya

    shotariya Member

    Joined:
    Nov 16, 2017
    Messages:
    12
    Likes Received:
    13
    VRChat:
    shotariya
    That looks like image library that I'm using for combining can't read this tga format, it support 24 and 32 bit tga formats.
    You can try to re-save image to png with other image editor/web and change material texture image to that.
     
    #19 shotariya, Oct 29, 2018
    Last edited: Dec 3, 2018
  20. shotariya

    shotariya Member

    Joined:
    Nov 16, 2017
    Messages:
    12
    Likes Received:
    13
    VRChat:
    shotariya
    UPD: some errors like this possibly fixed now