BUMP-MAPPING SET09115 Intro to Graphics Programming

Embed Size (px)

Citation preview

  • Slide 1

BUMP-MAPPING SET09115 Intro to Graphics Programming Slide 2 Breakdown Background Review texturing and lighting Adding detail Bump and Normal Mapping Examples Shaders Advanced Techniques Parallax mapping Tessellation Slide 3 Recommended Reading Real-Time Rendering Chapter 6, section 6.7 onwards For tessellation, see 13.6 Slide 4 Background Slide 5 Review - Lighting Lighting is the technique we use to provide depth to our renders Three basic lighting types Ambient Background light Diffuse Directional light Specular Shininess Slide 6 Review - Textures Textures are just a 2D grid of pixels we can use for other purposes For examples, alpha-mapping We can use texture data in our shaders to perform more elaborate effects Using texture data is one of the commonest techniques for adding more detail to a 3D model Slide 7 Problem Adding Detail We want detail The more detail the better How do we get high detail renders in our game so we can see creases in fingers, notches in swords, etc? Slide 8 Solution Add Geometry Easy solution add more triangles Artists solution More triangles means more geometry means higher quality So job done, right? Slide 9 Problem Processing Geometry Problem is processing high poly count models Typically try and keep characters down to 25,000 High number of triangles means it takes longer to render Fine for non-real-time applications Games we need better techniques So how do we add detail, without adding geometry? Slide 10 Cheating with Lighting Effectively, we have already been doing this Lighting cheats Phong shading is an example We need techniques which allow us to manipulate the light to make it look like there is detail Slide 11 Options Bump Mapping Normal Mapping Relief Mapping Parallax Mapping Slide 12 Questions? Slide 13 Bump and Normal Mapping Slide 14 Bump Mapping Bump mapping is the technique used to add detail to a surface Think roughness / texture Bump mapping is the simplest technique for adding detail using textures Slide 15 Bump Map A bump map is just a black and white image that is used to modify the surface a model to provide a rough look Detail is very fine, surface level Think cloth texture Slide 16 Video Example http://www.youtube.com/watch?v=HR422RXjw-Q http://www.youtube.com/watch?v=HR422RXjw-Q Slide 17 Procedural Bump Mapping Frag Shader vec3 litColour; 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; litColour = SurfaceColour.rgb * max(dot(normDelta, LightDir), 0.0); vec3 reflectDir = reflect(LightDir, normDelta); // Use reflectDir as relection normal Slide 18 Normal Mapping Normal mapping extends on the bump mapping technique to create a more shaped detail Think brick work rather than low level surface Slide 19 Normal Maps Normal maps use RGB as their texture colours Depending on the colour, the lighting model determines the normal of the model at that particular point of the texture Slide 20 Video Example http://www.youtube.com/watch?v=pQS2m18ebEI http://www.youtube.com/watch?v=pQS2m18ebEI Slide 21 Normal Mapping Shader Normal mapping shader works similarly to the bump mapping shader Typically, we add specularity as well Main difference is that our normals are more than two values, allowing a more realistic lighting effect Slide 22 Questions? Slide 23 Advanced Techniques Slide 24 Relief Mapping Relief mapping is where we add detail using a texture, but actually manipulate the geometry to create the detail Actually, we talked a bit about relief mapping for terrain generation last week We are manipulating a 3D plane into our 3D terrain Relief mapping is useful, but more expensive Slide 25 Relief Map Example http://www.youtube.com/watch?v=5gorm90TXJM http://www.youtube.com/watch?v=5gorm90TXJM Slide 26 Parallax Mapping AKA virtual displacement mapping Uses the viewer position to retrieve different pixels from the texture based on the height field Slide 27 Video Example http://www.youtube.com/watch?v=R4vIQobnegk http://www.youtube.com/watch?v=R4vIQobnegk Slide 28 Displacement Mapping Essentially relief mapping Proper relief mapping has the ability for self- occlusion and self- shadowing Technique requires geometry to be added to a model Tessellation Slide 29 Tessellation The big new addition to DirectX 11 Triangles are added or removed based on how close the viewer is Think like mip-mapping, but for models Not like normal LOD where different models are used Slide 30 Video Example http://www.youtube.com/watch?v=-uavLefzDuQ http://www.youtube.com/watch?v=-uavLefzDuQ Slide 31 Questions? Slide 32 To do this week Practical this week is on texturing I need to tweak the one on WebCT a little I know 3 rd years have MAD CW due this week Get it out of the way so you can move onto this one I wont be producing a practical on bump mapping If interested, investigate yourself Slide 33 Summary Adding details to a render is where current game technology is focused Model complexity cant go much further on current generation hardware Various techniques allow us to modify a render to provide detail Bump mapping, normal mapping, etc. There is a cost, but usually less than adding geometry