zju3dv / pvnet-rendering

render images for pvnet training
Apache License 2.0
183 stars 46 forks source link

AttributeError: 'RenderSettings' object has no attribute 'alpha_mode' #53

Closed Xiaflowers closed 3 years ago

Xiaflowers commented 3 years ago

你好,我在运行时出现下面这个问题:AttributeError: 'RenderSettings' object has no attribute 'alpha_mode'具体内容是: Traceback (most recent call last): File "/home/lee/py/pvnet-rendering/blender/render_backend.py", line 453, in camera, depth_file_output = setup() File "/home/lee/py/pvnet-rendering/blender/render_backend.py", line 93, in setup bpy.context.scene.render.alpha_mode = 'TRANSPARENT' AttributeError: 'RenderSettings' object has no attribute 'alpha_mode' 请问这该如何解决呢?

pengsida commented 3 years ago

你用什么版本的blender

Xiaflowers commented 3 years ago

2.83

pengsida commented 3 years ago

image

YuQiao0303 commented 1 year ago

你好,我用这个方法成功了(虽然我用的不是这个脚本,但解决了同款报错)。Hi, I've just tried the following method and it worked.

: https://blenderartists.org/t/2-80-cheat-sheet-for-updating-add-ons/1148974.

这个链接里面说: It's said in it that:

`So I just ran into this problem updating Level Builder, and the answer didn’t come up in a Google search so I am updating this necro thread.

bpy.data.scenes[“Scene”].render.alpha_mode : [“SKY”, “TRANSPARENT”] is now

bpy.data.scenes[“Scene”].render.film_transparent : [0, 1] Here’s hoping Google finds this answer for the next coder.`

So I modified my code like this and it worked fine:

if g_background_image_path == 'TRANSPARENT':
  # bpy.context.scene.render.alpha_mode = g_background_image_path # 2.79
  bpy.context.scene.render.image_settings.color_mode = 'RGBA' # blender 2.8
  bpy.context.scene.render.film_transparent = 1 # 0 for "SKY"; 1 for "TRANSPARENT

由于blender2.7和2.8之间还有很大的改动,不排除还会有其他不兼容的地方