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

some objects seem to disappear after adding textures #1002

Closed
freLorbeer opened this issue Nov 21, 2023 · 6 comments · Fixed by #1004
Closed

some objects seem to disappear after adding textures #1002

freLorbeer opened this issue Nov 21, 2023 · 6 comments · Fixed by #1004
Labels
question Question, not yet a bug ;)

Comments

@freLorbeer
Copy link
Contributor

Describe the issue

Hi,
i build a pipeline that renders a photo of a scene without any textures, afterwards I add textures to all objects and the room and render another set of images.

From time to time (like any 10-20 scenes maybe) it happens that an object disappears as shown in the images.
000426

000278
000278

it does not happens with the same object all the time and it does not happen in every scene. So it is super hard to reproduce the error.

Is there any hidden relation between textures and object properties that can make it like invisible?

Thanks a lot.

Here is a short code snippet to show how I exactly add the textures:

Minimal code example

used_room_textures=[]
used_distr_obj_textures = []

# set shading and physics properties and randomize PBR materials
for j, obj in enumerate(screw_obj + distractor_bop_objs):
    obj.set_shading_mode('auto')
        
    mat = obj.get_materials()[0]
    #if obj.get_cp("bop_dataset_name") in ['itodd', 'tless']:
    grey_col = np.random.uniform(0.3, 0.9)   
    mat.set_principled_shader_value("Base Color", [grey_col, grey_col, grey_col, 1])        
    mat.set_principled_shader_value("Roughness", np.random.uniform(0, 1.0))
    mat.set_principled_shader_value("Specular", np.random.uniform(0, 1.0))


#Material Loader
# Load a random CC0Texture that was downloaded from https://cc0textures.com/
random_room_textures = bproc.loader.load_ccmaterials(textures_dir, used_room_textures)
random_room_texture = np.random.choice(random_room_textures)

random_distr_obj_textures = bproc.loader.load_ccmaterials(textures_dir, used_distr_obj_textures)

# Entity Manipulator
# Sample a CCTextures material once for all loaded ground_planes.
for plane in room_planes:
    plane.replace_materials(random_room_texture)

for obj in placed_objs:
    # set random material
    random_distr_obj_texture = np.random.choice(random_distr_obj_textures)
    # needed in order to map textures on objects and not only the colour
    obj.add_uv_mapping(projection="smart")
    
    obj.replace_materials(random_distr_obj_texture)
    # enable physics that objects fall down
    obj.enable_rigidbody(True)`

Files required to run the code

No response

Expected behavior

I expect that the texture of the objects i replace and that they are visible in the rendering
but sometimes some of them disappear

BlenderProc version

2.6.1

@freLorbeer freLorbeer added the question Question, not yet a bug ;) label Nov 21, 2023
@cornerfarmer
Copy link
Member

Hey @freLorbeer,

thanks a lot of the detailed issue description. Do you have a way to reproduce this? If yes, could you run your script using debug mode and look inside the blender UI which material has been assigned to the invisible object. One reason would be that some of the materials might contain transparent parts which could then lead to the object being transparent (depending on the UV).

If you set the environment variable BLENDER_PROC_RANDOM_SEED you can perform the exact same run multiple times. This might help in reproducing the behavior.

@freLorbeer
Copy link
Contributor Author

@cornerfarmer Thanks for the fast response.

After opening this issue I also found some textures that are way too transparent for my use case like Rust001
I rendered again, using only Fence and Rust001 and almost anything disappeared.

So this was definitively one reason and hopefully the only one.

For others who don't want to look at each texture by hand:
each texture that contains an opacity file is partially transparent (some are more and some less transparent)

@cornerfarmer
Copy link
Member

Hey @freLorbeer,

this makes sense, maybe we should add an option to skip transparent materials.

However, one thing is still not clear to me: If you dont set use_all_materials to true when calling load_ccmaterials then all fences and rust textures should be filtered out already. So, are you sure Fence and Rust001 were selected randomly?

@freLorbeer
Copy link
Contributor Author

@cornerfarmer I've already wondered about this parameter.

use_all_materials was set to False per default. I am not entirely sure, if Fence and Rust001 were selected randomly. But i could choose them even with use_all_materials=False by passing them as used_assets

@cornerfarmer
Copy link
Member

cornerfarmer commented Nov 23, 2023

Yeah, so if you set used_asset, this will ignore use_all_materials and always load the materials desired.
However, I found that even when only setting use_all_materials=False there are still some transparent materials left, which probably cause this issue. Therefore, transparent materials are now skipped per default in the ccmaterials loader (see: #1004). In the usual use-case, I think transparent materials are not desired.

@freLorbeer
Copy link
Contributor Author

Ah okay, nice to know.

Can I layer the textures? For example using Rust001 on top of another texture?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question, not yet a bug ;)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants