SE3250 Intro to 3D Computer Graphics Jay Urbain Credits: OpenGL, - - PowerPoint PPT Presentation

se3250 intro to 3d computer graphics
SMART_READER_LITE
LIVE PREVIEW

SE3250 Intro to 3D Computer Graphics Jay Urbain Credits: OpenGL, - - PowerPoint PPT Presentation

SE3250 Intro to 3D Computer Graphics Jay Urbain Credits: OpenGL, Jason Leigh University of Illinois at Chicago Geometry - Polygon, Mesh, Vertex Most visible objects in a 3D scene are made up of polygon meshes A mesh is a grid-like


slide-1
SLIDE 1

SE3250 Intro to 3D Computer Graphics

Jay Urbain

Credits: OpenGL, Jason Leigh University of Illinois at Chicago

slide-2
SLIDE 2

Geometry - Polygon, Mesh, Vertex

  • Most visible objects in a 3D scene are made up of polygon meshes
  • A mesh is a grid-like structure that represents a complex shape.
  • Mathematically simple to render in real time, and detailed enough to be

recognizable.

  • Every shape is reduced to a number of connected polygons, usually

triangles; including round surfaces. triangles; including round surfaces.

  • Polygons' corner points are called vertices.
  • Every vertex is positioned at a coordinate, all vertices together describe

the outline of the shape.

  • Create 3D meshes in tools called mesh editors, e.g in Blender, Maya.
slide-3
SLIDE 3

Polygons, Meshes & Scan Conversion

V1 V2 V3 Raster Scan line

slide-4
SLIDE 4

Coordinate Systems Y Y

Left-handed Coordinate System (typical computer graphics Reference system) Right-handed Coordinate System (conventional Cartesian reference system)

X Y Z X Z

slide-5
SLIDE 5

Geometric Transformations

  • Transformation occurs

about the origin of the coordinate system’s axis Translate Scale Rotate

slide-6
SLIDE 6

Order of Transformations Make a Difference

Translate along X 1; Rotate about Z 45 Rotate about Z 45; Translate along X 1 Box centered at

  • rigin
slide-7
SLIDE 7

Hierarchy of Coordinate Systems

  • Also called:

– Scene graphs – Parent and Child Entities – Sometimes called Skeletons because it is usually used to represent people (arms, legs,

Local coordinate system

represent people (arms, legs, body).

slide-8
SLIDE 8

The Camera

Parallel (orthographic) Projection Perspective Projection

slide-9
SLIDE 9

The Camera

Projection Plane Near Clipping Plane Far Clipping Plane View Volume

slide-10
SLIDE 10

Materials: Color, Lighting/Shading

  • “Color" is part of an object's light reflection.
  • Our brain uses shading and reflecting properties to infer an object's shape

and material.

  • Differentiate chalk & milk, skin & paper, water & plastic.
  • Ambient color

The uniform base color of the mesh – what it looks like when not – The uniform base color of the mesh – what it looks like when not influenced by any light source. – Usually similar to the Diffuse color. – Min. color you need for an object to be visible.

  • Diffuse color

– Base color of the mesh plus shattered light and shadows that are caused by a light source. – Usually similar to the Ambient color.

slide-11
SLIDE 11

Ambient Lighting

  • No light source – material color
slide-12
SLIDE 12

Light Sources - Emissive color

  • Emissive color

– The color of light emitted by a light source or glowing material. – Only glowing materials such as lights have an emissive color, normal

  • bjects don't have this property.

– Often white (sun light).

slide-13
SLIDE 13

Light Sources - Reflections

  • Reflections: Shininess

– Degree of shininess of a surface. – Shiny objects have small, clearly outlined specular highlights. (E.g. glass, water, silver) – Normal objects have wide, blurry specular

  • highlights. (E.g. metal, plastic, stone, polished
  • highlights. (E.g. metal, plastic, stone, polished

materials). – Uneven objects are not shiny and have no specular highlights. (E.g. cloth, paper, wood, snow) .

slide-14
SLIDE 14

Light Sources - Reflections

  • Reflections: Specular Color

– If the material is shiny, then the Specular Color is the color of the reflected highlights. – Usually the same as the emissive color of the light source (e.g. white). – You can use colors to achieve special specular effects, such as metallic

  • r iridescent reflections.
  • r iridescent reflections.

– Non-shiny objects have a black specular color.

slide-15
SLIDE 15

Elements of OpenGL Lighting

  • http://www.youtube.com/watch?v=g5pJd4L3aBM
  • http://www.youtube.com/watch?v=sd0BOnN6aNY&feature=r

elated

slide-16
SLIDE 16

Materials: Textures

  • Simplest case: object has one texture, the Color Map, loaded from one

image file.

  • The more information you provide to the Color Map, the higher the

degree of detail and realism.

  • Whether you want photo-realistic rendering or "toon" rendering (Cel

Shading), everything depends on the quality of your materials and Shading), everything depends on the quality of your materials and textures.

  • Modern 3D graphics use several layers of information to describe one

material, each mapped layer is a texture.

slide-17
SLIDE 17

Color Map / Diffuse Map

  • A plain image file or a procedural texture that describes an
  • bject's visible surface.
  • The image can have alpha channels for transparency.
  • A Color Map is the minimum texture. You can map more

textures as optional improvements. textures as optional improvements.

  • Color Maps are unshaded. The same is called Diffuse Map in a

Phong-illuminated material, because this texture defines the basic colors of light that are diffused by this object.

slide-18
SLIDE 18

Diffuse Reflection (Lambertian Lighting Model)

The greater the angle between the normal and the vector from the point to the light source, the less light is reflected. Most light is reflected when the angle is 0 degrees, none is reflected at 90 degrees.

slide-19
SLIDE 19

Specular Reflection (Phong Lighting Model)

  • Maximum specular reflectance
  • ccurs when the viewpoint is

along the path of the perfectly reflected ray (when alpha is zero).

  • Specular reflectance falls off

quickly as alpha increases. quickly as alpha increases.

  • Falloff approximated by

cosn(alpha).

  • n varies from 1 to several

hundred, depending on the material being modeled.

  • n=1 provides broad, gentle falloff
  • Higher values simulate sharp,

focused highlight.

  • For perfect reflector, n would be

infinite.

slide-20
SLIDE 20

Fall off in Phong Shading

Small n Large n

slide-21
SLIDE 21

Approximating Curved Surfaces with Flat Polygons

Flat Shading – each polygon face has a normal that is used to perform lighting calculations.

slide-22
SLIDE 22

Gouraud Shading

  • Compute vertex normals by

averaging face normals.

  • Compute intensity at each vertex.
  • Interpolate the intensity along

the edges of the polygon. I1 I2 I1,2 I1,3 I3

I1,2,3,4

Raster Scan line

slide-23
SLIDE 23

Phong Shading

  • Interpolate the Normals

between the end points

  • f the scan line rather

than just the intensity.

  • Used with Phong

lighting model to

N1 N2 N1,2 N1,3 N3

N1,2,3,4

Raster Scan line

lighting model to produce specular highlights.

N1,2 N1,3

N2

http://www.youtube.com/watch?v=Seo5eo3GUQo&feature=related

slide-24
SLIDE 24

Texture Mapping

  • Apply picture to a polygon surface to add realism

without explicitly creating geometry.

v u

slide-25
SLIDE 25

Texture Maps Used in Tank Game

slide-26
SLIDE 26

Sprite

  • Typically a 2D image or animation that is integrated into a

larger scene.

  • Initially used to describe graphical objects handled separate

from the memory bitmap of a video display.

  • Term has since been applied more loosely to refer to various
  • Term has since been applied more loosely to refer to various

manner of graphical overlays.

slide-27
SLIDE 27

Billboarding

  • Sprite now refers to a partially transparent two dimensional

animation that is mapped onto a special plane in a 3D scene.

  • Unlike a texture map, the sprite plane is always perpendicular to

the axis emanating from the camera.

  • The image can be scaled to simulate perspective, rotated two

dimensionally, overlapped with other objects, and can be occluded.

  • It can only be viewed from a single angle.
  • This rendering method is also referred to as billboarding.
  • http://www.youtube.com/watch?v=0PtEW3It65s
slide-28
SLIDE 28

Billboarding

Billboards Real

slide-29
SLIDE 29

Backface Culling & Flipping Surface Normals

slide-30
SLIDE 30

Normal Mapping

  • In modern games, normal maps are computed for high

polygon scenes and then mapped onto low polygon models giving them incredible levels of detail

slide-31
SLIDE 31

Bump Mapping

  • Predecessor to Normal Mapping where a greyscale texture is

used as a height field to modify the shading normal on the surface of a polygon (on a per pixel basis)

  • Creates very similar effect as Normal Mapping

Polygon surface

Height field

Perturbed normals

slide-32
SLIDE 32

Normal Mapping

  • Modify normals on a per-pixel

basis using a Normal Map

  • The map is an R,G,B map

where the 3 components represent the direction of the normal vector relative to the tangent of the polygon’s Regular texture map Texture map + normal map surface

slide-33
SLIDE 33

Weakness of Normal/Bump Mapping

  • If you look at the polygon on its

side, it will still look flat.

  • Answer: Use parallax mapping to

modify texture.

  • Answer: Use Displacement

Mapping to perturb the actual

Bump

Mapping to perturb the actual geometry of the mesh

  • Height field is used to displace the

geometry of the mesh along its normal

Displacement

slide-34
SLIDE 34

Double Buffering, Drawing Order, Z Buffering

Front Buffer

Back Buffer Image is drawn to the back buffer while the front buffer is displayed to the viewer. Swapping is usually done

Buffer

Swapping is usually done during vertical blank of the monitor (50Hz). Most PCs tend to turn this synch off resulting in flickering of graphics.

slide-35
SLIDE 35

Depth Sorting of Polygons

  • Polygons have to be sorted

back-to-front to draw them in the right order.

  • Z Buffer ~ 16-32 bits/pixel.
  • Buffer that stores depth

information on a per pixel basis.

  • Used to determine which pixel

2 3 4 8

  • Used to determine which pixel

is in front of the other.

  • Small Z values are in front.
  • Avoids having to sort polygons

in Z when rasterizing.

slide-36
SLIDE 36

Transparency & the Effect of Drawing Order

1 2 3

Drawing order

Alpha blending

Viewpoint Viewpoint

blending

  • ccurs