REQUEST: Material groups - divide materials into separate image sets to bake
KirilStrezikozin opened this issue · 17 comments
This feature request is:
- not a duplicate
- implemented
Is your feature request related to a problem? Please describe.
Snoopybob from BlenderMarket:
I can tell you that I have compared most of the addons of this type, and I haven't found any that offers this obvious feature. I am sure that many people would be interested in such a feature, especially in the field of video games. Merging maps is convenient, but when you are constrained to low resolutions, it is better to have one map per material.
Describe the solution you'd like to be implemented
a sub-table in which, when you select an object, the list of materials appears with the possibility of selecting those which will be baker individually, of those which one could merge.
Not easy to project but I think this is the kind of functionality that should be allowed to "unfold" once an option is checked. This allows the user to glimpse new and more refined possibilities.
- We activate the display of the bake options by material
- Choose the objects concerned, then the materials concerned by objects
- Specify which ones will be merged and which ones will be individually baked "by default".
Just an idea, I hope it inspires you
Additional context
my option:
A section called "Material Groups" where you could specify unique material groups and add one or multiple objects' materials to them. With this kind of customization, you could be able to not bake all materials merged or all separately, but instead, for ex, choose mat1, mat2, mat4 to bake merged and mat3 separately from them.
- implement UI:
- on
bm_props.global_active_index
Update
, refillCollectionProperty
for object's materials, add thatCollectionProperty
to the UI.
- UI: add buttons to quickly set different indexes for all materials and another button to quickly set the same
- Sideway todo: for
bm_table_of_objects
updates, write reassign for..table_active_index
because, for ex, highpoly table active index I haven't reseted and it causes UI draw errors - minor fixes around all code
- add
$matgroup
tag tobatchname
- refactor:
BakeMaster-Blender-Addon/utils.py
Line 2457 in cee6c7e
smart refresh to capture old config and try to keep old group indexes.
- call
bpy.ops.bakemaster.item_matgroups_table_refresh
inbake_prepare_all_objects()
after settingsbm_props.global_active_index
and before resolvingbatchname
- add method:
def ...matgroups_batch_collector(batchname: str, object)
to collectbatchname
andmatgroups
and form a shell of images forself.bake_images[...][...] = (output from new method)
Example:
input:
batchname
[ mat1 - 1 ]
[ mat2 - 2 ]
[ mat3 - 1 ]
[ mat4 - 1 ]
[ mat5 - 3 ]
output:
[ batchname1, 1, mat1, mat3, mat4 ]
[ batchname2, 2, mat2 ]
[ batchname3, 3, mat5 ]
- adapt texsets init to
image_groups
put intoself.bake_images[...][...]
- edit adaptation: combine only
image_groups
that have the samegroup_index
example:
========================================
[['Cube_1_NORMAL', 1, ['Material', 'Material.001', 'Material.002', 'Material.003', 'Material.004']]]
[['Cube_1_ALBEDO', 1, ['Material', 'Material.001', 'Material.002', 'Material.003', 'Material.004']]]
[['Cube_1_METAL', 1, ['Material', 'Material.001', 'Material.002', 'Material.003', 'Material.004']]]
[['Cube_1_ROUGH', 1, ['Material', 'Material.001', 'Material.002', 'Material.003', 'Material.004']]]
========================================
[['Cube_1_NORMAL', 1, ['Material', 'Material.002', 'Material.003']], ['Cube_1_NORMAL', 2, ['Material.001']], ['Cube_1_NORMAL', 3, ['Material.004']]]
[['Cube_1_ALBEDO', 1, ['Material', 'Material.002', 'Material.003']], ['Cube_1_ALBEDO', 2, ['Material.001']], ['Cube_1_ALBEDO', 3, ['Material.004']]]
[['Cube_1_METAL', 1, ['Material', 'Material.002', 'Material.003']], ['Cube_1_METAL', 2, ['Material.001']], ['Cube_1_METAL', 3, ['Material.004']]]
[['Cube_1_ROUGH', 1, ['Material', 'Material.002', 'Material.003']], ['Cube_1_ROUGH', 2, ['Material.001']], ['Cube_1_ROUGH', 3, ['Material.004']]]
should be:
========================================
[['Cube_1_NORMAL', 1, ['Material', 'Material.001', 'Material.002', 'Material.003', 'Material.004']]]
[['Cube_1_ALBEDO', 1, ['Material', 'Material.001', 'Material.002', 'Material.003', 'Material.004']]]
[['Cube_1_METAL', 1, ['Material', 'Material.001', 'Material.002', 'Material.003', 'Material.004']]]
[['Cube_1_ROUGH', 1, ['Material', 'Material.001', 'Material.002', 'Material.003', 'Material.004']]]
========================================
[['Cube_1_NORMAL', 1, ['Material', 'Material.002', 'Material.003']], ['Ball_2_NORMAL', 2, ['Material.001']], ['Ball_3_NORMAL', 3, ['Material.004']]]
[['Cube_1_ALBEDO', 1, ['Material', 'Material.002', 'Material.003']], ['Ball_2_ALBEDO', 2, ['Material.001']], ['Ball_3_ALBEDO', 3, ['Material.004']]]
[['Cube_1_METAL', 1, ['Material', 'Material.002', 'Material.003']], ['Ball_2_METAL', 2, ['Material.001']], ['Ball_3_METAL', 3, ['Material.004']]]
[['Cube_1_ROUGH', 1, ['Material', 'Material.002', 'Material.003']], ['Ball_2_ROUGH', 2, ['Material.001']], ['Ball_3_ROUGH', 3, ['Material.004']]]
- Full
operator_bake.py
code adaptation to matgroups
need to test definitely
but it wasn't as hard as I expected. Just added another headache on top of existing multidimensional arrays holding bake data
@@ -3151,6 +3129,8 @@ def grab_image_name(item):
data += dir_data
# append already initialized images
+ # whoa look at da 4-dimensional array,
+ # that's what makes stuff blazingly fast ^_^
for obj_shell in self.bake_images:
for maps_shells in obj_shell:
for map_shell in maps_shells:
for image_group in map_shell:
data.append(image_group[0])
- in
handle_object(...)
, where I getimage_groups
, callhandle_matgroups(...)
to mute materials that aren't in the current matgroup. Onmap_index
,matgroup_index
change, restore muted materials.
hell i'm done with this +.+
bakemaster_matgroups_ui-2023-02-22_16.47.42.mp4
- make
matgroup_naming
prop look better in the ui