-
-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Good day,
I need to follow a ray along its path and acquire information of all its multiple intersections. To this end, I'm considering the following example involving the scattering from a corner reflector:
import numpy as np
from plotoptix import TkOptiX
from plotoptix import NpOptiX
import matplotlib.pyplot as plt
nu = 7
nv = 7
def displayResults(rt):
print("Launch finished.")
hitPositionsData = rt._hit_pos
xHitPositions = hitPositionsData[:, :, 0]
yHitPositions = hitPositionsData[:, :, 1]
zHitPositions = hitPositionsData[:, :, 2]
dHitPositions = hitPositionsData[:, :, 3]
hitTriangle = rt._geo_id[:, :, 1].reshape(rt._height, rt._width)
print("Shape of rays array is {}.".format(xHitPositions.shape))
xHitPositions = xHitPositions[hitTriangle < 0xFFFFFFFF]
yHitPositions = yHitPositions[hitTriangle < 0xFFFFFFFF]
dHitPositions[np.where(hitTriangle >= 0xFFFFFFFF)] = -1
hitTriangle[np.where(hitTriangle >= 0xFFFFFFFF)] = 10
print(dHitPositions)
print("Shape of hitting rays array is {}.".format(xHitPositions.shape))
plt.plot(xHitPositions, yHitPositions, 'bo')
plt.show()
plt.imshow(dHitPositions)
plt.colorbar()
plt.show()
plt.imshow(hitTriangle)
plt.colorbar()
plt.show()
plt.draw()
#verticesTriangle = np.array([[-2, -2, 0], [2, -2, 0], [-2, 2, 0], [2, 2, 0]])
#faceTriangle = np.array([[0, 1, 2], [1, 2, 3]])
#verticesTriangles = np.array([[-1, -1, 0], [1, -1, 0], [-1, 1, 0], [1, 1, 0], [-1, 1, 2], [1, 1, 2]])
#faceTriangles = np.array([[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]])
verticesTriangles = np.array([[0, 1, 0], [0, -1, 0], [0.5 * np.sqrt(2), 1, 0.5 * np.sqrt(2)], [0.5 * np.sqrt(2), -1, 0.5 * np.sqrt(2)], [-0.5 * np.sqrt(2), 1, 0.5 * np.sqrt(2)], [-0.5 * np.sqrt(2), -1, 0.5 * np.sqrt(2)]])
faceTriangles = np.array([[0, 1, 2], [1, 2, 3], [0, 1, 4], [1, 4, 5]])
rt = NpOptiX(on_rt_accum_done = displayResults, width = nu, height = nv)
#rt = NpOptiX(width = nu, height = nv)
rt.set_mesh("Mesh", verticesTriangles, faceTriangles)
u = np.linspace(-1.9, 2.1, nu)
v = np.linspace(-2, 2, nv)
V, U = np.meshgrid(v, u)
W = np.full((nu, nv), -1)
originsTexture = np.stack((U, V, W, np.zeros((nu, nv)))).T
rt.set_texture_2d("origins", originsTexture)
cx = np.zeros((nu, nv))
cy = np.zeros((nu, nv))
cz = np.ones((nu, nv))
r = np.full((nu, nv), 200)
directionsTexture = np.stack((cx, cy, cz, r)).T
rt.set_texture_2d("directions", directionsTexture)
rt.setup_camera("custom_cam", cam_type = "CustomProjXYZtoDir", textures = ["origins", "directions"])
rt.set_param(max_accumulation_frames = 1)
rt.set_uint("path_seg_range", 1, 4)
rt.start()
#rt.close()
I have the following questions:
- I'm setting
path_seg_range
to enable multiple reflections. However, it seems the line does not have an effect. If I comment it out, the results seem to be the same. - I access the hit positions and hit distances by the
rt._hit_pos
array. However, for my purposes, I need to know all the hit positions and distances per ray. Is that possible by PlotOptiX?
Metadata
Metadata
Assignees
Labels
No labels