-
I'm doing an experiment where I want to randomly sample N points in a scene, which cannot be inside a closed object, and generate random rays by randomly sampling directions on the sampled points. I've tried using the samples = []
bsdfs = []
num_samples = int(max(num_samples/len(scene.shapes()),1))
for shape in scene.shapes():
for _ in range(num_samples):
sample = shape.sample_position(time=0,sample=sampler.next_2d())
to_world = shape.
si = mi.SurfaceInteraction3f()
si.p = sample.p
si.sh_frame = mi.Frame3f(sample.n)
si.uv = sample.uv
specular_reflectance = shape.eval_attribute(name="specular_reflectance",si=si)
diffuse_reflectance = shape.eval_attribute(name="diffuse_reflectance",si = si)
samples.append(sample)
bsdfs.append(shape.bsdf()) Also, does every type of bsdf have specular_reflectance and diffuse_reflectance? and how should I get the corresponding value at the sampling point? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @ioissss I'm assuimg you want to sample points on surfaces. I'd recommend a two-level scheme, where you first sample a shape, and then sample a point on the shape using To sample a shape, you can build a 1D disrete distibution from the shapes' surface areas. Once a shape is sampled, the No, not every BSDF has those two components. If you keep track of the shape you sampled from, you can request its BSDF, with |
Beta Was this translation helpful? Give feedback.
Hi @ioissss
I'm assuimg you want to sample points on surfaces. I'd recommend a two-level scheme, where you first sample a shape, and then sample a point on the shape using
shape.sample_position()
.To sample a shape, you can build a 1D disrete distibution from the shapes' surface areas.
Once a shape is sampled, the
sample_position()
will return a point in world-space.No, not every BSDF has those two components. If you keep track of the shape you sampled from, you can request its BSDF, with
shape.bsdf()
.