DLR-RM / BlenderProc

A procedural Blender pipeline for photorealistic training image generation
GNU General Public License v3.0
2.78k stars 449 forks source link

[FEATURE]: Show my pictures on the mesh object. Do not use cctexture #583

Closed Lemonade24510 closed 2 years ago

Lemonade24510 commented 2 years ago

I want to show pictures on the "plane". Do not use cctexture 000331 Rgb_24811 It's equivalent to replacing the ground with a new picture Maybe my English is not very good,It's really a headache/(ㄒoㄒ)/~~

themasterlink commented 2 years ago

Hey,

don't worry about your English, there are good automatic translators out there. You can always use one of those.

But, back to your question. Setting the texture of a material can be done with:

# Collect all jpg images in the specified directory
images = list(Path(args.image_dir).rglob("material_manipulation_sample_texture*.jpg"))
for mat in materials:
    # Load one random image
    image = bpy.data.images.load(filepath=str(random.choice(images)))
    # Set it as base color of the current material
    mat.set_principled_shader_value("Base Color", image)

Check out the example: https://dlr-rm.github.io/BlenderProc/examples/basics/material_manipulation/README.html

Best, Max

Lemonade24510 commented 2 years ago

Thank you. This effect is exactly what I want but: ground_material = bproc.filter.one_by_attr(materials, "name", "") I don't know what to fill in I want to keep random materials,But I don't know: the name of my material at each cycle andI want to load my pictures as soon as PLANE generat 7116e99e3ea5e03d585ff10e82550e3 e

thankyou As a civil engineering student. There are too many things I don't understand when learning this

Lemonade24510 commented 2 years ago

nice!i did it! thank you,plane.scale_uv_coordinates is also very useful😊

themasterlink commented 2 years ago

I will close this then :)

Pengfeicc commented 2 years ago

@Lemonade24510 @themasterlink For example in main_itodd_random.py how can i add custom textrue only on the planes? how can i modifiy the following code?

random_cc_texture = np.random.choice(cc_textures) for plane in room_planes: plane.replace_materials(random_cc_texture)

594