DIYer22 / bpycv

Computer vision utils for Blender (generate instance annoatation, depth and 6D pose by one line code)
MIT License
470 stars 58 forks source link

render_data() bug when a single mesh has multiple materials #19

Closed mitchelljy closed 3 years ago

mitchelljy commented 3 years ago

First of all, this tool is absolutely perfect for what I need and I love it! It was working fine for me on a simpler scene, but now I am using it to create an image segmentation dataset on a more complex scene with a different material setup. I've now encountered a bug when multiple materials are used for a single mesh.

Here is the simple script I have setup which causes this behavior:

import sys
sys.path.append("/home/mitchell/anaconda3/envs/blender/lib/python3.7/site-packages")

import bpycv

result = bpycv.render_data()

Before running:

before

After running:

image

And here you can see vaguely what my materials look like for the city object beforehand:

image

The first material (default.001) is applied to all parts of the city after calling render_data(), whereas before there were 4 different materials for different parts of the city.

I can imagine this would be difficult to support, however one quick way to solve this for me would be the ability to ignore the city object entirely when generating annotations. I'm not sure if this is possible though.

I'm not a blender expert by any means, but if there's anything else you'd like to know I'd be happy to help. Thanks in advance!

DIYer22 commented 3 years ago

By right now, object that has multi-materials are not support well. After rendering annotations, only one material will recover to the object. The temporary approach is reloading all objects after rendering annotations. We will fix this issue soon by render annotations in another way.

mitchelljy commented 3 years ago

Thanks @DIYer22

I ended up being able to work around this problem temporarily by modifying the library to support an 'ignore object' argument whereby I could pass in a list of object names (or a prefix for object names) and all matching objects would be totally ignored by the library. This worked for me because I didn't need the city object to be included in the object mask, it could be treated as background.

If you happen to have the same issue as me before a more reliable fix is implemented then this may work for you too :smile:

jessicametzger commented 2 years ago

I am having trouble with this, and unfortunately need to render tracked objects with multiple materials (i.e. have bpycv pay attention to them). Any updates would be great.