@@ -58,7 +58,7 @@ emitter shape and specify an :monosp:`area` instance as its child:
5858template <typename Float, typename Spectrum>
5959class AreaLight final : public Emitter<Float, Spectrum> {
6060public:
61- MI_IMPORT_BASE (Emitter, m_flags, m_shape, m_medium)
61+ MI_IMPORT_BASE (Emitter, m_flags, m_shape, m_medium, m_needs_sample_2_3d )
6262 MI_IMPORT_TYPES (Scene, Shape, Texture)
6363
6464 AreaLight (const Properties &props) : Base (props) {
@@ -68,6 +68,7 @@ class AreaLight final : public Emitter<Float, Spectrum> {
6868 " shape." );
6969
7070 m_radiance = props.texture_d65 <Texture>(" radiance" , 1 .f );
71+ m_needs_sample_2_3d = false ;
7172
7273 m_flags = +EmitterFlags::Surface;
7374 if (m_radiance->is_spatially_varying ())
@@ -90,7 +91,7 @@ class AreaLight final : public Emitter<Float, Spectrum> {
9091 }
9192
9293 std::pair<Ray3f, Spectrum> sample_ray (Float time, Float wavelength_sample,
93- const Point2f &sample2, const Point2f &sample3,
94+ const Point3f &sample2, const Point2f &sample3,
9495 Mask active) const override {
9596 MI_MASKED_FUNCTION (ProfilerPhase::EndpointSampleRay, active);
9697
@@ -115,7 +116,7 @@ class AreaLight final : public Emitter<Float, Spectrum> {
115116 }
116117
117118 std::pair<DirectionSample3f, Spectrum>
118- sample_direction (const Interaction3f &it, const Point2f &sample, Mask active) const override {
119+ sample_direction (const Interaction3f &it, const Point3f &sample, Mask active) const override {
119120 MI_MASKED_FUNCTION (ProfilerPhase::EndpointSampleDirection, active);
120121 Assert (m_shape, " Can't sample from an area emitter without an associated Shape." );
121122 DirectionSample3f ds;
@@ -124,13 +125,13 @@ class AreaLight final : public Emitter<Float, Spectrum> {
124125 // One of two very different strategies is used depending on 'm_radiance'
125126 if (likely (!m_radiance->is_spatially_varying ())) {
126127 // Texture is uniform, try to importance sample the shape wrt. solid angle at 'it'
127- ds = m_shape->sample_direction (it, sample, active);
128+ ds = m_shape->sample_direction (it, Point2f ( sample. x (), sample. y ()) , active);
128129 active &= dr::dot (ds.d , ds.n ) < 0 .f && dr::neq (ds.pdf , 0 .f );
129130
130131 si = SurfaceInteraction3f (ds, it.wavelengths );
131132 } else {
132133 // Importance sample the texture, then map onto the shape
133- auto [uv, pdf] = m_radiance->sample_position (sample, active);
134+ auto [uv, pdf] = m_radiance->sample_position (Point2f ( sample. x (), sample. y ()) , active);
134135 active &= dr::neq (pdf, 0 .f );
135136
136137 si = m_shape->eval_parameterization (uv, +RayFlags::All, active);
@@ -193,7 +194,7 @@ class AreaLight final : public Emitter<Float, Spectrum> {
193194 }
194195
195196 std::pair<PositionSample3f, Float>
196- sample_position (Float time, const Point2f &sample,
197+ sample_position (Float time, const Point3f &sample,
197198 Mask active) const override {
198199 MI_MASKED_FUNCTION (ProfilerPhase::EndpointSamplePosition, active);
199200 Assert (m_shape, " Cannot sample from an area emitter without an associated Shape." );
@@ -202,10 +203,10 @@ class AreaLight final : public Emitter<Float, Spectrum> {
202203 PositionSample3f ps;
203204 if (!m_radiance->is_spatially_varying ()) {
204205 // Radiance not spatially varying, use area-based sampling of shape
205- ps = m_shape->sample_position (time, sample, active);
206+ ps = m_shape->sample_position (time, Point2f ( sample. x (), sample. y ()) , active);
206207 } else {
207208 // Importance sample texture
208- auto [uv, pdf] = m_radiance->sample_position (sample, active);
209+ auto [uv, pdf] = m_radiance->sample_position (Point2f ( sample. x (), sample. y ()) , active);
209210 active &= dr::neq (pdf, 0 .f );
210211
211212 auto si = m_shape->eval_parameterization (uv, +RayFlags::All, active);
0 commit comments