## Sampling Ashikhmin-Shirley BRDF

Practical and theoretical implementation discussion.
papaboo
Posts: 42
Joined: Fri Jun 21, 2013 10:02 am
Contact:

### Sampling Ashikhmin-Shirley BRDF

Hey everyone,

I'm attempting to implement the Ashikhmin-Shirley BRDF described in An Anisotropic Phong BRDF Model, but I'm having a hard time with the sampling.

In the Monte Carlo sampling section of the paper they describe how the specular part of the BRDF should be sampled by sampling each quadrant of the hemisphere. Then the diffuse part should be sampled using a cosine distribution and "To generate samples for the entire BRDF, simply use a weighted average of 1 and p(k2)"

My question is then how do I combine those two sampling strategies? Or specifically how do I generate a single sample direction and the corresponding density value? I could do it by treating the BRDF as a composition of two BRDFS (specular and diffuse) and then randomly select either the quadrant or the cosine distribution, but if there is a way to generate a sample without using another random number, then that would be great

Cheers
Asger

friedlinguini
Posts: 89
Joined: Thu Apr 11, 2013 5:15 pm

### Re: Sampling Ashikhmin-Shirley BRDF

If you're feeling stingy about generating random numbers, you can reuse a random number that was used to generate a discrete choice. E.g.,

Code: Select all

float r1 = random();
float r2 = random();
if (r1 < diffuseProbability) {
r1 = r1 / diffuseProbability;
// Do diffuse sampling using r1,r2
} else {
r1 = (r1 - diffuseProbability) / (1.0 - diffuseProbability)
// Do specular sampling using r1,r2
}
Note that you potentially run into precision issues if diffuseProbability is too close to (but not equal to) 0 or 1.

papaboo
Posts: 42
Joined: Fri Jun 21, 2013 10:02 am
Contact:

### Re: Sampling Ashikhmin-Shirley BRDF

Arh yes I could do that, but it would probably introduce too much noise in edge cases.

I was hoping there would be some combined sampling technique, but if not I'll simply split it into two BRDFs and let my BSDF sample them along with any other BRDFs. Then I can combine them again once I introduce compounded BSDFs.

Thanks for the answer.

ingenious
Posts: 281
Joined: Mon Nov 28, 2011 11:11 pm
Location: London, UK
Contact:

### Re: Sampling Ashikhmin-Shirley BRDF

Another option is to construct two random numbers from the one number by splitting its bits, either 50/50 or however you prefer. One disadvantage of this approach is that you will likely loose any stratification in the random number, which possibly depends on how exactly you split the bits.