diff --git a/yt/utilities/amr_kdtree/amr_kdtools.py b/yt/utilities/amr_kdtree/amr_kdtools.py index f42e3a36f7f..01d7327a267 100644 --- a/yt/utilities/amr_kdtree/amr_kdtools.py +++ b/yt/utilities/amr_kdtree/amr_kdtools.py @@ -3,13 +3,17 @@ from yt.funcs import mylog -def receive_and_reduce(comm, incoming_rank, image, add_to_front): +def receive_and_reduce(comm, incoming_rank, image, add_to_front, *, use_opacity=True): mylog.debug("Receiving image from %04i", incoming_rank) # mylog.debug( '%04i receiving image from %04i'%(self.comm.rank,back.owner)) arr2 = comm.recv_array(incoming_rank, incoming_rank).reshape( (image.shape[0], image.shape[1], image.shape[2]) ) + if not use_opacity: + np.add(image, arr2, image) + return image + if add_to_front: front = arr2 back = image @@ -31,6 +35,7 @@ def receive_and_reduce(comm, incoming_rank, image, add_to_front): for i in range(4): np.multiply(image[:, :, i], ta, image[:, :, i]) np.add(image, front, image) + return image diff --git a/yt/utilities/amr_kdtree/amr_kdtree.py b/yt/utilities/amr_kdtree/amr_kdtree.py index b8378c66715..861f4320c14 100644 --- a/yt/utilities/amr_kdtree/amr_kdtree.py +++ b/yt/utilities/amr_kdtree/amr_kdtree.py @@ -294,7 +294,7 @@ def get_reduce_owners(self): owners[temp.node_id] = owners[temp.left.node_id] return owners - def reduce_tree_images(self, image, viewpoint): + def reduce_tree_images(self, image, viewpoint, *, use_opacity=True): if self.comm.size <= 1: return image myrank = self.comm.rank @@ -307,7 +307,11 @@ def reduce_tree_images(self, image, viewpoint): split_pos = node.parent.get_split_pos() add_to_front = viewpoint[split_dim] >= split_pos image = receive_and_reduce( - self.comm, owners[node.parent.right.node_id], image, add_to_front + self.comm, + owners[node.parent.right.node_id], + image, + add_to_front, + use_opacity=use_opacity, ) if node.parent.node_id == 1: break diff --git a/yt/visualization/volume_rendering/render_source.py b/yt/visualization/volume_rendering/render_source.py index 65d6cd2e557..c7d0beed2e4 100644 --- a/yt/visualization/volume_rendering/render_source.py +++ b/yt/visualization/volume_rendering/render_source.py @@ -607,7 +607,11 @@ def render(self, camera, zbuffer=None): def finalize_image(self, camera, image): if self._volume is not None: - image = self.volume.reduce_tree_images(image, camera.lens.viewpoint) + image = self.volume.reduce_tree_images( + image, + camera.lens.viewpoint, + use_opacity=self.transfer_function.grey_opacity, + ) return super().finalize_image(camera, image)