BlenderProc icon indicating copy to clipboard operation
BlenderProc copied to clipboard

[Q] How to change blend_mode in blenderproc?

Open scotgopal opened this issue 2 years ago • 2 comments

Describe the issue

Is there a way to modify the blend_method in blenderproc? Here's the link to the property in BlenderPy that I would like to modify via bproc: https://docs.blender.org/api/current/bpy.types.Material.html#bpy.types.Material.blend_method. My goal is to make an object transparent and simply changing the 'Alpha' value of the principled bsdf shader to 0 doesn't help me allow light to pass through this object in view mode: Viewport Shading.

Minimal code example

No response

Files required to run the code

No response

Expected behavior

  • Learn to modify the blend_method in bproc
  • Make objects transparent

BlenderProc version

v3.1.0

scotgopal avatar Jun 14 '23 05:06 scotgopal

I think this is the only way to do this via bproc since there are no methods available to directly modify this. It accesses the blender_obj attribute of the object with type blenderproc.types.MeshObject, followed by directly accessing the material of the object, named 'transparent_mat'.

obj_spawn_area.blender_obj.data.materials[
                    "transparent_mat"
                ].blend_method = "BLEND"

scotgopal avatar Jun 14 '23 06:06 scotgopal

Yes you are right, there is currently no blenderproc api method to change the blend_method. Feel free to add one and create a PR.

cornerfarmer avatar Jun 19 '23 11:06 cornerfarmer