Presentation is loading. Please wait.

Presentation is loading. Please wait.

6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.

Similar presentations


Presentation on theme: "6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering."— Presentation transcript:

1 6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering

2 6.2 Vis_04 Rendering of Triangles n Surface views for 2D scalar visualization, and isosurfaces for 3D scalar visualization both generate a triangular mesh surface n Techniques for rendering these meshes rely on : – an understanding of how light is reflected from surfaces - to define the colour of points within each triangle – generating a 2D image representation of the 3D scene n Just a simplified view here...

3 6.3 Vis_04 Reflection Model n There are two major components to consider in modelling reflection of light from a surface – diffuse reflection: this gives a dull effect; light is scattered evenly and gives the colour of the surface – specular reflection: this gives shininess of surface; light is reflected at angle of perfect reflection and has colour of incoming light – total effect is sum of both (plus ambient light)

4 6.4 Vis_04 * intensity of reflected light depends on angle of light to surface Reflection Model - Diffuse Reflection light source N L I* = Intensity of light source N = Surface normal L = Direction of light source K d = Diffuse-reflection coefficient (gives colour) I = Reflected intensity surface  I = K d (cos  ) I* * equal reflection in all directions I, I*, K d have R, G, B components

5 6.5 Vis_04 I* = Intensity of light source V = View direction R = Direction of perfect reflected light K s = Specular-reflection coefficient I = Reflected intensity I = K s ( cos  ) n I* n varies with material large n : shiny small n : dull Intensity depends on angle between eye and reflected light ray - and type of material V light source N L R eye surface  Reflection Model - Specular Reflection

6 6.6 Vis_04 Effect of Diffuse Reflection Slide from Alan Watt, University of Sheffield

7 6.7 Vis_04 Effect of Diffuse plus Specular Reflection Slide from Alan Watt, University of Sheffield

8 6.8 Vis_04 Rendering n To render a scene composed of a number of surfaces (here triangles): We can project the surfaces on to a viewing plane, determining which are visible to the eye, and assigning the colour as given by the lighting model

9 6.9 Vis_04 Perspective Projection view plane eye point

10 6.10 Vis_04 Parallel Projection view plane direction of projection

11 6.11 Vis_04 Triangle Rendering n Thus, by projecting the triangle vertices, we get position of triangle in image - how can we get the colour of pixels within the triangle? n There are three techniques of increasing complexity - and increasing realism – Flat shading – Gouraud shading – Phong shading

12 6.12 Vis_04 Flat Shading of Triangular Mesh n Each point in a triangle given the same intensity N1 N2 N3 N4 Fast and simple - but intensity discontinuities at edges Calculate intensity for each triangle from reflection model equations

13 6.13 Vis_04 Gouraud Shading of Triangular Mesh n Aim is to shade mesh as though it were curved surface Step 1: Approximate normal at each vertex in some way - one possibility is to average the normals of surrounding triangles

14 6.14 Vis_04 Gouraud Shading of Triangular Mesh Step 2: Calculate the intensity at each vertex using the lighting model I1I1 I2I2 I3I3 I1I1 I2I2 I3I3 Step 3: Calculate the intensity at any interior point by linear interpolation in triangle

15 6.15 Vis_04 Phong Shading of Triangular Mesh N1N1 N2N2 N3N3 Step 1: As for Gouraud, estimate normals at vertices N1N1 N2N2 N3N3 Step 2: Estimate normal at an interior point by linear interpolation Step 3: Calculate intensity by applying lighting model

16 6.16 Vis_04 Comparison of Techniques n Flat shading: – fast and simple, 1 lighting calc’n done per triangle, all pixels given same intensity – discontinuity in intensity across edges n Gouraud shading – relatively fast, 1 lighting calc’n per vertex, intensity linearly interpolated from vertex intensities - giving smooth appearance – now industry standard n Phong shading – slower, lighting calc’n for each pixel - giving very smooth appearance – not supported in OpenGL

17 6.17 Vis_04 Constant or Flat Shading - Each Polygon has Constant Shade

18 6.18 Vis_04 Gouraud Shading

19 6.19 Vis_04 Phong Shading

20 6.20 Vis_04 Flat, Gouraud and Phong Shading Slides from Alan Watt, University of Sheffield

21 6.21 Vis_04 Rendering by Ray Tracing n An alternative to polygon projection is the concept of ray tracing n Very high quality rendering with global inter- reflections

22 6.22 Vis_04 Rendering of Isosurfaces n Isosurface algorithms generate triangular meshes which can be rendered as just described n Key is the estimation of vertex normals for Gouraud and Phong shading n One possibility is to construct the entire surface, then assign vertex normals as average of normals of surrounding triangles

23 6.23 Vis_04 Rendering of Isosurfaces n An alternative - generally preferred - is based on fact that surface normal is equal to the gradient vector of f At (x i,y j,z k ), df/dx = 0.5*(f i+1,j,k - f i-1,j,k ) df/dy = 0.5*(f i,j+1,k - f i,j-1,k ) df/dz = 0.5*(f i,j,k+1 - f i,j,k-1 ) This gives us normals at all grid points, and then trilinear interpolation will give normals at the triangle vertices


Download ppt "6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering."

Similar presentations


Ads by Google