-
I am trying to record the paths of rays sampled in multiple directions, but I'm not quite sure how to do that. I thought I could start with the "Script a Renderer" tutorial, but there are a few things I don't understand:
Attaching pics of what I am trying to do, and the code block I currently have. Any help is very much appreciated! # Primary Surface Intersection
si = scene.ray_intersect(rays)
bsdf = si.bsdf(rays)
# Standard BSDF evaluation context for path tracing
bsdf_ctx = mi.BSDFContext()
# Getting Sampler from Camera
loaded_sensor = mi.load_dict(sensor)
sampler = loaded_sensor.sampler().clone()
# Loop iteration counter
i = mi.UInt32(0)
# Initialize the loop state (listing all variables that are modified inside the loop)
loop = mi.Loop(name="", state=lambda: (i, si,))
# while loop(si.is_valid() & (i < ambient_ray_count)):
with dr.suspend_grad():
# 1. Compute directions of initial surface interaction
bsdf_sample, bsdf_weight = bsdf.sample(bsdf_ctx, si, sampler.next_1d(),
sampler.next_2d())
# 2. Spawn a new ray starting at the surface interactions
rays2= si.spawn_ray(si.to_world(bsdf_sample.wo)) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi @h-OUS-e
Note: You'll most likely want to use a recorded loop (
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Hi @h-OUS-e
si.p
to some normal Python list. In addition, of course, you'll want to save a mask to know which rays are still active.Note: You'll most likely want to use a recorded loop (
mi.Loop
) for performance which is incompatible with what I mentioned above about visualizations. So you can either use a normal Python loop, or not save ray paths during optimization or even have a separate code path just for the visualizations.