advanced computer graphics spring 2014 k. h. ko school of mechatronics gwangju institute of science...
TRANSCRIPT
Advanced Computer Graphics Spring 2014
K. H. Ko
School of MechatronicsGwangju Institute of Science and Technology
3
Introduction
Game Engine Graphics side
Graphics Engine Physics side
Physics Engine
Physics Engine A library that encapsulates the implementation
of the low-level physics and provides high-level API for those applications that require enforcement of physical laws.
4
Introduction
Core System
Low-level system-Basic data structure
-File Handling
-Memory Management
-Etc.
Mathematics system-Basic Mathematics functions
-Vector & Matrix Algebra
-Quaternions
-Etc.
Object Management
Interface to System
5
Physics Engine Graphics Engine
Introduction
Core System
- Rendering system
-Collision Detection
-Physics system
-Etc.
Game Engine
7Taken from the course notes by Tomas Akenine-Möller, Chalmers University of Technology
State-of-the-Art Real-Time Rendering2001
8
State-of-the-Art Real-Time Rendering2001
Taken from the course notes by Tomas Akenine-Möller, Chalmers University of Technology
9
Which one is a real photo,and which one is CG?
Taken from the course notes by Tomas Akenine-Möller, Chalmers University of Technology
10
Complexity: 8 million triangles…
Taken from the course notes by Tomas Akenine-Möller, Chalmers University of Technology
11
Photo-realistic Rendering…
Taken from the course notes by Tomas Akenine-Möller, Chalmers University of Technology
12
Graphics Rendering Pipeline
The main function of the pipelineGenerate, or renderrender, a two-dimensional
image. Given a virtual camera, three-dimensional
objects, light sources, lighting models, textures and more.
The pipeline is the underlying tool for real time rendering.
14
Graphics Rendering Pipeline
ArchitectureThree conceptual stages – the engine of
the rendering pipeline
Each of these stages is usually a pipeline in itself.
15
Graphics Rendering Pipeline
ArchitectureConceptual stages
Application, geometry and rasterizerFunctional stages
Has a certain task to perform But does not specify the way that task is
executed in the pipelinePipeline stages
It is executed simultaneously with all the other pipeline stages.
16
Graphics Rendering Pipeline
ArchitectureExample
The geometry stage may be divided into five functional stages.
But it is the implementation of a graphics system that determines its division into pipeline stages.
A given implementation may combine two functional stages into one pipeline stage.
While it divides another, more time-consuming, functional stage into several pipeline stages or parallelizes it.
17
Graphics Rendering Pipeline
ArchitectureDetermination of the rendering speed:
the update speed of the images, fps (frames per second)
The slowest of the pipeline stages
18
Graphics Rendering Pipeline
Application Stage (executed on CPU) Driven by the application and therefore
implemented in software. Collision detection, acceleration algorithms,
animations, force feedback, etc. The developer has full control over what
happens in the application stage. At the end of the application stage, the
geometry to be rendered is fed to the next stage.
Rendering primitives, i.e., points, lines, triangles, etc.
19
Graphics Rendering Pipeline
Application Stage (executed on CPU) Rendering Primitives.
Most important task is to send rendering primitives (e.g. triangles) to the graphics hardware
20
Graphics Rendering Pipeline
Geometry stageComputes what is to be drawn, how it
should be drawn and where it should be drawn.
Is responsible for the majority of the per-polygon operations or per-vertex operations.
Implemented either in software or in hardware.
Transforms, projections, lightings, etc.
21
Graphics Rendering Pipeline
Geometry stageFunctional stages: They form a single
pipeline stage.
It performs a very demanding task. Model and view transform, lighting and
shading, projection, clipping, screen mapping
22
Graphics Rendering Pipeline
Geometry stageModel and view transform
Model coordinates -> model transform -> world coordinate or world space
The world space is unique. All models exist in the same space.
Only the models that a camera sees are rendered.
The camera has a location in world space and a direction.
23
Graphics Rendering Pipeline
Geometry stageModel and view transform
View transform : To facilitate projection and clipping, the camera and all the models are transformed with the view transform.
This transform makes the clipping and projection operations simpler and faster.
25
Graphics Rendering Pipeline
Geometry stageLighting and shading
In order to lend models a more realistic appearance, the scene can be equipped with one or more light sources.
Shading technique – The colors are given at the vertices of a triangle. Interpolation techniques are needed to cover the entire triangle.
Gouraud Shading, Phong Shading, etc.
27
Graphics Rendering Pipeline
Geometry stageProjection
After lighting, rendering systems perform projection.
It transforms the view volume into a unit cube with its extreme points at (-1,-1,-1) and (1,1,1).
The unit cube is called the canonical view volume. Orthographic projection Perspective projection
29
Graphics Rendering Pipeline
Geometry stageClipping
Only the primitives wholly or partially inside the view volume need to be passed on to the rasterizer stage, which then draws them on the screen.
The primitives that are partially inside the view volume require clipping.
Due to the projection transformation, the clipping is done against the unit cube.
Consistency
31
Graphics Rendering Pipeline
Geometry stageScreen Mapping
The coordinates of the primitives from the previous stage are still three-dimensional.
The x and y coordinates of each primitive are transformed to form screen coordinates.
Window coordinates.
33
Graphics Rendering Pipeline
Rasterizer stage Draws (renders) an image with use of the data
that the previous stage generated. Given the transformed and projected vertices, colors
and texture coordinates, the goal of the rasterizer stage is to assign correct colors to the pixels to render an image correctly.
Rasterization or scan conversion. Per-pixel operations
Color buffer. It is responsible for resolving visibility.
Z-buffer (depth buffer) is used.
36
OpenGL Rendering Pipeline
Display ListsAll data (geometry or pixels) can be
saved in a display list for current or later use.
Cf. Immediate modeWhen a display list is executed, the
retained data is sent from the display list.
38
OpenGL Rendering Pipeline
EvaluatorsAll geometric primitives are eventually
described by vertices.Evaluators provide a method for
deriving the vertices used to represent curves or surfaces.
Parametric curves and surfaces : evaluate vertices using the control points and basis functions.
40
OpenGL Rendering Pipeline
Per-Vertex Operations They convert the vertices into primitives.
Vertex data transformation Texturing Lighting calculation etc.
Primitive Assembly Constructs complete geometric primitives
They are transformed and clipped vertices with related color, depth and sometimes texture-coordinate values and guidelines for rasterization.
42
OpenGL Rendering Pipeline
Pixel Operations From system memory
Pixels are first unpacked into the proper number of components.
Next the data is scaled, biased and processed by a pixel map.
The results are clamped and then either written into texture memory or sent to the rasterization step.
From frame buffer If pixel data is read from the frame buffer
43
OpenGL Rendering Pipeline
Pixel OperationsFrom frame buffer
If pixel data is read from the frame buffer, pixel-transfer operations (scale, bias, mapping and clamping) are performed.
Then, the results are packed into an appropriate format and returned to an array in system memory.
45
OpenGL Rendering Pipeline
Texture Assembly Rasterization
The conversion of both geometric and pixel data into fragments.
Each fragment square corresponds to a pixel in the framebuffer.
Anti-aliasing are taken into consideration. Color and depth values are assigned for
each fragment square.
47
OpenGL Rendering Pipeline
Fragment Operations1st Operation: texturing2nd Operation: fog calculation3rd Operation: blending, dithering,
logical operation, masking by a bitmask4th Operation: the thoroughly processed
fragment is drawn into the appropriate framebuffer.