Skip to content

Commit

Permalink
fix blender 4.1 render pass
Browse files Browse the repository at this point in the history
  • Loading branch information
NullSenseStudio authored and carson-katri committed Aug 12, 2024
1 parent f8abd77 commit 80e7c70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,10 @@ def render_pass_to_np(
top_to_bottom: bool = True
):
array = np.empty((*reversed(size), render_pass.channels), dtype=np.float32)
render_pass.rect.foreach_get(array.reshape((-1, render_pass.channels)))
if BLENDER_VERSION >= (4, 1, 0):
render_pass.rect.foreach_get(array.reshape(-1))
else:
render_pass.rect.foreach_get(array.reshape(-1, render_pass.channels))
if color_management:
array = scene_color_transform(array, color_space=color_space, clamp_srgb=clamp_srgb)
elif color_space is not None:
Expand Down
5 changes: 2 additions & 3 deletions render_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ def render(self, depsgraph):
for original_pass in original_layer.passes:
if original_pass.name == render_pass.name:
source_pass = original_pass
pixels = np.empty((len(source_pass.rect), len(source_pass.rect[0])), dtype=np.float32)
source_pass.rect.foreach_get(pixels)
render_pass.rect[:] = pixels
pixels = image_utils.render_pass_to_np(source_pass, size=(size_x, size_y))
image_utils.np_to_render_pass(pixels, render_pass)
self.end_result(render_result)
except Exception as e:
print(e)
Expand Down

0 comments on commit 80e7c70

Please sign in to comment.