-
SummaryI'm debugging rendering in spectral mode in Python and have set
Initially, I configured a BSDF with 75-channel reflectance. However, during the debugging process, I noticed that the return value of This behavior differs from my original expectation. So, during rendering in spectral mode, is the number of channels in the sample function fixed at 4 channels, even if the material parameters may be set to have more channels? System configurationSystem information: OS: Windows-10 Dr.Jit: 0.4.4 Steps to reproduce1.here is my test function class real_data_integrator(mi.SamplingIntegrator):
def __init__(self, props):
super().__init__(props)
def sample(self,
scene: mi.Scene,
sampler:mi.Sampler,
ray: mi.RayDifferential3f,
medium: mi.Medium = None,
active: bool = True) -> tuple[mi.Color3f, bool, list[float]]:
L = mi.Spectrum(0.0)
# ---------------------- Direct emission ----------------------
si = scene.ray_intersect(ray, active)
bsdf_ctx = mi.BSDFContext()
sample1 = sampler.next_1d()
sample2 = sampler.next_2d()
bsdf: mi.BSDF = si.bsdf()
bsdf_sample, bsdf_weight = bsdf.sample(
bsdf_ctx, si, sample1, sample2)
self.shape_confirm(bsdf_weight)
valid_ray = active & si.is_valid()
active &= si.is_valid()
cosThetaI = mi.Frame3f.cos_theta(si.wi)
active &= (cosThetaI>0)
# Sample the emitter
ds, em_weight = scene.sample_emitter_direction(
si, sampler.next_2d(), True, active
)
active &= ds.pdf != 0.0
self.shape_confirm(em_weight)
return dr.select(True, L, 0.0), valid_ray, []
@dr.wrap(source='drjit', target='torch')
def shape_confirm(self,em_weight):
print(em_weight.shape) 2.here is my test xml <scene version="3.0.0">
<default name="spp" value="32"/>
<default name="res" value="512"/>
<integrator type="My_integrator"/>
<sensor type="perspective" id="sensor">
<string name="fov_axis" value="smaller"/>
<float name="near_clip" value="0.001"/>
<float name="far_clip" value="100.0"/>
<float name="focus_distance" value="1000"/>
<float name="fov" value="40"/>
<transform name="to_world">
<lookat origin="0, 0, 3.6"
target="0, 0, 0"
up ="0, 1, 0"/>
</transform>
<sampler type="independent">
<integer name="sample_count" value="$spp"/>
</sampler>
<film type="hdrfilm">
<integer name="width" value="$res"/>
<integer name="height" value="$res"/>
<rfilter type="tent"/>
<string name="pixel_format" value="rgb"/>
<string name="component_format" value="float32"/>
</film>
</sensor>
<emitter type="directional">
<vector name="direction" value="0.0, 0.0, -1.0"/>
<!-- <spectrum name="irradiance" value="400:1.0 ,450:2.0 ,500:1.0 ,550:2.0 ,600:1.0 ,700:3.0"/> -->
<rgb name="irradiance" value="1.0"/>
</emitter>
<shape type="obj">
<string name="filename" value="cube.obj" />
<transform name="to_world">
<scale value="1"/>
<translate x="0" y="0" z="0"/>
</transform>
<bsdf type="diffuse">
<spectrum name="reflectance" value="400:0.343, 404:0.445, 408:0.551, 412:0.624, 416:0.665, 420:0.687, 424:0.708, 428:0.723, 432:0.715, 436:0.71, 440:0.745, 444:0.758, 448:0.739, 452:0.767, 456:0.777, 460:0.765, 464:0.751, 468:0.745, 472:0.748, 476:0.729, 480:0.745, 484:0.757, 488:0.753, 492:0.75, 496:0.746, 500:0.747, 504:0.735, 508:0.732, 512:0.739, 516:0.734, 520:0.725, 524:0.721, 528:0.733, 532:0.725, 536:0.732, 540:0.743, 544:0.744, 548:0.748, 552:0.728, 556:0.716, 560:0.733, 564:0.726, 568:0.713, 572:0.74, 576:0.754, 580:0.764, 584:0.752, 588:0.736, 592:0.734, 596:0.741, 600:0.74, 604:0.732, 608:0.745, 612:0.755, 616:0.751, 620:0.744, 624:0.731, 628:0.733, 632:0.744, 636:0.731, 640:0.712, 644:0.708, 648:0.729, 652:0.73, 656:0.727, 660:0.707, 664:0.703, 668:0.729, 672:0.75, 676:0.76, 680:0.751, 684:0.739, 688:0.724, 692:0.73, 696:0.74, 700:0.737"/>
</bsdf>
</shape>
</scene> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Hello @free7187, Indeed, the number of wavelengths samples by each ray is a compile-time constant. By default, it is set to 4, e.g.: mitsuba3/resources/mitsuba.conf.template Line 329 in b70b7e3 but you can in principle increase it in your The idea is that by sampling 4 wavelengths per ray and accumulating results from many rays, the full spectrum will still be correctly integrated. |
Beta Was this translation helpful? Give feedback.
I haven't tried this myself, but in principle it should be possible to add the missing bindings here:
https://github.com/mitsuba-renderer/drjit/blob/5bc1d4eed09fe05a5dc9d7eba9ca15ab946cf84b/src/python/bind.h#L610