Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/yt/visualization/volume_rendering/lens.py b/yt/visualization/volume_rendering/lens.py
- index b5b466467..31ff6dfec 100644
- --- a/yt/visualization/volume_rendering/lens.py
- +++ b/yt/visualization/volume_rendering/lens.py
- @@ -46,12 +46,15 @@ class Lens(ParallelAnalysisInterface):
- """
- self.setup_box_properties(camera)
- - def new_image(self, camera):
- + def new_image(self, camera, color='k'):
- """Initialize a new ImageArray to be used with this lens."""
- + from matplotlib.colors import to_rgba
- + color = to_rgba(color)
- self.current_image = ImageArray(
- np.zeros((camera.resolution[0], camera.resolution[1],
- 4), dtype='float64', order='C'),
- info={'imtype': 'rendering'})
- + self.current_image += color
- return self.current_image
- def setup_box_properties(self, camera):
- @@ -152,13 +155,6 @@ class PerspectiveLens(Lens):
- def __init__(self):
- super(PerspectiveLens, self).__init__()
- - def new_image(self, camera):
- - self.current_image = ImageArray(
- - np.zeros((camera.resolution[0], camera.resolution[1],
- - 4), dtype='float64', order='C'),
- - info={'imtype': 'rendering'})
- - return self.current_image
- -
- def _get_sampler_params(self, camera, render_source):
- # Enforce width[1] / width[0] = resolution[1] / resolution[0]
- camera.width[1] = camera.width[0] \
- @@ -299,14 +295,6 @@ class StereoPerspectiveLens(Lens):
- super(StereoPerspectiveLens, self).__init__()
- self.disparity = None
- - def new_image(self, camera):
- - """Initialize a new ImageArray to be used with this lens."""
- - self.current_image = ImageArray(
- - np.zeros((camera.resolution[0], camera.resolution[1], 4),
- - dtype='float64', order='C'),
- - info={'imtype': 'rendering'})
- - return self.current_image
- -
- def _get_sampler_params(self, camera, render_source):
- # Enforce width[1] / width[0] = 2 * resolution[1] / resolution[0]
- # For stereo-type lens, images for left and right eye are pasted together,
- @@ -524,14 +512,6 @@ class FisheyeLens(Lens):
- super(FisheyeLens, self).setup_box_properties(camera)
- self.set_viewpoint(camera)
- - def new_image(self, camera):
- - """Initialize a new ImageArray to be used with this lens."""
- - self.current_image = ImageArray(
- - np.zeros((camera.resolution[0], camera.resolution[0],
- - 4), dtype='float64', order='C'),
- - info={'imtype': 'rendering'})
- - return self.current_image
- -
- def _get_sampler_params(self, camera, render_source):
- vp = -arr_fisheye_vectors(camera.resolution[0], self.fov)
- vp.shape = (camera.resolution[0], camera.resolution[0], 3)
- diff --git a/yt/visualization/volume_rendering/render_source.py b/yt/visualization/volume_rendering/render_source.py
- index 434401f87..0b06b90cc 100644
- --- a/yt/visualization/volume_rendering/render_source.py
- +++ b/yt/visualization/volume_rendering/render_source.py
- @@ -467,10 +467,7 @@ class VolumeSource(RenderSource):
- if self._volume is not None:
- image = self.volume.reduce_tree_images(image, camera.lens.viewpoint)
- image.shape = camera.resolution[0], camera.resolution[1], 4
- - # If the call is from VR, the image is rotated by 180 to get correct
- - # up direction
- - if self.transfer_function.grey_opacity is False:
- - image[:, :, 3] = 1
- +
- return image
- def __repr__(self):
- diff --git a/yt/visualization/volume_rendering/scene.py b/yt/visualization/volume_rendering/scene.py
- index e27185943..309a0bb7a 100644
- --- a/yt/visualization/volume_rendering/scene.py
- +++ b/yt/visualization/volume_rendering/scene.py
- @@ -107,6 +107,34 @@ class Scene(object):
- return self.sources[item]
- return self.get_source(item)
- + _background_color = "black"
- + def background_color():
- + doc = """
- + The background color sets the color of the scene's background.
- + Note that background_color cannot be set if the scene contains
- + a VolumeSource with a grey_opacity=False transfer function
- +
- + Parameters
- + ----------
- + background_color : string or 3 or 4 element iterable
- + The color to use for the background. It will be converted
- + to an RGBA tuple using matplotlib.colors.to_rgba.
- + """
- + def fget(self):
- + return self._background_color
- +
- + def fset(self, value):
- + for source in self.sources.values():
- + if isinstance(source, VolumeSource):
- + tf = source.transfer_function
- + if not getattr(tf, 'grey_opacity', False):
- + raise RuntimeError(
- + "Cannot set the background color for a render "
- + "source with grey_opacity=True")
- + self._background_color = value
- + return locals()
- + background_color = property(**background_color())
- +
- @property
- def opaque_sources(self):
- """
- @@ -522,7 +550,7 @@ class Scene(object):
- """
- if camera is None:
- camera = self.camera
- - empty = camera.lens.new_image(camera)
- + empty = camera.lens.new_image(camera, color=self.background_color)
- opaque = ZBuffer(empty, np.full(empty.shape[:2], np.inf))
- for k, source in self.opaque_sources:
Add Comment
Please, Sign In to add comment