SE3250 Intro to 3D Computer Graphics Jay Urbain Credits: OpenGL, - - PowerPoint PPT Presentation
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
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.
Polygons, Meshes & Scan Conversion
V1 V2 V3 Raster Scan line
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
Geometric Transformations
- Transformation occurs
about the origin of the coordinate system’s axis Translate Scale Rotate
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
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).
The Camera
Parallel (orthographic) Projection Perspective Projection
The Camera
Projection Plane Near Clipping Plane Far Clipping Plane View Volume
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.
Ambient Lighting
- No light source – material color
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).
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) .
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.
Elements of OpenGL Lighting
- http://www.youtube.com/watch?v=g5pJd4L3aBM
- http://www.youtube.com/watch?v=sd0BOnN6aNY&feature=r
elated
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.
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.
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.
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.
Fall off in Phong Shading
Small n Large n
Approximating Curved Surfaces with Flat Polygons
Flat Shading – each polygon face has a normal that is used to perform lighting calculations.
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
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
Texture Mapping
- Apply picture to a polygon surface to add realism
without explicitly creating geometry.
v u
Texture Maps Used in Tank Game
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.
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
Billboarding
Billboards Real
Backface Culling & Flipping Surface Normals
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
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
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
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
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.
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.
Transparency & the Effect of Drawing Order
1 2 3
Drawing order
Alpha blending
Viewpoint Viewpoint
blending
- ccurs