Section 2 (graphics)

  • Uploaded by: cmp2012
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Section 2 (graphics) as PDF for free.

More details

  • Words: 750
  • Pages: 33
Computer Graphics Using Direct 3D Basics

Outline • Vectors for Direct3D Graphics • Transformations and Matrices • Direct3D 9.0 Rendering Pipeline (The story of a pixel) 2

Outline • Vectors for Direct3D Graphics • Transformations and Matrices • Direct3D 9.0 Rendering Pipeline (The story of a pixel) 3

Vectors • • • • • •

Left-handed Coordinate System Vector addition and subtraction Dot product (Why needed ?) Cross product (Why needed ?) Magnitude Normalization 4

D3DVECTOR Type

5

D3DXVECTOR

6

D3DXVECTOR (Cont.)

7

D3DXVECTOR (Cont.)

8

D3DXVECTOR (Cont.) • Direct3D provides utility functions for vectors such as D3DXVec3Length, D3DXVec3Normalize, D3DXVec3Dot, D3DXVec3Cross • Direct3D also provides D3DXVECTOR2 and D3DXVECTOR4 types to represent 2-D and 4D vectors.

9

Outline • Vectors for Direct3D Graphics • Transformations and Matrices • Direct3D 9.0 Rendering Pipeline (The story of a pixel) 10

Transformations • The rendering technique used by Direct3D depends on “projecting” 3D objects onto “image plane”.

11

Transformations (Cont.) • This needs 3 transformations: – Transforming object points from local to world coordinate system (World Transformation) – Transforming object points from world coordinates to camera-relative coordinates (Camera Transformation) 12

Transformations (Cont.) • This needs 3 transformations: – Transforming object points 3D camera coordinate system to 2D image coordinate system (Projection Transformation)

• In this session, we will focus on world transformation. 13

Transformations (Cont.) • Many transformations (e.g. rotation, scaling, translation, skew) can be represented by a set of linear equations • x` = a0x + b0y + c0z + d0 • y` = a1x + b1y + c1z + d1 • z` = a2x + b2y + c2z + d2

14

Transformations (Cont.) • This set can be represented by a single matrix equation [x` y` z` 1] = a 0 a 1 a2 a3 [x y z 1][ b0 b1 b2 b3 ] c0 c1 c2 c3 d0 d1 d2 d3 15

Transformations (Cont.) • Example: Translation +3 along x-axis [x` y` z` 1] = 1000 [x y z 1][ 0 1 0 0 ] 0010 3001

16

Transformations (Cont.) • Matrix representation allows for easy combination of transformations: – xAB = x(AB) = (xA)B

• Applying the transformation AB is equivalent to applying A then B • Transformations are combined by multiplying corresponding matrices 17

Transformations (Cont.) • More on transformations and transformation matrices will be studied in the lectures.

18

D3DMATRIX

19

D3DXMATRIX • D3DXMATRIX extends D3DMATRIX providing access functions and overloaded operators.

20

D3DXMATRIX • There are utility functions to perform common matrix operations such as D3DXMatrixIdentity, D3DXmatrixTranspose and D3DXMatrixInverse • There are also functions to construct common transformation matrices such as D3DXMatrixTranslation, D3DXMatrixRotationX and D3DXMatrixScaling

21

D3DXMATRIX • D3DXTransformCoord applies a transformation matrix to a D3DXVector • D3DXTransformNormal applies a transformation matrix to a D3DXVector without the 4th row. Useful when the vector represents a direction rather than a location (e.g. normal vector) (Why ?) 22

Mid-way Summary • 3D Graphics use vectors and vector operations. • Transformations of vectors can be represented by matrices. • D3DXVECTOR and D3DXMATRIX classes and associated functions provide a handy matrix toolset. 23

Outline • Vectors for Direct3D Graphics • Transformations and Matrices • Direct3D 9.0 Rendering Pipeline (The story of a pixel) 24

Why study the pipeline ??

25

Direct3D 9.0 Pipeline

[Image from MSDN] 26

Direct3D 9.0 Pipeline (Cont.) • Vertex Data – Untransformed model vertices stored in memory buffers [Vertex Buffer]

• Primitive Data – Geometric primitives (lines, triangles, polygons ... etc) refer to vertices using indices [Index Buffers]

27

Direct3D 9.0 Pipeline (Cont.) • Tessellation – Extract vertices from higher-order primitives

• Vertex Processing – Transformation – Per-vertex Lighting

28

Direct3D 9.0 Pipeline (Cont.) • Geometry Processing – Clipping – Backface Culling – Rasterization

• Pixel Processing – Given geometry and texture data, determine final pixel color (final for the primitive not the image) 29

Direct3D 9.0 Pipeline (Cont.) • Pixel Rendering – Determine final pixel color to be output to the image plane (rendering target) • Object occlusion (Depth test) • Blending • Stencil test, Alpha test

30

Direct3D 9.0 Pipeline (Cont.) • This was the fixed rendering pipeline • The programmable rendering pipeline allows you to override vertex and pixel processing stages using vertex and pixel shaders

31

Summary • We have overviewed the DirectX pipeline and its stages. • Meanwhile we encountered important terms such as vertex, pixel, primitive, texture, light, shaders. • Also, we have got insight on an important stage in the pipeline which is vertex transformation. 32

Any Questions ??

33

Related Documents

Section 2 (graphics)
June 2020 5
Graphics
November 2019 36
Graphics
May 2020 21
Section 2
November 2019 22
Section 2
November 2019 14
Section 2
April 2020 11

More Documents from ""