Talk:Specular highlight

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Physics (Rated Start-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject Physics, a collaborative effort to improve the coverage of Physics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
 
WikiProject Computer graphics (Rated Start-class)
WikiProject icon This article is within the scope of WikiProject Computer graphics, a collaborative effort to improve the coverage of computer graphics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 ???  This article has not yet received a rating on the project's importance scale.
 

I would like to suggest the fact that for a pure mirror like surface the reflection occurs when the angle between L and N and V and N are the same. Mentioning the half-vector as being the direction around which light is reflected seems 1/ wrong 2/ misleading. It has been proven that using the half-vector in models such as the Phong or the Cook-Torrance gave more accurate results than by using the reflection vector, but physically speaking, again, for a pure mirror like surface, the reflection direction is the vector that should be used. It seems to me that the first paragraph should not mention the half-vector and should be re-written such as to only mention the reflection vector. Anyone would agree and make the change ? -c

Error: Cook-Torrance model[edit]

According to the reference[1], the formula for the specular term should be changed from

k_\mathrm{spec} = \frac{D F G}{E \cdot N}

to

k_\mathrm{spec} = \frac{D F G}{\pi (E \cdot N) (L \cdot N)}

ClaudeKnaus (talk) 15:15, 21 September 2010 (UTC)

Gaussian model better than the Blinn-Phong shading model?[edit]

It says in the article that Gaussian distribution is a slightly better model than Phong shading, while in fact the model will give

k_\mathrm{spec} = e^{- \left ( \frac{\angle (N, H)}{m} \right )^2} = \exp\left(-\frac{\alpha^2}{m^2}\right) = (e^{-\alpha^2})^n

where \alpha = \angle (N, H) and n = 1/m^2. Suppose that \alpha is very small (which it will be in the specular highlight), we can then use a first order Taylor series to obtain

k_\mathrm{spec} = (e^{-\alpha^2})^n \approx (1 - \alpha^2)^n \approx (1 - \sin^2\alpha)^n = (\cos^2\alpha)^n = (N\cdot H)^{2n}

which is exactly the same as in the Blinn-Phong shading model. --Kri (talk) 23:48, 7 February 2011 (UTC)

I'm not sure where the "better" came from. Your observation is also the basis of my 1993 paper, ref 1, in which I compare the Gaussian approximations to the Phong and Blinn–Phong methods. The approximations are good for small angles and large n, as you note; there is still a difference between the Phong and Blinn–Phong methods under this appproximation though. I also provide other good approximations, much quicker to compute, needing no exponentiation and not very accurate normalization. Dicklyon (talk) 02:24, 8 February 2011 (UTC)
Nice paper, and nice illustrations; I read some of it. I have also thought about using what you call the D vector to approximate dot product between the L and R vectors; I guess there are approximations like this everywhere in computer graphics and similar fields if you are just somewhat bright in geometry and physics. But you haven't patented these methods, have you? --Kri (talk) 00:17, 10 February 2011 (UTC)
Apple did; probably expires Nov. 2012 if it's still alive. Dicklyon (talk) 01:44, 10 February 2011 (UTC)
Okay. Say, just hypothetically, that I would come up with some of the techniques mentioned in your paper, without seeing them there and without having any idea of that they where patented. And say that I would use those techniques in a commercial product. Now, if Apple finds out that I'm using the same techniques that they have a patent on, can they sue me for it? --Kri (talk) 00:02, 13 February 2011 (UTC)
Sure, anyone can sue anyone for anything. And they could claim that you knew about it and infringed it willfully, so are liable for triple damages. Unlikely, though, esp. since it would be hard to show any damages and it would cost them millions to litigate. There's also a good chance they have allowed it to just expire. It's always a crap shoot. It's best not to worry about infringing patents, I think. Dicklyon (talk) 00:09, 13 February 2011 (UTC)
Yes that's true; it's probably better to live your life without worrying for a lot of stuff! --Kri (talk) 18:16, 13 February 2011 (UTC)
There are sources about Gaussian microfacet distribution here. I think this distribution is not quite the same thing as the specular shape distribution in the Blinn–Phong method, but certainly very closely related. Maybe you can say something more useful than the "better". Dicklyon (talk) 02:25, 10 February 2011 (UTC)
Don't you realise? They all are the same, spot will be brighter and more shiny if surface is better polished (for example, if light source is point, then if ball surface is very good polished then bright spot will be brightest and smallest at biggest polishing amount [n] and rest of ball surface will be almost black, the darker from bright spot on ball depending on angle between ball triangle normal and light vector). Polishing level describing n factor. There simply can't be something better than Phong model. Only if we talking about HDR, then maybe something better possible to think up than Phong-Blinn method. — Preceding unsigned comment added by Versatranitsonlywaytofly (talkcontribs) 13:37, 21 August 2011 (UTC)
There is only one problem with Phong-Blinn equation (\hat{N}\cdot \hat{H})^n. But first need to answer to question, what stronger reflects sun light: white paper or mirror? If take white paper size of eye retina (about 0.5 cm x 0.5 cm) and mirror with eye retina size and mirror from whatever distance will reflect all sun energy for eye in 0.5*0.5=0.25 cm^2. Energy amount will be equal from any distance. And pease of paper from distance will look very small and all energy [going parallel from sun) split into all directions. Now consider two ball, one is metal or mirror ball and another is ball colored with white color, which is like paper without any specular highlights (in nature it's almost don't exist paper without specularity of light). So rising with n any number between between 0 and 1 will decrease number. We need to made somehow, that paper reflects energy in single point (or pixel) about 1 and mirror about 5 or 10, let choose number 7 for mirror reflected energy per pixel. So then depending how close material is to mirror or to paper in sense of specularity highlight need to choose coefficient k between 1 and 7 and then formula becoming (k(\hat{N}\cdot \hat{H}))^n. In perfect sense, paper is material which reflects light equally (to viewer) do not depending on angle between surface normal and light vector. And perfect mirror is mirror, which reflecting only light if dot product of surface normal and light vector is 1 and if there is only 5 degree angle (between N and L vectors) then light reflection is still 0 (to viewer). For perfect paper material formula can be like this 0.999+\frac{(\hat{N}\cdot \hat{H})^n}{c}-\frac{0.999}{c}, where 1<c<1000. If c is small (c=1) then it is simulated perfect mirror and if c=1000 then it is simulated perfect paper. But formula is not good enough. Too much coefficients like c and n. So formula must look more like this 0.999+\frac{2(\hat{N}\cdot \hat{H})}{c}-\frac{0.999}{c}, where 1<c<1000. Notice, that vectors N and H are normalized and dot product of them can't be more than 1, because angle \beta between them goes in formula \cos\beta=\hat{N}\cdot \hat{H}. Then just need multiply all formula by light intensity I(0.999+\frac{2(\hat{N}\cdot \hat{H})}{c}-\frac{0.999}{c}), where 0<I<1. From specular lighting to viewer can come light with strength maximum 2, but if result is bigger than 1 then it must be 1. So by changing only c (from 1 to 1000) you will get effect from perfect paper to perfect mirror. As simple as that, without any errors.
I forgot that for perfect mirror need big n, so formula can be like this 0.999+\frac{2(\hat{N}\cdot \hat{H})^n}{c}-\frac{0.999}{c} or like this n(\hat{N}\cdot \hat{H})^n and in both cases if result more than 1, then it still 1. For perfect mirror n=\infty, but enough and 1<n<10. About light intensity for this formula n(\hat{N}\cdot \hat{H})^n you can forget. Final formula can be I(0.999+\frac{2(\hat{N}\cdot \hat{H})^{10-c/100}}{c}-\frac{0.999}{c}), where 1<c<1000.

Formula k(\hat{N}\cdot \hat{H})^n correct only for point lights[edit]

Specular highlight formula c=I k(\hat{N}\cdot \hat{H})^n (if c>1, then c=1; I is light intensity, 0<I<1; k is coefficient of how much reflected light bulb wire on metal surface is brighter than white paper illuminated [perpendicular to light direction] by the same light bulb at same distance, 1<k<5) is correct for point lights and all kind of lamps if lamps are not close to object with specular highlight. And I think in most cases programmers in game and in all places do not making this condition: if c>1, then c=1 (they making it before multiplying by light intensity I). Because this is very important for almost reflected (like reflection on metal) even weak light to be brighter than white paper illuminated by stronger light (because specular reflection is reflection of light source like wire of light bulb). But here is bad news. From big distance all rays coming to surface of metal almost parallel and if metal is flat, then all flat surface will be bright and in reality would be on flat surface only small bright spot (in reality would be only Sun spot very bright instead all bright flat surface). So specular lighting can't be implemented correctly for near and far light sources. And specular highlights are in most cases only good for not flat objects (then they almost correct). So even ray-tracing and specular cubemaps and any over best techniques are incapable to correctly simulate metal specular highlights. For near objects specular highlight formula c=I\cdot k(\hat{N}\cdot \hat{H})^n (if c>1, then c=1) is incorrect, because must be reflected shape of light like light bulb bright shape or very bright wire inside bulb. But at least if near light source is not parallel light, then on flat surface will be bright spot and brightest in center, but in reality there should be bright shape (like blured light bulb wire [on metal]). Final formula is this:

I_{reflected} = I_{directed}((\hat{N} \cdot \hat{L}) + k (\hat{N} \cdot \hat{H})^n) \quad (if \;\; I_{reflected}>1, \;\; then \;\; I_{reflected}=1).
This d=\hat{N} \cdot \hat{L} (0<d<1) is diffuse lighting and it needed, because at different angle [between light source and surface] goes not equal amount of light energy per surface area. If angle between light vector and surface normal is 0 degrees, then lighting is brightest. At bigger angles bigger surface areas illuminated by same amount of light energy.
In games Crysis and Crysis 2 there used light attenuation (light weakening depending on distance between light and object). In "Doom 3" and in "Fear 3" videogames light attenuation is not used for flashlight (фонарик). Of course light attenuation also needed for realism (but not sun light or moonlight).

do not need remove[edit]

Phong distribution[edit]

In the Phong reflection model, the intensity of the specular highlight is calculated as:

k_\mathrm{spec} =    \|R\| \|V\| \cos^n\beta = (\hat{R} \cdot \hat{V})^n

Where R is the mirror reflection of the light vector off the surface, and V is the viewpoint vector (viewer vector).

In the Blinn–Phong shading model, the intensity of a specular highlight is calculated as:

k_\mathrm{spec} = \|N\| \|H\| \cos^n\beta =(\hat{N} \cdot ((\hat{L}+\hat{V})/2))^n = (\hat{N} \cdot \hat{H})^n

Where N is the smooth surface normal and H is the half-angle direction (the direction vector midway between L, the vector to the light, and V, the viewpoint vector). Here angle \beta describes the angle between R and V vectors. The Blinn–Phong shading model is equal to Phong reflection model model, but it smarter to use, because do not need to know reflection of light vector R and is faster because don't need to compute \cos\beta.

When H coincides with N, the direction of the reflection coincides with the viewing direction V and a specular hightlight is observed. So the original formula

(\hat{R} \cdot \hat{V})^n
is expanded to
(\hat{N} \cdot ((\hat{L} + \hat{V}) / 2))^n
or
(N \cdot H)^n

The complete Blinn-Phong model formula looks like:

I_{reflected} = I_{directed}((\hat{N} \cdot \hat{L}) + k_{specular} (\hat{N} \cdot \hat{H})^n),
where I is intensity of light, vector N is normal of surface and vector L is light source vector. Angle between H and V vectors is equal to angle between H and L vectors.

The exponent n characterizes the shiny properties of the surface and ranges from 1 to infinity. Objects that are matte require a small exponent, since they produce a large, dim, specular highlight with a gentle falloff. Shiny surfaces should have a sharp highlight that is modeled by a very large exponent, making the intensity falloff very steep. Together with the diffuse reflection model, the Phong illumination model can be expressed in the following way:

I_{reflected} = I_{directed}((\hat{N} \cdot \hat{L}) + k_{specular} \cos^n(\beta)).
\cos^n(\beta) can be replaced by using the mechanism of the dot or scalar product of the unit vectors R and V:
I_{reflected} = I_{directed}((N \cdot L) + k_{specular} (R \cdot V)^n).
This is the generally accepted phong reflection equation. As the angle between V and R decreases, the specularity rises.

Because it is expensive to calculate the reflection vector R (mirror of light incidence around the surface normal), James F. Blinn [Blinn] introduced a way to do this using an imaginary vector H, which is defined as halfway between L and V. H is therefore:

\hat{H} = (\hat{L} + \hat{V})/2.
For calculation diffuse of light (how light reflects depending on angle between surface normal N and light vector L) need to use this formula:
I_{reflected} = C_{diffuse}\cdot I_{directed}\|N\| \|L\| \cos\theta=C_{diffuse}\cdot I_{directed} \cos\theta=C_{diffuse}\cdot I_{directed} (\hat{N}\cdot \hat{L}),
where ||N||=1 and ||L||=1, because they are normalized.

The number n is called the Phong exponent, and is a user-chosen value that controls the apparent smoothness of the surface. These equations imply that the distribution of microfacet normals is an approximately Gaussian distribution (for large n), or approximately Pearson type II distribution, of the corresponding angle.[2] While this is a useful heuristic and produces believable results, it is not a physically based model.

  1. ^ R. Cook and K. Torrance. "A reflectance model for computer graphics". Computer Graphics (SIGGRAPH '81 Proceedings), Vol. 15, No. 3, July 1981, pp. 301–316.
  2. ^ Richard Lyon, "Phong Shading Reformulation for Hardware Renderer Simplification", Apple Technical Report #43, Apple Computer, Inc. 1993 PDF