Hello everybody,

I am currently working on a project involving lots of relatively advanced lighting code, and I am more precisely interested in custom reflection algorithms based on BRDF functions. From what I’ve read, most of the BRDFs equations follow this paradigm “BRDF() = diffuse() + specular()” where diffuse and specular are two different functions.

I am rather confused on how to transpose that into some shading code. So could please anyone let me know whether the following statement is correct?

When one wants to actually implement a BRDF in a shader, you have to separate the diffuse and specular component, so that each is multiplied by the proper light and material properties. For instance, if we compute the red value of an object illuminated by a light, the equation is

R = diffuse() * light.diffuse.r * object_material.diffuse.r + specular() * light.specular.r * object_material.specular.r

and similarly for G and B.

Is that correct?

Many thanks

Dietmar