close

Bump Mapping

bumpmap2.gif  Bump mapping is very much like Texture Mapping. However, where Texture Mapping added colour to a polygon, Bump Mapping adds, what appears to be surface roughness. This can have a dramatic effect on the look of a polygonal object. Bump Mapping can add minute detail to an object which would otherwise require a large number of polygons. Note that the polygon is still physically flat, but appears to a be bumpy. 

Take a look at the cube on the left. If you look closely, you can see lots of detail on it. It looks as if it must have been made from millions of tiny polygons, but is made from just 6. You might ask how this differs from Texture Mapping. The difference is that a Bump Map is a Texture Map that responds to the direction of the light.
 
凹凸貼圖是很像紋理貼圖。但是,如果紋理映射多邊形的顏色,凹凸映射補充說,這似乎是表面粗糙度。這可能有一個戲劇性的效果就看一個多邊形對象。凹凸貼圖微小的細節可以添加到一個對象,否則將需要大量的多邊形。請注意,仍然是身體上的多邊形平坦,但似乎是一個充滿坎坷
看看這個立方體的左邊。如果你仔細觀察,可以看到大量的細節就可以了。這看起來好像它必須已經從數百萬微小的多邊形,但是是由只有6可能會問這不同於紋理映射。所不同的是,凹凸貼圖紋理貼圖響應該方向的光。

<<凹凸映射和紋理映射非常相似。然而,紋理映射是把顏色加到多邊形上,而凹凸映射是把粗糙信息加到多邊形上。這在多邊形的視覺上會產生很吸引人的效果。我們只需要添加一點信息到本來需要使用大量多邊形的物體上。需要注意的是這個物體是平的,但是它看起來卻是粗糙不平的。讓我們來看看上邊的那個立方體。如果你很近地觀察它時,你會發現它上面的很多細節。它看起來好像是由成千上萬個多邊形構成的,其實它只是由6個矩形構成。你或許會問:“這和紋理映射有什麼不同?”它們的不同之處在於——凹凸映射是一種負責光方向的紋理映射。>>


bumpmap3.gif    Take a close look at a rough surface. From a distance, the only way you know it is rough is by the fact that it's brightness changes up and down across it's surface. Your brain can pick out these bright and dark patterns and interpret them as bumps on the surface.
The little picture on the left illustrates this. You see what looks like an embossed surface. Some rectangles and letters have been pressed into it, but if you touch it, it just feels like the glass of your monitor.Nothing more has been done than change the brightness if the image in just the right places, your brain does the rest. This technique can be used to add real feeling to a polygon. 
好好看看粗糙的表面。從遠處看,只有這樣,你知道這是粗糙的事實,它的亮度變化,上下兩端的表面你的大腦能夠挑選出這些明亮和黑暗的模式和解釋它們表面上顛簸
圖片左邊說明了這一點你看什麼看起來浮雕面矩形和信件,有的被壓到它,但如果你觸摸它,它只是感覺就像是一杯已經做了monitor.Nothing不是改變圖像的亮度,如果僅在適當的地方,你的大腦沒有休息。這種技術可以用來添加多邊形的真實心情
<<從遠處看,你判斷這個物體是粗糙的的唯一證據是在它表面上下的亮度有改變。你的大腦能夠獲得這些亮暗不一的圖案信息,然後判斷出它們是表面中有凹凸的部位。上邊的一幅圖就說明了這一點。你可以發現它是一個浮雕式的表面。一些矩型和字母被印入表面,但是它們摸上去就像是一個隱藏的監控器的玻璃。如果這個圖像是在適當的位置上,那麼它除了改變亮度,不需要再做任何其他的工作。        
那麼你也許會問:我是怎麼知道哪些點要亮,哪些點要暗呢?這不難。絕大多數人生活在這樣一種環境下——這個環境的大多數光源來自上方(譯者注:比如白天主要的光來自太陽,夜晚主要的光來自天花板上的日光燈)。所以向上傾的地方就會更亮,而向下傾的地方就會更暗。所以這種現象使你的眼睛看到一個物體上亮暗區域時,可以判斷出它的凹凸情況。相對亮的塊被判斷是面向上的,相對暗的塊被判斷是面向下的。所以我只需要給物體上的線條簡單得上色。
 
如果你想要更多的證據,這裡還有一幅幾乎相同的圖,不同於前的是它旋轉了180度。所以它是前一幅圖倒轉的圖像。那些先前看起來是凹進去的區域,現在看起來是凸出來的了。>>


bumpmap4.gif    So how did I know which bits to make bright, and which to make dark? It's easy. Most people spend their lives in an environment where the main light source is above them (except us spods of course, whose main light source comes from the monitor). So surfaces angled upwards tend to be brightly lit, and downward inclined surfaces tend to be darker. Therefore it follows that if your eyes see light and dark areas on an object, they will interpret them as bumps; lighter bits it takes as up-facing, and darker bits it takes as down-facing. So, I just coloured the lines on the image accordingly. 
As if you needed any more evidence, here is exactly the same image, but rotated 180 degrees. It appears to be the inverse of the previous one. Those areas that appeared to be pushed in, now seem to have popped out, and vice-versa. 
Now, your brain is not entirely stupid. If you had visual evidence that the inverted image was lit from underneath, your brain would again interpret it as the first image. Infact, if you stare, and think hard enough about a light source comming from the bottom right, you can make that happen.
所以,我怎麼知道哪些位,使明亮,黑暗?這很容易。大多數人一生都在一個環境中,主光源他們上面(除了我們 spods當然,其主要光源來自監視器)。因此,表面傾斜向上往往是燈火通明,和向下的傾斜面往往是黑暗。因此,因此,如果你的眼睛看到光明與黑暗區域的一個對象他們將解釋他們作為顛簸;較輕的位的面向它以面向所以,我只是彩色圖像上相應
正如如果你需要更多的證據,這裡是完全一樣的形象,而且旋轉180度。這似乎前一個。這些地區,似乎是,現在似乎已經冒出來反之亦然
現在,你的大腦並不完全是愚蠢的如果你有視覺的證據表明,倒像從下面點燃,你的大腦會再次解釋它作為第一個
形象。事實上,如果凝視,並認為夠硬光源來自於右下角可以做到這一點

<<這時候你的大腦並沒有被完全欺騙,你腦中存留的視覺印象使你仍有能力判斷出這是前一幅圖,只是它的光源變了,是從下往上照的,你的大腦可能強迫性地判斷出它是第一幅圖。
事實上,你只要始終盯著它,並且努力地想像著光是從右下方向照射的,你就會理解它是凹的(譯者注:因為日常生活的習慣,你會很容易把這些圖形判斷成凸出的圖形,但是因為有了上一幅對照圖的印象,你可能才會特別注意到這些圖塊其實還是凹入的,只是判斷方法不符合我們日常生活習慣,因為這時大多數光不是從上方照射,而是從下往上照射)。>>

(1)凹凸映射背後的原理
 
讓我們來看看一個粗糙的表面。
[attach]2364[/attach]
 

從遠處看,你判斷這個物體是粗糙的的唯一證據是在它表面上下的亮度有改變。你的大腦能夠獲得這些亮暗不一的圖案信息,然後判斷出它們是表面中有凹凸的部位。上邊的一幅圖就說明了這一點。你可以發現它是一個浮雕式的表面。一些矩型和字母被印入表面,但是它們摸上去就像是一個隱藏的監控器的玻璃。如果這個圖像是在適當的位置上,那麼它除了改變亮度,不需要再做任何其他的工作。
      
那麼你也許會問:我是怎麼知道哪些點要亮,哪些點要暗呢?這不難。絕大多數人生活在這樣一種環境下——這個環境的大多數光源來自上方(譯者注:比如白天主要的光來自太陽,夜晚主要的光來自天花板上的日光燈)。所以向上傾的地方就會更亮,而向下傾的地方就會更暗。所以這種現象使你的眼睛看到一個物體上亮暗區域時,可以判斷出它的凹凸情況。相對亮的塊被判斷是面向上的,相對暗的塊被判斷是面向下的。所以我只需要給物體上的線條簡單得上色。
 
如果你想要更多的證據,這裡還有一幅幾乎相同的圖,不同於前的是它旋轉了180度。所以它是前一幅圖倒轉的圖像。那些先前看起來是凹進去的區域,現在看起來是凸出來的了。
 
[attach]2365[/attach]
 
這時候你的大腦並沒有被完全欺騙,你腦中存留的視覺印象使你仍有能力判斷出這是前一幅圖,只是它的光源變了,是從下往上照的,你的大腦可能強迫性地判斷出它是第一幅圖。事實上,你只要始終盯著它,並且努力地想像著光是從右下方向照射的,你就會理解它是凹的(譯者注:因為日常生活的習慣,你會很容易把這些圖形判斷成凸出的圖形,但是因為有了上一幅對照圖的印象,你可能才會特別注意到這些圖塊其實還是凹入的,只是判斷方法不符合我們日常生活習慣,因為這時大多數光不是從上方照射,而是從下往上照射)。

What is a Bump Map
A bump map is very much like a texture map. However, rather than containing colours, it contains bumps. The most common way to represent bumps is by the height field method. A greyscaled texture map is used, where the brightness of each pixel represents how much it sticks out from the surface (see image on right). This is a very convenient way to store a bump map, and it's simple to make. How this information is used by the renderer will become apparent later.
Of course, you needn't limit yourself to such simple patterns. You can have wood, stone, peeling paint, anything you want.
bumpmap5.gif  
  
什麼是凹凸貼圖
凹凸貼圖一個很像紋理圖。然而,而不是包含的顏色,它包含顛簸。最常見的方式來表示顛簸是由高度場的方法。一個greyscaled紋理貼圖的場合,在每個像素的亮度是多少代表表面(見圖片右)這是一個非常方便的方式來存儲一個凹凸貼圖,它製作簡單如何使用這些信息由渲染器變得明顯
當然,你不必限制自己這種簡單的模式你可以有木材,石材,油漆脫落任何你想要的。

So how's it done
Bump mapping is an extension of the Phong Shading technique. In Phong Shading, the surface normal was interpolated over the polygon, and that vector was used to calculate the brightness of that pixel. When you add bump mapping, you are altering the normal vector slightly, based on information in the bump map. Adjusting the normal vector causes changes in the brightness of the pixels in the polygon. Simple.
Now, there are several ways of acheving this. I have never actually programmed real phong shading or bump mapping, only the fast versions (which work very nicely thank you), so I am kind of making this next bit up as I go along. Bare with me.
OK, so we need a method for converting the height information on the bump map into vector adjustment information for the phong shader. This is not so hard to do, but it might be tricky to explain.
那麼怎麼完成它

凹凸貼圖是一個擴展Phong光照技術。Phong光照,表面正常的是插多邊形,而向量是用來計算該像素的亮度當您添加凹凸貼圖,你是稍微改變了正常的載體基於信息凹凸貼圖。調整向量導致的亮度變化的像素中的多邊形。簡單。
現在,有幾種方法acheving這一點。其實我從來沒有真正的Phong光照程序凹凸貼圖,只有快速的版本(這工作很很好的謝謝你),所以我下位使這個,我沿著光禿禿跟我來。
好了,我們需要一種方法高度信息轉換凹凸貼圖調整信息載體 Phong材質著色並不難做到,但它可能是棘手的解釋。

OK, so first you'll need a way to convert the bumps on the bumpmap into little vectors, one vector for each pixel. Take a look at the zoomed-in view of a bumpmap on the left. The lighter pixels stick out more than the darker ones. Get the picture? Now, for each pixel, a vector must be computed. These vectors represent the incline of the surface at that pixel. The picture on the right represents this. The little red vectors point in the 'downhill' direction.
There are many ways to calculate these vectors. Some are more accurate than others, but it depends exactly what you mean by accurate. One of the most common methods is to calculate the X and Y gradient at that pixel:
好了,首先,您需要一種方法來轉換顛簸bumpmap向量,一個向量的每個像素。看一看放大的查看一個 bumpmap在左邊。較輕的像素伸出的。知道了嗎?現在,每個像素,向量必須被計算。這些向量代表了傾斜的表面在該像素。圖片右邊代表這一點。小紅向量在'下坡'的方向
有許多方法來計算這些載體有些人比別人更準確不過這取決於你的意思正是通過準確的。其中最常見的方法是計算 X和Y梯度在該像素
bumpmap6.gif     bumpmap7.gif  



x_gradient = pixel(x-1, y) - pixel(x+1, y)
y_gradient = pixel(x, y-1) - pixel(x, y+1)
With these two gradients, you will now need to adjust the normal vector of the polygon at that point.
Here is the polygon, with it's origional normal vector, n. Also shown are the two vectors which are going to be used to adjust the normal vector for this pixel. The two vectors must be aligned with the bumpmap for the polygon to be rendered correctly. I.E. the vectors are parallel to the axes of the bumpmap.
On the right are the bump map, and the polygon. Both pictures show the U and V vectors. 

Now you can see the new Normal vector after adjustment. The adjustment is simply:
New_Normal = Normal + (U * x_gradient) + (V * y_gradient)
With this New_Normal vector , you can procede to calculate the brightness of the polygon at that point, using the usual phong shading technique. 

x_gradient = pixel(x-1, y) - pixel(x+1, y)
y_gradient = pixel(x, y-1) - pixel(x, y+1)
有了這兩個梯度,您現在需要調整的多邊形法向量在這一點上
下面是多邊形的,與它原來的法向量,全同時顯示兩個向量將要使用的正常調整向量這個像素。兩個向量都必須有多邊形bumpmap要呈現正確。向量平行於bumpmap
在右邊凹凸貼圖多邊形。這兩張圖片顯示的U和V載體

現在你可以看到新的法向量調整後調整很簡單:
New_Normal = Normal + (U * x_gradient) + (V * y_gradient)
有了這個 New_Normal向量,可以繼續計算多邊形的亮度這一點上,使用通常的Phong光照技術。
x_n1.gif   x_n2.gif           x_t1.gif   x_t2.gif  

  
arrow
arrow
    全站熱搜

    createps 發表在 痞客邦 留言(0) 人氣()