1 / 15

好孩子的 CG 教室 - 輕輕鬆鬆寫 CG 作業 2-Bump map

好孩子的 CG 教室 - 輕輕鬆鬆寫 CG 作業 2-Bump map. 為什麼有這份投影片呢 ?. 聽說有人說助教上課講太快 Bump map 都聽不懂 導致大家第二部分的作業都 怪怪的. EZ 的 Bump Map 的方法. 因為真正的 bump map 非常繁瑣 , 所以這裡提供替代方案教學 請各位看到資料夾中 fiber_bump.bmp fiber.bmp 真正要看的其實是 fiber_bump 他代表貼圖高度 ( 貼圖顏色還是要看 fiber) 所以如果怕麻煩的話也可以把 fiber.bmp 的 (R+G+B)/3 ( 效果是差不多的 ).

calvin
Download Presentation

好孩子的 CG 教室 - 輕輕鬆鬆寫 CG 作業 2-Bump map

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 好孩子的CG教室-輕輕鬆鬆寫CG作業2-Bump map

  2. 為什麼有這份投影片呢? • 聽說有人說助教上課講太快Bump map都聽不懂 • 導致大家第二部分的作業都怪怪的

  3. EZ的Bump Map的方法 • 因為真正的bump map非常繁瑣,所以這裡提供替代方案教學 • 請各位看到資料夾中 • fiber_bump.bmp • fiber.bmp • 真正要看的其實是fiber_bump他代表貼圖高度(貼圖顏色還是要看fiber) • 所以如果怕麻煩的話也可以把fiber.bmp 的(R+G+B)/3(效果是差不多的)

  4. 簡單的Bump Map的方法(cont) • 但請注意,不管是哪一張貼圖出來的取出的rgb值都不是normal!!! 請勿直接assign • 那normal到底要怎麼算呢?

  5. 容易的Bump Map的方法(cont) float temp = 1.0/512.0; //算出每個tixel之間的距離 vec2 i = vec2 ( gl_TexCoord[1].x,gl_TexCoord[1].y ); //i是計算的pixel位置 vec2 j = vec2 ( gl_TexCoord[1].x+temp,gl_TexCoord[1].y ); // 是其右方的pixel位置 vec2 k = vec2 ( gl_TexCoord[1].x,gl_TexCoord[1].y+temp ); //k是i上方的pixel位置 vec4 i_color = texture2D(colorTexture,i);//根據位置取得顏色 vec4 j_color = texture2D(colorTexture,j); vec4 k_color = texture2D(colorTexture,k); k (x,y-1) j (x-1,y) i (x,y)

  6. 單純的Bump Map的方法(cont) • v = ||i - k||就是垂直方向的高度差 • u = ||i - j|| 就是水平方向的高度差 • 三維方向的三個軸x, y和z • 先將法向量對z軸旋轉v • 再將法向量個z值scale u倍 • 最後將法向量 normalize新的normal就產生囉 \^o^/

  7. 方法好像跟老師教的不同?? • 投影片的Pu, Pv跟model的texture參數化有關;又因為teapot是圓柱投影,只跟Y軸有關,所以經過簡化後才能用這個偷吃步的方法。 • 所以想做正統方法的請私底下來找助教或自行上網查詢。

  8. 補交有什麼好處呢? • 現在大家的方法幾乎是都錯的,但助教會酌量給分,但也鼓勵想做的同學(或想多拿點分數的)可以補交bump map,會再額外加分 • 再助教送成績以前,都可以上傳補交,請各位好好把握!

  9. GDI plus • GDI + 是一種好東西 • 他可以幫助你寫期末專題 • +在這裡念做plus

  10. 如何輕鬆的搞定GDI +(1) • 宣告 • #include <gdiplus.h> • #pragma comment(lib, "gdiplus.lib") • using namespace Gdiplus; • GdiplusStartupInputgdiplusStartupInput; • ULONG_PTR gdiplusToken; • // Initialize GDI+. • GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

  11. 如何輕鬆的搞定GDI +(2) • //產生一張畫布 • PAINTSTRUCT ps; • HDC hdc= BeginPaint(hwnd,&ps); • Graphics g(hdc); • //開始畫東西 • g.DrawImage(…);//畫圖 • g.FillRectangle(…);//填滿矩形 • …

  12. 如何輕鬆的搞定GDI +(3) • 剩下的使用方法請參考範例程式 • brush,pen, string and draw picture 裡面有詳細的應用方法 • 如果還不夠….請參考MSDN

  13. 給要做RAYTRACING的人 • glMatrixMode(GL_PROJECTION); • glLoadIdentity(); • gluPerspective(90.0, (GLfloat)WinW/(GLfloat)WinH, 1.0, 1000.0); • glMatrixMode(GL_MODELVIEW); • glLoadIdentity(); • gluLookAt(WinW/2, WinH/2, WinH/2, • WinW/2, WinH/2, 0.0, • 0.0, 1.0, 0.0); • //Light(); • // clear the buffer • glClearColor(0.0f, 0.0f, 0.0f, 0.0f); • glClearDepth(1.0f); • glEnable(GL_DEPTH_TEST); • glDepthFunc(GL_LEQUAL); • glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); • GLfloatr_color = 1.0 , g_color=1.0, b_color=1.0;

  14. inti,j; • for(i=0;i<WinW;i++){ • for(j=0;j<WinH;j++){ • glBegin(GL_POINTS); • glColor3f(r_color,g_color,b_color); • glVertex2i(i,j); • glEnd(); • } • }

  15. END

More Related