There are quite a few materials that are nearly diffuse reflectors such as rough
wood, newspaper, concrete, and mouse pad. However, a considerable number of
surfaces are shiny or glossy. We call these specular materials. Examples include
polish metals, plastics, polish wood, glass, glazed ceramics, and enamel paint.
These materials look different when you view them different angles, so we need
to take into account the direction from the surface to the eye. One standard way
of simulating specular materials is called the Blinn-Phong Reflection Model
named after its inventors, Jim Blinn and Bui Tuong Phong. The full model has a
number of terms in it for self-shadowing and for a shininess factor called the
Fresnel coefficent. But the simplest and most common form is this. Specular
equals the maximum of N dot H or 0, whichever is larger, raised to a power. N is
the surface normal, same as with diffuse material. H is called the half angle
vector. Say, you're given a surface, a light source direction, and a viewer
direction. How would you point a mirror so that the light reflected directly
toward the viewer? The answer is the half angle vector, which is the vector
halfway between these two directions, so that these two angles are equal. If the
surface normal and the half angle are identical, then the surface is perfectly
aligned to reflect light to the eye. So, N dot H would be 1, and all light is
reflective. As the normal and the half angle diversion direction, N dot H
becomes smaller. Once the angle between these vectors is 90 degrees, the
contribution goes to 0. The maximum function here limits the inputs so that this
value is never negative. We want to avoid it being negative because we're about
to raise it to a power. The S factor here is the shininess or specular power,
and has a range from 1 to infinity, though anything above 100 is not too much
different. When you raise a fraction to a power, the result is smaller, and
smaller still the higher the power. For example, 0.5 squared is 0.25, cubed, is
0.125, and so on. By raising this term to a higher power, the object appears
shinier. We can see this in the graph of N dot H versus the specular intensity.
As the cosine power rises, the slope becomes tighter and tighter and gets
sharper. What the half angle represents is the distribution of microfacets on a
surface. A microfacet is a way of thinking how a material reflects light. For
example, a fairly smooth surface may look like this. Light coming in from one
direction will bounce off the surface mostly in the reflection direction. A
rougher surface will a lower shininess has a distribution of facets more like
this and the light will still go in the reflection direction, but with a much
wider dispersal. At this point, it's best for you to try out the specular power
function and see how it responds. An example program that follows, you control
the ambient, diffuse, and specular contributions. Try playing with the shininess
and other controls to see their effects.
拡散反射に近い作用をする素材は樹木、新聞紙、
コンクリート、マウスパッドなど数多くありますが
表面が輝いて光沢がある物がほとんどです
それを鏡面反射マテリアルと呼びます
つやのある金属、プラスチック、磨かれた木、
ガラス、陶磁器、エナメルペイントなどがそうです
これらは角度ごとに違った見え方をするので
表面からの視点の方向を考慮しなければいけません
この処理を実行するモデルに
ブリン-フォン反射モデルというものがあります
考案者のジム·ブリンと
ブイ·トゥオン·フォンの名前がつけられています
このモデルを実行すれば自動で影をつけたり
フレネル係数を計算して光沢を出すことが可能ですが
最も簡単なのはこの計算式です
最大値のNドットHまたはゼロを用いて
鏡面反射率を求めます
拡散反射の式と同様にNは面法線ベクトルを表し
Hはハーフベクトルと呼ばれます
ここに平面を用意しライトの位置と
視点の位置を設定します
光を反射させて目に届くようにするには
どのように鏡を設置すればよいでしょう
答えはハーフベクトルの位置です
2つのベクトルの中間なので角度は均等に分かれます
法線ベクトルとハーフベクトルが等しければ
表面は光を一直線に反射して目に届けます
この場合NドットHの値は1ですべての光を反射します
法線ベクトルとハーフベクトルがずれていたら
NドットHの値は小さくなります
2つのベクトルの角が90度なら値は0になります
最大値を使うので負の値になることはありません
指数を用いるので負の値は避けたいのです
このSは1~無限大の数値で
輝度や反射率を表しますが
100を超えると変化はほとんど表れません
少数で累乗すると指数と反比例して
値は小さくなっていきます
例えば0.5を2乗すると0.25で
3乗なら値は0.125になります
出てくる値が大きくなるほどオブジェクトは輝くのです
NドットHと鏡面反射率の関係をグラフにしました
余弦の値が大きくなるほど曲線はより狭くなります
ハーフベクトルが示すのは小面ごとの光の配分です
マテリアルがどのように光を反射するかを考えられます
例えば滑らかな表面はこのようになります
一定の方向からきた光は
それぞれの反射方向にはね返ります
表面が粗く光沢が少ないマテリアルでは
このような配分になります
光は反射方向に広く散っていきます
実際に鏡面反射マテリアルの効果を見てください
次のデモでは環境光、拡散反射、
鏡面反射の作用を見ることができます
輝度や他のパラメータを操作してみましょう
有許多東西有漫射材質的反射特性,像是木材、報紙、水泥跟滑鼠墊
但是有很多表面是光滑閃亮的
我們稱為鏡面反射材質
例子有拋光金屬、塑膠、拋光木材、玻璃、上釉瓷器與琺瑯漆
這些材質從不同角度觀察看起來不同
所以我們需要將表面到眼睛的方向納入考量
鏡面反射材質標準模擬方法之一是 Blinn-Phong 反射模型
以其發明者 Jim Blinn 與 Bui Tuong Phong 命名
Phong 模型有許多項,包含自我遮擋(Self-Shadowing)和亮度的菲涅耳係數(Fresnel Coefficent)
但是最簡單常見的是這樣
鏡面反射等於 N 內積 H 與零取最大值再取 S 次方
N 是表面法向量,跟漫射一樣
H 是半角度向量(Half Angle Vector)
給定一個表面上面有往光源的向量與往眼睛的向量
你會怎麼指向鏡子讓光直接反射到觀測者?
答案是半角度向量
即這兩個方向中間的向量,使得兩個夾角角度相同
如果表面法向量跟半角度向量相同
則表面能完美地將光反射到眼睛,N 內積 H 等於 1,所有的光都被反射
當法向量跟半角度向量方向有落差,N 內積 H 會變小
當兩者夾角到 90 度則強度會歸零
跟零取最大值保證這個值不會變成負的
我們避開負數因為還要次方
S 參數稱之為閃亮程度(Shininess)或是鏡面反射強度(Specular Power),介於 1 到無限
雖然超過 100 後差別不大
將分數取指數會變小,指數越大結果越小
像是 0.5 平方是 0.25、立方是 0.125,以此類推
增加指數次方會讓物件看起來更閃亮
你可以參考這張 N 內積 H 跟鏡面反射強度的圖表
當餘弦的次方數越高,曲線變得越細越陡
半角度向量代表的是平面上的微平面(Microfacets)的分布
微平面是一種思考材質如何反射光的想法
舉例來說,光滑的表面可能看起來像這樣
從一個方向入射的光大致會往反射方向反彈
較粗糙不閃亮的表面其微平面分布可能如此
光還是會往反射方向去,但是擴散地開得多
最好的方法就是讓你操作鏡面反射強度函數試試看反應
下一個展示程式裡你可以控制環境光、漫射與鏡面反射
試試閃亮程度與其他參數的效果