Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REQUEST: Material groups - divide materials into separate image sets to bake #25

Open
2 tasks done
KirilStrezikozin opened this issue Feb 17, 2023 · 17 comments
Open
2 tasks done
Assignees
Labels
feature upgrade for your old lawnmower needs testing wow does it even work?

Comments

@KirilStrezikozin
Copy link
Owner

KirilStrezikozin commented Feb 17, 2023

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.

  1. We activate the display of the bake options by material
  2. Choose the objects concerned, then the materials concerned by objects
  3. 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.

@KirilStrezikozin KirilStrezikozin added the feature upgrade for your old lawnmower label Feb 17, 2023
@KirilStrezikozin KirilStrezikozin self-assigned this Feb 17, 2023
@KirilStrezikozin KirilStrezikozin added the in progress All night I stay not sleeping because I'm thinking about this label Feb 17, 2023
@KirilStrezikozin KirilStrezikozin added this to the BakeMaster 3.0.0 milestone Feb 17, 2023
@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 17, 2023

  • implement UI:
  1. on bm_props.global_active_index Update, refill CollectionProperty for object's materials, add that CollectionProperty to the UI.

KirilStrezikozin added a commit that referenced this issue Feb 17, 2023
@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 17, 2023

  • UI: add buttons to quickly set different indexes for all materials and another button to quickly set the same

@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 17, 2023

  • 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

KirilStrezikozin added a commit that referenced this issue Feb 18, 2023
KirilStrezikozin added a commit that referenced this issue Feb 18, 2023
@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 20, 2023

  • add $matgroup tag to batchname

KirilStrezikozin added a commit that referenced this issue Feb 20, 2023
@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 21, 2023

KirilStrezikozin added a commit that referenced this issue Feb 21, 2023
@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 21, 2023

  • call bpy.ops.bakemaster.item_matgroups_table_refresh in bake_prepare_all_objects() after settings bm_props.global_active_index and before resolving batchname

@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 21, 2023

  • add method: def ...matgroups_batch_collector(batchname: str, object) to collect batchname and matgroups and form a shell of images for self.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 ]

@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 21, 2023

  • adapt texsets init to image_groups put into self.bake_images[...][...]

@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 21, 2023

  • edit adaptation: combine only image_groups that have the same group_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']]]

@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 22, 2023

  • Full operator_bake.py code adaptation to matgroups

@KirilStrezikozin
Copy link
Owner Author

need to test definitely

@KirilStrezikozin
Copy link
Owner Author

but it wasn't as hard as I expected. Just added another headache on top of existing multidimensional arrays holding bake data

@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 22, 2023

@@ -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])

@KirilStrezikozin KirilStrezikozin added solved How could you? GPT helped? close on release done here, but let's wait for the release needs testing wow does it even work? in progress All night I stay not sleeping because I'm thinking about this and removed in progress All night I stay not sleeping because I'm thinking about this solved How could you? GPT helped? close on release done here, but let's wait for the release needs testing wow does it even work? labels Feb 22, 2023
@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 22, 2023

  • in handle_object(...), where I get image_groups, call handle_matgroups(...) to mute materials that aren't in the current matgroup. On map_index, matgroup_index change, restore muted materials.

@KirilStrezikozin KirilStrezikozin added solved How could you? GPT helped? close on release done here, but let's wait for the release needs testing wow does it even work? in progress All night I stay not sleeping because I'm thinking about this and removed in progress All night I stay not sleeping because I'm thinking about this solved How could you? GPT helped? close on release done here, but let's wait for the release labels Feb 22, 2023
@KirilStrezikozin
Copy link
Owner Author

hell i'm done with this +.+

@KirilStrezikozin
Copy link
Owner Author

bakemaster_matgroups_ui-2023-02-22_16.47.42.mp4

@KirilStrezikozin
Copy link
Owner Author

KirilStrezikozin commented Feb 22, 2023

  • make matgroup_naming prop look better in the ui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature upgrade for your old lawnmower needs testing wow does it even work?
Projects
None yet
Development

No branches or pull requests

1 participant