I am currently making a Ray-tracer as a personal project. My lighting equation looks like this
Pixel_color[i] = 255 * (Ma*Ig*Ca + Md*I*Cd * diffuse + Ms*I*Cs * glossy) // M = material color (ambient, diffuse and specular) // I = intensity of light (Ig is the global ambient intensity) // C = color of the light (ambient , diffuse and specular)
glossy contains all the necessary dot products and the normalization factors ( PI for diffuse and n+8/8*PI for Blinn Phong). Also everything is in range 0-1. I've read from some books and it says to make sure that
"Ks + Kd" <= 1 And now I am confused.
1) What exactly is Ks and Kd? Is it just my surface diffuse color and specular color divided by 255 to make it in the range 0-1? Or is it the reflectance ratio that I have to multiply with my color? If it's something else then what should I set them to? For example if I have a color
rgb(66, 170, 244) which is somewhat light blue. What should the Ks and Kd be for the above color?
2) These books don't include the ambient component when talking about this conservation so should it be Ka+Kd+Ks <= 1? Again if that's the case what will Ka be?
3) If I consider Ks = Ms and Kd = Md. It doesn't fit out. for example if I want a surface with the above color
rgb(66, 170, 244) to be shiny and the specular highlight should be white. Then my Ms would be (255-66, 255-170, 255-244) which won't be white. Another way I could do is subtract the maximum from every component Ms(255-244, 255-244, 255-244). But this means the specular color would be very low. What if I wanted a very shiny surface?
So according to the book Computer Graphics Principles and Practice, Chapter 6 "Fixed Function and Hierarchial Modeling in WPF"
Cd Innate color of “diffuse layer” (Cd,R,Cd,G,Cd,B) Cs Innate color of “specular layer” (Cs,R,Cs,G,Cs,B) ka Efficiency of diffuse layer at reflecting ambient light (ka,R, ka,G, ka,B) kd Efficiency of diffuse layer at reflecting light (kd,R, kd,G, kd,B) ks Efficiency of specular layer at reflecting light (ks,R, ks,G, ks,B)
After that it writes,
Note that for solid-color materials, the distinction between the two terms Cd and kd is unnecessary, as far as the math is concerned; you can think of them as a single term. That is, you can fix kd,R at 1. 0 and use Cd,R to achieve any effect, and conversely you could fix Cd,R and specify only kd,R. However, the distinction between the two terms is meaningful when the innate color Cd is being provided via texture mapping; in that case, there is a need for a kd,R factor affecting the reflection of the varying color Cd specified by the texture.
After that in Chapter 14.9 it removes Kd/Ks and Cd/Cs and replaces both with K_L and K_G
These k parameters are no longer potentially ambiguous RGB triples (each 0 . . . 1), but constants representing the net probability over all directions of that term contributing to scattering.
Which led me to think they are just a single constant like "0.5" However in the next example they are telling the same thing to ensure that K_L + K_G <= 1 across all channel which implies that k_L and k_G are infact RGB triples.