Download presentation

Presentation is loading. Please wait.

Published byIrea Armstrong Modified over 3 years ago

1
16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects

2
16.2 Si23_03 Where were we…? n Phong reflection model tells us how light reflects from surfaces…

3
16.3 Si23_03 Phong Reflection Model light source N L R V eye surface I( ) = K a ( )I a ( ) + ( K d ( )( L. N ) + K s ( R. V ) n ) I*( ) / dist In practice, we evaluate I RED, I GREEN, I BLUE for red, green, blue intensities: I RED = K a RED I a RED + ( K d RED ( L. N ) + K s ( R. V ) n ) I* RED /dist dist = distance attenuation factor

4
16.4 Si23_03 Interpolated Shading n Polygons can be efficiently shaded using: – Flat shading – Gouraud shading – Phong shading n Visible surfaces are determined using the z-buffer algorithm flat Gouraud Phong

5
16.5 Si23_03 Flat, Gouraud and Phong Shading

6
16.6 Si23_03 Phong versus Gouraud Shading n A major advantage of Phong shading over Gouraud is that specular highlights tend to be much more accurate – vertex highlight is much sharper – a highlight can occur within a polygon n Also Mach banding greatly reduced n The cost is a substantial increase in processing time because reflection model applied per pixel n OpenGL only supports Gouraud shading

7
16.7 Si23_03 Adding Realism Through Texture Effects

8
16.8 Si23_03 Adding Realism plastic floating in air n Objects rendered using Phong reflection model and Gouraud or Phong interpolated shading often appear rather plastic and floating in air exture n Texture effects can be added to give more realistic looking surface appearance – Simple texture – Bumps – Light maps

9
16.9 Si23_03 Adding Surface Detail n The most obvious solution is not the best – breaking the scene into smaller and smaller polygonal objects increases the detail –..BUT it is very hard to model and very time-consuming to render n Preferred solution is texture mapping painted – typically a 2D image painted onto objects

10
16.10 Si23_03 A Simple Example n Suppose we have a 2D image... n.. and a 3D box n.. we can paint the image on a face of the box

11
16.11 Si23_03 … or a teapot

12
16.12 Si23_03 Basic Concept n Replace the shading calculation with a look-up into a texture map (ie 2D image) to get the colour of a pixel n May replace shaded value - or modulate it in some way

13
16.13 Si23_03 Question n We could apply the texture in screen space (ie after projection) n... or we could apply it in object space (ie before projection) n Which is more sensible?

14
16.14 Si23_03 Texture Mapping - Overview screen space I J object space during scan conversion of each polygon, find corresponding position of pixel on object texture space V U X Y Z paint texture on to object

15
16.15 Si23_03 Mapping Texture to Polygons n For polygon texture mapping, we explicitly define the (u,v) co- ordinates of the polygon vertices n That is, we pin the texture at the vertices n We interpolate within the triangle at the time of scan converting into screen space X Z Y object texture space V U

16
16.16 Si23_03 Texture Mapping Triangles (x 1,y 1,z 1 ) (x 2,y 2,z 2 ) (x 3,y 3,z 3 ) (u 1,v 1 ) (u 2,v 2 ) (u 3,v 3 ) (i 1,j 1 ) (i 2,j 2 ) (i 3,j 3 ) Interpolation is done during scan conversion, similar as is done for Gouraud interpolated shading But rather than interpolate to get RGB values, we get (u,v) values which point to elements of texture map.

17
16.17 Si23_03 Interpolation in Texture Space n The interpolation in texture space has to be done carefully n Equal steps in screen space do not correspond to equal steps in object space (and hence texture space) n Why? U V I J screen texture A line is a line in all 3 spaces X Z Y object

18
16.18 Si23_03 Interpolation in Texture Space n The rate of change in texture space will depend on the depth of the points from the viewer n Correct approach is to scale by the distance (z P, z Q ) of the points from the viewer U V texture I J screen P Q P Q If Q further away than P, then as we take equal steps from P towards Q, we want to take increasingly large steps in (U,V) space from P to Q.

19
16.19 Si23_03 Interpolation in Texture Space n Suppose (u P, v P ) and (u Q,v Q ) are texture co-ords at end-points P, Q n Linear interpolation would be: – u = u Q + (1- )u P with increasing from 0 to 1 (similarly for v) n Correct texture interpolation is: u = [ u Q / z Q + (1- )u P / z P ] / D where D = [ / z Q + (1- )/ z P ] U V texture P Q I J screen P Q Note: this is equivalent to a linear interpolation in projective space

20
16.20 Si23_03 Check for Yourself n Suppose P is one unit from viewer, and Q is two units from viewer n Show that the mid- point in screen space is equivalent to one-third of the distance along the line in texture space

21
16.21 Si23_03 Summing Up n We have seen how a 2D texture image can be mapped to an object, at the rendering stage – for a polygon, we pin texture to vertices and interpolate (correctly!) at scan conversion time modify n The texture value is used to modify the colour that would otherwise be drawn – options include replacing completely, or modulating (eg by multiplying shaded value with texture value)

22
16.22 Si23_03 Bump Mapping

23
16.23 Si23_03 Bump Mapping n This is another texturing technique n Aims to simulate a dimpled or wrinkled surface – for example, surface of an orange trick n Like Gouraud and Phong shading, it is a trick – surface stays the same – but the true normal is perturbed, or jittered, to give the illusion of surface bumps

24
16.24 Si23_03 Bump Mapping

25
16.25 Si23_03 How Does It Work? n Looking at it in 1D: original surface P(u) bump map b(u) add b(u) to P(u) in surface normal direction, N(u) new surface normal N(u) for reflection model

26
16.26 Si23_03 Bump Mapping A Bump Map

27
16.27 Si23_03 Bump Mapping Resulting Image

28
16.28 Si23_03 Bump Mapping - Another Example

29
16.29 Si23_03 Bump Mapping Another Example

30
16.30 Si23_03 Bump Mapping Procedurally Defined Bump Map

31
16.31 Si23_03 Another pioneer n Jim Blinn – Creator of bump mapping and many other graphics effects

32
16.32 Si23_03 Light Maps

33
16.33 Si23_03 The Problem with Gouraud…. n Gouraud shading is established technique for rendering but has well known limitations – Vertex lighting only works well for small polygons… – … but we dont want lots of polygons!

34
16.34 Si23_03 Pre-Compute the Lighting n Solution is to pre- compute some canonical light effects as texture maps n For example…

35
16.35 Si23_03 Rendering using Light Maps n Suppose we want to show effect of a wall light – Create wall as a single polygon – Apply vertex lighting – Apply texture map – In a second rendering pass, apply light map to the wall

36
16.36 Si23_03 Light Maps n Widely used in games industry n Latest graphics cards will allow multiple texture maps per pixel

Similar presentations

OK

1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.

1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 9 Adding Realism Through Texture.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on functional groups Working of flat panel display ppt online Ppt on bluetooth broadcasting hardware Org chart download ppt on pollution Ppt on earth dams Ppt on web browser and its features Ppt on grease lubrication system Ppt on aircraft landing gear system description Ppt on limitation act ontario Ppt on culture of assam