1 / 16

3D Game Programming Lab6- Bump Mapping

3D Game Programming Lab6- Bump Mapping. Goal. 了解 bump mapping 的原理 懂得如何使用 GLSL 實作 bump mapping 自行製作 bump map. The Perception. Bump Mapping. add bump map textures to models. model. bump map. result. GLSL. Vertex shaders change or get the information of vertices Fragment shaders

kanoa
Télécharger la présentation

3D Game Programming Lab6- Bump Mapping

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. 3D Game ProgrammingLab6-Bump Mapping

  2. Goal • 了解bump mapping的原理 • 懂得如何使用GLSL實作bump mapping • 自行製作bump map

  3. The Perception

  4. Bump Mapping • add bump map textures to models model bump map result

  5. GLSL • Vertex shaders • change or get the information of vertices • Fragment shaders • mostly compute the color to be applied to a fragment

  6. Bump Mapping in GLSL MCVertex MCNormal MCTangent TexCoord0 What you see on the pixelFragColor LightDir EyeDir TexCoord Vertex Shader Fragment Shader

  7. Vertex Shader • compute the informaion of vertices gl_Position = MVPMatrix * MCVertex; EyeDir = vec3(MVMatrix * MCVertex); TexCoord = TexCoord0.st; vec3 n = normalize(NormalMatrix * MCNormal); vec3 t = normalize(NormalMatrix * MCTangent); vec3 b = cross(n, t); vec3 v; v.x = dot(LightPosition, t); v.y = dot(LightPosition, b); v.z = dot(LightPosition, n); LightDir = normalize(v); v.x = dot(EyeDir, t); v.y = dot(EyeDir, b); v.z = dot(EyeDir, n); EyeDir = normalize(v);

  8. Fragment Shader • calculate the color to be perceived vec3 litColor; vec2 c = BumpDensity * TexCoord.st; vec2 p = fract(c) - vec2(0.5); float d, f; d = dot(p,p); f = inversesqrt(d + 1.0); if (d >= BumpSize) { p = vec2(0.0); f = 1.0; } vec3 normDelta = vec3(p.x, p.y, 1.0) * f; litColor = SurfaceColor.rgb * max(dot(normDelta, LightDir), 0.0); vec3 reflectDir = reflect(LightDir, normDelta); float spec = max(dot(EyeDir, reflectDir), 0.0); spec = pow(spec, 6.0); spec *= SpecularFactor; litColor = min(litColor+spec,vec3(1.0)); FragColor = vec4(litColor, SurfaceColor.a);

  9. Bump Map • height map • normal map • displacement map height / normal displacement

  10. Create Bump Map • Image Editing Software • Photoshop • PhotoImpact • GIMP • CrazyBump http://www.crazybump.com/

  11. Create Bump Map • get a image of the texture • take a photo by yourself • find images on the Internet http://www.cgtextures.com/

  12. Create Bump Map

  13. Create Bump Map • select bumps or dents

  14. Create Bump Map • adjust parameters and save 1. 2.

  15. Create Bump Map Normal Grayscale of Normal convert by other software Occlusion Specularity

  16. Create Bump Map Without Bump Map Specularityas Height Map

More Related