Simple question about custom lighting

Hello everybody,

This is not strictly speaking related to OpenGL, but many people here should have experience to answer my question, so I tried my luck anyway.

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

Hi there.

The BRDF is a function of continuous wavelength which is often approx. by 3 channels in computer graphics.

However, I think that if your BRDF model can be expressed by
BRDF-Red() = diffuse-Red() + specular-Red()
then the terms object_material.diffuse.r and object_material.specular.r are included in your BRDF equation. Also, the light terms are just ways to approx. a quantity of energy emited from the light source. There is no such thing as specular light and diffuse light. They just model ernery in an intuitive way. Specular means “more reflected light in a direction”. We could imagine diffuse lighting as the limit of specular lighting when the lobe is VERRRRRY wide.

The hardware mapping of those concepts is based on approx., simplifications and intuition.
I recommend “Advanced Global Illumination” or books on radiometry to get the concepts behind.

have a good day!
JF

Many many thanks for the answer. I really appreciate :slight_smile:

Also thanks for the reading suggestion, I’ll make an inter-library loan, but its gonna take a while before I can get my hands on it. In the meantime, I have two simple comments/questions, if you dont mind answering them.

However, I think that if your BRDF model can be expressed by
BRDF-Red() = diffuse-Red() + specular-Red()

The “if” is puzzling me. Are you saying that some BRDFs may have more/less than 2 components (i.e. diffuse and specular)? Because all the BRDFs models I came across contained 2 components (i.e. diffuse and specular). Or am I missing the point?

then the terms object_material.diffuse.r and object_material.specular.r are included in your BRDF equation. Also, the light terms are just ways to approx. a quantity of energy emited from the light source. There is no such thing as specular light and diffuse light. They just model ernery in an intuitive way. Specular means “more reflected light in a direction”. We could imagine diffuse lighting as the limit of specular lighting when the lobe is VERRRRRY wide.
JF[/QB]
Just to confirm (a simple yes/no will do): essentially, I can definitely ditch the material parameters, and eventually get rid of the light parameters [unless I use it to control intensity]? The BRDF equation then simply become the one you suggested: BRDF-Red() = diffuse-Red() + specular-Red()?

Have a good day as well :slight_smile:

Hi again,

Well, I put the “if” because I don’t wanna sound absolute. It’s true that lots of BRDF models are expressed in the form diffuse part + specular part. However, it’s not a condition. Any ratio of radiance over irradiance can describe a BRDF.
To be physically plausible, the BRDF must conserve energy, be reciprocal and have a bunch of properties. Being of the form diffuse+specular is not one of them.

Also, sometimes, even if the model can be decomposed in diffuse + specular, the specular part can contain multiple terms like in the Lafortune model.

For your second question, it’s trickier than that. The material parameters are included in the BRDF since the BRDF is a property of the material. I meant that the RGB parameters often used in hardware are approximations of the true continuous wavelenght dependancy of reflectance. Besides, some models include other material properties such as the normal distribution of the microfacets.

And the true light parameters are “Radiance emission distribution” + “wavelength”. Again, you can approximate the light radiance distribution as a diffuse emitter (point light) with only a constant intensity value and the wavelength with 3 channels. But light doesn’t emit specular photons and diffuse photons…

Quick tip: beware the cosine in the brdf equations. This is evil…

CiaO!
JF