-
Notifications
You must be signed in to change notification settings - Fork 59
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
Multiple materials on an object do not get reversed #27
Comments
Thanks for reporting BUG. If you plan to fix this bug, pull requests are welcome.😊 |
Thanks for the link. That's a great way of doing it. Also makes the rendering faster since it doesn't have to do two passes anymore. |
How did you plan on integrating this? Its easy enough to create those nodes, but how do you deal with the nodes the user already has in place? |
Sorry, I am not familiar with Compositing Nodes and have not figured out how to implement it properly currently. |
Here is code that does what the youtube instructions say. I am not sure how it would work in the library yet. import bpy
view_layer = bpy.context.view_layer
view_layer.use_pass_z = True
view_layer.use_pass_object_index = True
scene = bpy.context.scene
scene.render.use_compositing = True
scene.use_nodes = True
tree = scene.node_tree
links = tree.links
render_layers = tree.nodes.new(type="CompositorNodeRLayers")
render_layers.location = (-0, 0)
div_block = tree.nodes.new(type="CompositorNodeMath")
render_layers.location = (-300, 200)
div_block.operation = 'DIVIDE'
div_block.inputs[1].default_value = 65535
link = links.new(render_layers.outputs["IndexOB"], div_block.inputs[0])
composite_block = tree.nodes.new(type="CompositorNodeComposite")
composite_block.location = (400, 200)
link = links.new(render_layers.outputs["Image"], composite_block.inputs["Image"])
fileoutput_block = tree.nodes.new(type="CompositorNodeOutputFile")
fileoutput_block.location = (400, 0)
fileoutput_block.file_slots.new("Instance")
fileoutput_block.file_slots["Instance"].format.color_mode = "BW"
fileoutput_block.file_slots["Instance"].format.color_depth = "16"
link = links.new(render_layers.outputs["Image"], fileoutput_block.inputs["Image"])
link = links.new(div_block.outputs[0], fileoutput_block.inputs["Instance"]) |
This is also an issue for me as I use many objects with multiple materials. For the temporary solution, how do you reload the object after rendering the instance annotation in code? The first image renders fine but from then on the materials do not reset properly. This is my script:
|
object_1 = bpy.data.objects.get("multi_material_object_1")
# change to
object_1 = bpycv.load_obj("path/to/3d_file") |
This unfortunately doesn't work for me because I use procedural textures and I want to adjust them each iteration of the loop. Is there another work-around to solve this issue? |
I lose my material too after an iteration. When I use @DIYer22 How do I use
|
@wish2023 Right now, |
This was referenced in another issue but it was then closed without a resolution. If an object has multiple materials, the materials are not reversed after the instance material is applied. The issue is in the replace_collection code. I don't how how blender associates materials to different vertices but that doesn't seem to be in the material itself. So even though bpycv is restoring the list of materials, the data about where they are applied is lost.
The text was updated successfully, but these errors were encountered: