## Small SchlickBRDF::SampleF question

Discussion related to the implementation of new features & algorithms to the Core Engine.

Moderators: jromang, tomb, zcott, coordinators

### Re: Small SchlickBRDF::SampleF question

jeanphi wrote:Regarding BxDF usage, look at SampleF, when you sample the base, you apply the coating without a check.

Ah right, bad assumptions on my part.

jeanphi wrote:Also why do you prevent coating weight to go below .5? If the coating doesn't interact much, it shouldn't be sampled much.

Initially I let it go down to 0 at near-normal angles, however this actually lead to more noise than the current approach. Once I've fixed the rest I can play around a bit with the constants, perhaps we can go lower than 0.5, however I suspect it depends a lot on the base material.

Do you have any further suggestions regarding using a specular base material? From what I can see if the base is specular I'll have to sample the base, otherwise it'll just be black (try fex with a mirror base material).

However should I just use NumComponents or should I always call base's SampleF, and if specular don't do the random selection? If so, how do I handle Pdf() correctly?
May contain traces of nuts.

Lord Crc

Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

### Re: Small SchlickBRDF::SampleF question

Lord Crc wrote:Initially I let it go down to 0 at near-normal angles, however this actually lead to more noise than the current approach. Once I've fixed the rest I can play around a bit with the constants, perhaps we can go lower than 0.5, however I suspect it depends a lot on the base material.

It shouldn't go down to 0, there's still some reflection at normal incidence so that's going to be the limit, however the weight for diffuse should be adjusted to something like 1/Pi or R.Filter() or some mix of that.

Lord Crc wrote:Do you have any further suggestions regarding using a specular base material? From what I can see if the base is specular I'll have to sample the base, otherwise it'll just be black (try fex with a mirror base material).

My take on it would be to use the current scheme and do the following:
- if coating is sampled and base layer is specular, don't add it (remove the BSDF_SPECULAR flag when getting the base layer scattering)
- if the base is sampled and returns a BSDF_SPECULAR component, don't add the coating reflection
- in the pdf, only give the pdf for the coating

Specular materials are special in that their pdf is a Dirac function so they can't be mixed at all with other scattering events, they have to be isolated.

Jeanphi
jeanphi

Posts: 6577
Joined: Mon Jan 14, 2008 7:21 am

### Re: Small SchlickBRDF::SampleF question

jeanphi wrote:It shouldn't go down to 0, there's still some reflection at normal incidence so that's going to be the limit, however the weight for diffuse should be adjusted to something like 1/Pi or R.Filter() or some mix of that.

Yeah that's the problem, the default weight is 1, which is far more than the reflection at normal incidence. Should we perhaps reduce the default weight to 1/Pi, and then for diffuse set it to R.Filter()/Pi? I'll have to go over how this affects the MultiBSDF and the current materials, but I'd rather not special-case the base weight inside my BSDF.

jeanphi wrote:Specular materials are special in that their pdf is a Dirac function so they can't be mixed at all with other scattering events, they have to be isolated.

Right, and thats what threw me off the track, though mostly the handling of the Pdf().

Anyway, thanks for the feedback I'll see if I can fix this within the new few days.
May contain traces of nuts.

Lord Crc

Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

### Re: Small SchlickBRDF::SampleF question

Lord Crc wrote:Yeah that's the problem, the default weight is 1, which is far more than the reflection at normal incidence. Should we perhaps reduce the default weight to 1/Pi, and then for diffuse set it to R.Filter()/Pi? I'll have to go over how this affects the MultiBSDF and the current materials, but I'd rather not special-case the base weight inside my BSDF.

Maybe we should remove the default Weight implementation so that each BxDF has to implement its own one properly, ditto for BSDF. LambertianBxDF already has a RoverPi value. However the BSDF class has no Weight member, so doing this won't change anything.

Jeanphi
jeanphi

Posts: 6577
Joined: Mon Jan 14, 2008 7:21 am

### Re: Small SchlickBRDF::SampleF question

Thanks for the improvements jeanphi! I'll do some tests and move the BRDF components into the BSDF, and remove SchlickGlossyBDRF.
May contain traces of nuts.

Lord Crc

Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

### Re: Small SchlickBRDF::SampleF question

From what I can see SchlickDistribution doesn't support the multibounce option. So would you prefer SchlickBSDF take a MicrofacetDistribution, or should we do the Schlick microfacet stuff manually inside SchlickBSDF and keep the multibounce option?

edit: or is the multibounce addition general enough to work with an arbitrary MD?
May contain traces of nuts.

Lord Crc

Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

### Re: Small SchlickBRDF::SampleF question

Oh, and sorry for being so daft here, but I don't understand why the pdf and pdfBack is asymmetric in SchlickBRDF::SampleF (ignoring the diffuse component), but not in MicrofacetReflection::SampleF, when using SchlickDistribution.

I'm thinking of the division of "pdf" by "fabsf(wo.z)" and "pdfBack" by "fabsf(wi->z)", versus "fabsf(cosThetaH)" for both in in MicrofacetReflection.

I guess I'm missing something obvious, but I'm struggling to find it.
May contain traces of nuts.

Lord Crc

Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

### Re: Small SchlickBRDF::SampleF question

Hi,

Multibounce can work with any distribution: the algorithm is just that light that is masked is considered to be diffusely scattered (so the (1-G) diffuse scattering added when multibounce is enabled). It should be computed in the BSDF.
The pdf is asymetric because you don't sample the outgoing direction but the microfacet normal and you then compute an outgoing direction from the incoming one, so the pdf of the outgoing direction is dependent on the incoming direction.

Jeanphi
jeanphi

Posts: 6577
Joined: Mon Jan 14, 2008 7:21 am

### Re: Small SchlickBRDF::SampleF question

jeanphi wrote:The pdf is asymetric because you don't sample the outgoing direction but the microfacet normal and you then compute an outgoing direction from the incoming one, so the pdf of the outgoing direction is dependent on the incoming direction.

Right, this makes sense. What I don't understand is why isn't this done in MicrofacetReflection? From what I can see, if you use it with SchlickDistribution then wi is computed the same way as in SchlickBRDF (ignoring cosine sampling), yet pdf == pdfBack. Sorry for being so dense.
May contain traces of nuts.

Lord Crc

Posts: 4455
Joined: Sat Nov 17, 2007 2:10 pm

### Re: Small SchlickBRDF::SampleF question

Lord Crc wrote:Right, this makes sense. What I don't understand is why isn't this done in MicrofacetReflection? From what I can see, if you use it with SchlickDistribution then wi is computed the same way as in SchlickBRDF (ignoring cosine sampling), yet pdf == pdfBack. Sorry for being so dense.

Probably because you just found a bug in MicrofacetReflection

Jeanphi
jeanphi

Posts: 6577
Joined: Mon Jan 14, 2008 7:21 am

PreviousNext