In [ ]:
import yt
import numpy as np
from yt.testing import fake_vr_orientation_test_ds
ds = fake_vr_orientation_test_ds()
In [ ]:
# now we do volume rendering
sc = yt.create_scene(ds, field='density')
# Change transfer function
tf = yt.ColorTransferFunction((np.log10(0.1), np.log10(1.)))
tf.sample_colormap(np.log10(0.9), 0.01, colormap="spectral")
tf.sample_colormap(np.log10(0.8), 0.01, colormap="spectral")
tf.sample_colormap(np.log10(0.6), 0.01, colormap="spectral")
tf.sample_colormap(np.log10(0.2), 0.01, colormap="spectral")
render_source = sc.get_source(0)
render_source.transfer_function = tf
In [ ]:
# plane-parallel lens
cam = sc.add_camera(ds, lens_type='plane-parallel')
cam.resolution = (500, 500) # equivalent with cam.set_resolution()
cam.width = ds.quan(4, 'code_length') # equivalent with cam.set_width()
cam.position = ds.arr([2.5, 0, 0], 'code_length') # equivalent with cam.set_position()
cam.switch_orientation(normal_vector=[-1, 0, 0],
north_vector=[0, 0, 1])
sc.render()
sc.show(sigma_clip=2.0)
In [ ]:
# perspective lens
cam = sc.add_camera(ds, lens_type='perspective')
cam.resolution = (500, 500)
cam.width = ds.arr([2, 2, 1], 'code_length')
cam.position = ds.arr([2.5, 0, 0], 'code_length')
cam.switch_orientation(normal_vector=[-1, 0, 0],
north_vector=[0 ,0, 1])
sc.render()
sc.show(sigma_clip=6.0)
In [ ]:
# spherical lens
cam = sc.add_camera(ds, lens_type='spherical')
cam.resolution = (1000, 500)
cam.position = ds.arr([0.5, 0, 0], 'code_length')
cam.switch_orientation(normal_vector=[-1 ,0 ,0],
north_vector=[0 ,0 ,1])
sc.render()
sc.show(sigma_clip=6.0)
In [ ]:
# stereo-spherical lens (another similar lens is stereo-perspective)
cam = sc.add_camera(ds, lens_type='stereo-spherical')
cam.disparity = ds.domain_width[0] * 1.5e-3 # separation between two eyes
cam.resolution = (1000, 1000)
cam.position = ds.arr([0.5, 0, 0], 'code_length')
cam.switch_orientation(normal_vector=[-1 ,0, 0],
north_vector=[0, 0, 1])
sc.render()
sc.show(sigma_clip=6.0)