mitsuba-renderer / mitsuba3

Mitsuba 3: A Retargetable Forward and Inverse Renderer
https://www.mitsuba-renderer.org/
Other
2.1k stars 246 forks source link

The pdf of the sample position obtained by shape.sample_position() is not a correct value #1218

Closed ioissss closed 3 months ago

ioissss commented 4 months ago

I used the shape's sample_position() function to sample on a certain shape, but I found that the pdf in the resulting positionSample was greater than 1! In my understanding, the probability density function would not have a value greater than 1, but then this happened, the codes are as followed:

positionSample = shape.sample_position(time=0,sample=[sampler.next_float32(),sampler.next_float32()],active=True)
pdf  = positionSample.pdf
print(pdf)

the result is : image

By the way, is the location of the sampling point obtained located in the object coordinate system? How do I translate it to the world coordinate system, I can't seem to get the transformation matrix for the corresponding object :)

njroussel commented 4 months ago

Hi @ioissss

The position sample should be in world-space, and the pdf value does indeed seem wrong here. Could you provide a full reproducer ? What does the shape.surface_area() method return ?

memamsaleh commented 3 months ago

Hi @njroussel

Not the original author of the issue but this happens to any object with a small surface area (<1) as the pdf just returns the inverse area. You can easily reproduce it with small spheres or rectangles.

njroussel commented 3 months ago

Oh that's totally expected and still mathematically sound -- if you integrate it over the surface, you'll still get 1.

I'll close this for now, unless there's something more too this issue.