Redering Pipeline

27
Rendering Pipeline - Study Group: DevRookie - Author: Daeyoung Hwang

Transcript of Redering Pipeline

Page 1: Redering Pipeline

Rendering Pipeline

- Study Group: DevRookie - Author: Daeyoung Hwang

Page 2: Redering Pipeline

Define Rendering PipelineRendering PipelineSource Code in practice

Page 3: Redering Pipeline

Define Rendering PipelineRendering PipelineSource Codes in practice

Page 4: Redering Pipeline

Why do we need to understand ?

Shader programming

Optimize performance of rendering

Page 5: Redering Pipeline

Computer is a machine box which only distinguish 0 and 1

Then how to display 3D world ?

Page 6: Redering Pipeline

Does teapot actually exist in 3D world ?

3D Virtual worldIn 2D monitor

Fake!!

Page 7: Redering Pipeline

Process of making 2D Image using virtual camera that defines perspec-tive view of 3D world and geometry expression about 3D world

Rendering Pipe-line ?

Page 8: Redering Pipeline

Define Rendering PipelineRendering PipelineSource Codes in practice

Page 9: Redering Pipeline

Whole Process of Rendering Pipeline

Tessellation Clipping Projection Viewport Rasterization

Apply Tex-ture

Render Backend

Convert Local

Convert World

Convert View

Back-face Culling Light

Display

Page 10: Redering Pipeline

1. Convert Local

Unique coordinate of one model (Model Coordinate)

No problem expressing single object like model viewer

Page 11: Redering Pipeline

2. Convert World

Convert objects in local space to world co-ordinate

TransformMovement,Rotation,Scale

Page 12: Redering Pipeline

3. Convert View (Convert Camera)

Convert camera to zero of coordinate=> Convert all objects

Page 13: Redering Pipeline

4. Back-face Culling

Set polygon which assigned clock wise of winding order as front-face polygon

Page 14: Redering Pipeline

5. Light

Calculate color of vertex using light formula including light source vector, sight vector, face-normal vector

Page 15: Redering Pipeline

6. Tessellation

Increase, decrease vertexes freely at GPU

Page 16: Redering Pipeline

7. Clipping

Clip polygon which is outof sight

According to viewingfrustum

Page 17: Redering Pipeline

8. Projection

Process of getting 2d dimension from 3d dimension

Perspective / orthographicprojection

Page 18: Redering Pipeline

9. Viewport Screen Mapping

Convert to window screen coordinate

Page 19: Redering Pipeline

10. Rasterize (triangle setup)

Calculate converted polygon into pixel to display on screen

Result – 2D Image todisplay on monitor

Page 20: Redering Pipeline

11. Apply TextureUse UV coordinate (0~1)

Page 21: Redering Pipeline

12. Render backend

Is it okay to write on video memory ?• Alpha Test• Stencil Test• Z buffer Test

Page 22: Redering Pipeline

12. Render Backend

How to write on video memory?• Alpha Blending• Fog• Anti-aliasing

Page 23: Redering Pipeline

Define Rendering PipelineRendering PipelineSource Codes in practice

Page 24: Redering Pipeline

VOID SetupMatrices(){

// convert to worldD3DXMATRIXA16 matWorld;D3DXMatrixIdentity( &matWorld );g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

// convert to view(camera)D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f ); // position of eyeD3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f ); // position of looking atD3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );// Up VectorD3DXMATRIXA16 matView;D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

Page 25: Redering Pipeline

// convert projectionD3DXMATRIXA16 matProj;// matProj : matrix to set value// D3DX_PI/4 : FOV (Field of View)// 1.0f : the aspect ratio// 1.0f : near clipping plane// 100.0f : far clipping planeD3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );

}

Page 26: Redering Pipeline

Summary

Page 27: Redering Pipeline

Reference• Windows DirectX Graphics Document• DirectX 9 를 이용한 3D GAME 프로그래밍 입문• 3D 게임 프로그래밍 ( 개정판 )• allosha blog http://bit.ly/9vtHSg