<p>So I found a solution on a shader toy.</p>

<p>I choose randomly from sampling diffuse or sampling specular with distribution 50:50. But I calculate PDF of both and average then. If you want to use a different proportion between sample function you just have to make sure that PDFs are combined with the same proportion as choose. </p>

CC BY-SA 4.0
2020-05-09T23:49:22.133Z
Why would you have both the probabilities at 50 though. It's gonna waste a lot of samples if, let's say we have a material that is 90% specular and 10% diffuse. You'd end up sampling the diffuse and specular 50% of the times when clearly you should have sampled the specular more.
gallickgunner
CC BY-SA 4.0
2020-05-10T08:41:09.977Z
Yes, it would be better, but my specular is different for each RGB value so it wouldn't be consistent. I would have to average the reflectivity and then decide what sampling to use. That's definitely an option, but I am not so far yet with optimization. But a good point. Thank you
Vít Gardoň
CC BY-SA 4.0
2020-05-09T22:44:42.270Z
2020-05-09T22:44:42.270Z
Vít Gardoň
<p>When I am sampling diffuse BRDF I am using cosine-weighted distribution and when I want to sample specular BRDF I use sampling by GGX distribution. I can decide how much light is reflected and how much is diffused by using Fresnel. That gives me an evaluation formula like this:</p>

<p>Eval = BRDF_specular * F + BRDF_diffuse * (1 - F)</p>

<p>the same principle I can use on PDF. But the problem comes up when I try to use this on sampling. It is obvious that I cannot use this interpolation for the sampled vector. But what I can do is to have some probability that I will sample specular direction and probability for sampling diffuse direction. As sample count goes up it will perform as if it was interpolation between these types of sampling. I can use this for dielectric materials because their Fresnel value is the same for RGB. But because I am using separate values for RGB for Fresnel on metallic material I can have different probabilities (for example, R = 0.8, G = 0.3, B = 0.0). This gives a nice look to metals as you can see in this <a href="https://shanesimmsart.wordpress.com/2018/03/29/fresnel-reflection/" rel="nofollow noreferrer">post</a>. What probability I should choose then? The biggest?? Average? Or is this some different approach to this problem, because I cannot find anywhere how to combine these BRDFs? </p>

CC BY-SA 4.0
2020-05-02T14:10:11.473Z
float luma(const vec3& color)
{
 return dot(color, vec3(0.2126f, 0.7152f, 0.0722f));
}
Max Tarpini
CC BY-SA 4.0
2020-05-04T04:06:41.827Z
For metals, or basically mix of diffuse and specular reflection I suggest you the Ashikhmin BRDF. It properly accounts for the diffuse part , Fresnel effect. Look at  https://www.google.com/url?sa=t&source=web&rct=j&url=http://www.cs.utah.edu/~michael/brdfs/jgtbrdf.pdf&ved=2ahUKEwjl2uDvqZnpAhVmURUIHcylCLUQFjADegQIBBAB&usg=AOvVaw2ywV--US_6Cpf4kWotzy79&cshid=1588565037935
ali
CC BY-SA 4.0
2020-05-04T04:10:06.977Z
Are you asking of the probability of choosing either of the two BRDFs? If yes, then it can be any number(can be 0.5) as later you divide brdf by this probability to account for rays that you didn't trace.
ali
CC BY-SA 4.0
2020-05-04T09:00:01.460Z
Thank you. I already came up with solution. I decided to choose them randomly 50:50. Then I average the PDF. I just forgot about this question. I will post a answer so that the question will not be left without one. Thanks you once again.
Vít Gardoň
<pathtracing><brdf><fresnel>
BRDF sampling and evaluation of diffuse vs specular component
Vít Gardoň
# BRDF sampling and evaluation of diffuse vs specular component

(Asked by: username_0 on 2020-04-27)

When I am sampling diffuse BRDF I am using cosine-weighted distribution and when I want to sample specular BRDF I use sampling by GGX distribution. I can decide how much light is reflected and how much is diffused by using Fresnel. That gives me an evaluation formula like this:

Eval = BRDF\_specular \* F + BRDF\_diffuse \* (1 - F)

the same principle I can use on PDF. But the problem comes up when I try to use this on sampling. It is obvious that I cannot use this interpolation for the sampled vector. But what I can do is to have some probability that I will sample specular direction and probability for sampling diffuse direction. As sample count goes up it will perform as if it was interpolation between these types of sampling. I can use this for dielectric materials because their Fresnel value is the same for RGB. But because I am using separate values for RGB for Fresnel on metallic material I can have different probabilities (for example, R = 0.8, G = 0.3, B = 0.0). This gives a nice look to metals as you can see in this [post](https://shanesimmsart.wordpress.com/2018/03/29/fresnel-reflection/). What probability I should choose then? The biggest?? Average? Or is this some different approach to this problem, because I cannot find anywhere how to combine these BRDFs?

**Tags:** pathtracing, brdf, fresnel

> **Comments:**
> **username_1**: float luma(const vec3& color) {  return dot(color, vec3(0.2126f, 0.7152f, 0.0722f)); }  
> **username_2**: For metals, or basically mix of diffuse and specular reflection I suggest you the Ashikhmin BRDF. It properly accounts for the diffuse part , Fresnel effect. Look at  https://www.google.com/url?sa=t&source=web&rct=j&url=http://www.cs.utah.edu/~michael/brdfs/jgtbrdf.pdf&ved=2ahUKEwjl2uDvqZnpAhVmURUIHcylCLUQFjADegQIBBAB&usg=AOvVaw2ywV--US_6Cpf4kWotzy79&cshid=1588565037935  
> **username_2**: Are you asking of the probability of choosing either of the two BRDFs? If yes, then it can be any number(can be 0.5) as later you divide brdf by this probability to account for rays that you didn't trace.  
> **username_0**: Thank you. I already came up with solution. I decided to choose them randomly 50:50. Then I average the PDF. I just forgot about this question. I will post a answer so that the question will not be left without one. Thanks you once again.  

---

## 1 answers

### Answer by username_0 on 2020-05-09. Score: 1

So I found a solution on a shader toy.

I choose randomly from sampling diffuse or sampling specular with distribution 50:50. But I calculate PDF of both and average then. If you want to use a different proportion between sample function you just have to make sure that PDFs are combined with the same proportion as choose.

> **Comments:**
> **username_3**: Why would you have both the probabilities at 50 though. It's gonna waste a lot of samples if, let's say we have a material that is 90% specular and 10% diffuse. You'd end up sampling the diffuse and specular 50% of the times when clearly you should have sampled the specular more.  
> **username_0**: Yes, it would be better, but my specular is different for each RGB value so it wouldn't be consistent. I would have to average the reflectivity and then decide what sampling to use. That's definitely an option, but I am not so far yet with optimization. But a good point. Thank you  

---

