Heyyy there!
So, following PBR and the canonical rendering equation, I was trying to figure out how you would go about importance sampling by sampling a BRDF directly. You know, by generating a bunch of random rays in a hemisphere around a surface normal and sampling the BRDF, instead of cosine-weighted sampling or sampling lobes or whatnot. It's not the fastest or best way by a long shot, but it'd be useful when I'm trying out different specular reflectance functions, or playing with different BRDFs in general.
Sampling the BRDF would create a weighted distribution. I'm thinking that you could do something like:
sample N rays and give them weights equal to brdf(...) * cos(angle_between_normal_and_ray_direction)
pick one of the rays randomly, given its weight
the density function for this point is equal to (the weight of the previously picked ray) / (sum of all the weights)
the new ray to cast is the picked ray
However, I don't exactly know if that's right. I haven't really been able to find anything about it. Mostly, people talk about the PDF and how you use it to weigh different rays, but when it comes down to the derivation, it's usually left out, so I don't really know how it's supposed to be calculated, or if I'm treating the concept right. I've also never heard of a BRDF-weighted distribution, but that's probably because it's not a good idea
I tested it out on a calculator, using a cosine-weighted distribution as a test, and the PDF seemed kinda close to what it should be. I also tried it out on a pathtracer I have laying around, and it seems like it works, but then again, I don't really trust my eyes with this stuff anymore.
So is this a correct method of generating a BRDF-weighted ray? Or is it more complicated that I think it is?
Thanks!