Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce rendered images without considering opacity #4877

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion yt/utilities/amr_kdtree/amr_kdtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down
8 changes: 6 additions & 2 deletions yt/utilities/amr_kdtree/amr_kdtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion yt/visualization/volume_rendering/render_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down