Source Here Goes ...
Material Properties
Jokes aside, there are basically shiny materials, like gold, metal, silver, and dim materials, like wood, fabrics and so on. In old good OpenGL, you could set material properties with functions like glMaterialfv(). There were several properties to set, but we will only play with two, that are really basic and included in every lighting model I've seen so far - Specular Power and Specular Intensity.Specular Power is the number, that we exponentiate specular factor to. It's usually ranging from 1 to 128 at max (I think these were the limits in old OpenGL, but in shaders you can work with arbitrary numbers of course and go beyond these limits). Why would we do this? Without doing this, the specular highlight would be too big, too unrealistic and too wide. Just think about it.
Specular factor is the number ranging from 0 to 1 and it's obtained by cosine of the angle. The cosine of 0 degrees is 1 and at 45 degrees it's still 0.707. This means, that the specular highlight would be too powerful looking from even pretty big angles like 45 degrees. By exponentiating this number to a power like 32, we will get significantly lower number. For the record, 0.70732 is already really small number - 0.000015185, which means that the highlight will be practically not visible from this angle. However, if we aren't too askew from the reflected vector and the cosine of angle is a number close to 1 (let's say 0.97), the resulting value would be 0.9732 = 0.377, which is a reasonable number and that will make the highlight visible! So by playing with power, you can change the size and intensity of specular highlight. Try it and play around with this number. See for yourself, that if you set the power to 1, the highlight is no good, it's just a mess . I also allow you to go to negative values to see what happens if you raise specular factor to negative powers. It's just fun .
Specular Intensity is now a really, really simple thing in comparison to specular power. After you raised specular factor to specular power, specular intensity just linearly controls the intensity of calculated highlight. So if we calculated highlight was for example 0.377 and our specular intensity is 0.5, the very final value will be 0.377 * 0.5 = 0.1885. There is really nothing difficult here.
I hope, that now it is clear to you, what Specular Factor, Specular Power and Specular Intensity are. With the knowledge you should have now, we can move to actual code in the shaders.
......................................................................
exponent
[ɪkˈspoʊnənt]
[n.] a small number or letter written above and to the right of anothernumber to show how many times you should multiply that number byitself
....
No comments:
Post a Comment