shocker-0x15 / GfxExp

Sandbox for graphics paper implementation
Other
228 stars 20 forks source link

Question about light contribution calculation #2

Closed l2- closed 2 years ago

l2- commented 2 years ago

Hi,

https://github.com/shocker-0x15/GfxExp/blob/ec95e561121812b7224579e3190d05db77ff19a4/restir/optix_kernels.cu#L868 https://github.com/shocker-0x15/GfxExp/blob/ec95e561121812b7224579e3190d05db77ff19a4/restir/optix_kernels.cu#L1403 I noticed that emittance is divided by PI even when the primary hit of the ray was an emitter. I was wondering what the reason is for this? For example if a primary ray hits an emitter with emittance (1.0, 1.0, 1.0) the shading will result in (1/pi, 1/pi, 1/pi) resulting in a visually dimmed primitive on the screen. Naturally this is only noticeable with emitters with emitting strength lower than pi.

image Here I am hovering a pixel for which the primary hit is an emitter with values (1.0, 1.0, 1.0) as you can see in the debug info. I think the pixel in that case should also have value (1.0, 1.0 ,1.0) unless I understand wrong.

This is the result when using contribution += emittance; image

shocker-0x15 commented 2 years ago

The reason for this is that emittance is not radiance. This is similar to the relation between (directional-hemispherical) reflectance vs Lambertian BRDF. If we have a Lambertian BRDF whose reflectance is 0.5, BRDF value is 0.5 / pi, not 0.5. (Note that the denominator is pi, not 2* pi. This is due to the definition of radiance, where the value is divided by a cosine factor).

I assume diffuse emitter for these samples, so I hard-coded dividing by pi. However if we use arbitrary directional distribution for emitters, it should be replaced by some value of EDF (Emittance Distribution Function, I don't think the industry has consensus for this name and the definition unlike BRDF).