0
$\begingroup$

I've been working on this for several days, but haven't found any solutions. Please help me out

I want two images per render scene.

  1. ordinary color rendered image
  2. only page masked image(Using Material Index pass)

the results is not good and changing every attempt.

any comments would be very helpful.

Thank you

here is my Composite Node. enter image description here and below is my python script

def render_and_save(output_path, output_gt_path):

view_layer = bpy.context.view_layer
view_layer.use_pass_material_index = True
bpy.data.images.remove(bpy.data.images.get("Render Result"), do_unlink=True)

bpy.ops.render.render()
render_result = bpy.data.images.get("Render Result")

if render_result is None:
    print("Error: 'Render Result' not found.")
    return

try:
    render_result.render_slots.active_index = 0
    render_result.save_render(filepath=output_path)
    
    render_result.render_slots.active_index = 1
    render_result.save_render(filepath=output_gt_path)
    print(f"Saved image: {output_path}")

except Exception as e:
    print(f"Error while saving: {e}")




def main():
 .....
    for i in range(num_images):
 .....
    output_color_path = os.path.join(output_dir, f"book_{i:03d}.png")
    output_gt_path = os.path.join(output_dir, f"book_GT_{i:03d}.png")
    render_and_save(output_color_path, output_gt_path)
$\endgroup$

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.