r/GraphicsProgramming • u/sgkadesh • Sep 01 '21
Working on a software renderer, confused as to why my explicit light sampling isn't working
I'm working on a software renderer in Java.
I have implemented a naive path tracer, and am in the process of implementing a smarter path tracer (rendering/SmartPathTracerRenderer.java), including russian roulette path termination, bsdf sampling for new ray direction, and explicit light sampling.
I think that I am calculating the pdf of my light sampling incorrectly, but I'm not really sure what I'm doing wrong. The resulting images seem to be too bright, and suggesting that the cos(theta)/pdf value is greater than one. I'm certain that I'm calculating cos(theta) correctly, so I think it's probably my pdf
Advice is welcome. Also, see my sample images
0
Upvotes
1
u/msqrt Sep 01 '21
Assuming you just pick a point randomly on the surface of the light mesh, the correct pdf is just 1/area with no extra terms.