Introduce to 3d rendering engine

1,522 views

Published on

This talks about some topics we need to know before designing our rendering engine, and it describes the graphics pipeline how to handle 3D objects drawing.

Published in: Technology, Art & Photos
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,522
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Introduce to 3d rendering engine

  1. 1. XPECSenior software engineerEllison Mu2012.9.201
  2. 2.  Game Platforms 3D EngineArchitecture Graphics Pipeline Q&A2
  3. 3. Console• PS3• XBOX 360• WiiDesktop• Windows• Linux• Mac OSXHandheldDevice• NDS, N3DS• PSP,Vita• iPhone/iPad• Android devicesWebBrowser• IE:ActiveX• Chrome,FireFox,Safori…: NPAPI3
  4. 4. 4
  5. 5. Target platform?Tools pipeline?Programming language?Game design?Reach or Rich?5
  6. 6. DecidemodelformatScenemanagementDraw surfaceRendermoduleMaterialsystem6
  7. 7. 7
  8. 8.  As possible as minimize draw surface View frustum culling8
  9. 9.  As possible as minimize draw surface Tree hierarchy▪ BSP▪ Quad-Tree▪ Oct-Tree▪ KD-Tree9
  10. 10. 10
  11. 11.  As possible as minimize draw surface Preprocess visibility determination11
  12. 12. 12
  13. 13.  As possible as minimize draw surface Preprocess visibility determination13
  14. 14. VertexbufferIndexbufferMaterial• Texture• Render state• ShaderExecutedraw call14
  15. 15.  Different platform provides different renderAPI DirectX OpenGL OpenGL ES Customized API15
  16. 16. Non-platform-dependency codesRender Layer Game LogicSceneManagerAbstractlayerPlatformdependencycodesSoftwaredevelopmentkit16
  17. 17. 17VertexIndexStream3D APICommandsAssembledPrimitivesPixelUpdatesPixelLocationStreamProgrammableFragmentProcessorTransformedVerticesProgrammableVertexProcessorGPUFront EndPrimitiveAssemblyFrameBufferRasterOperationsRasterizationandInterpolation3D API:OpenGL orDirect3D3DApplicationOr GamePre-transformedVerticesPre-transformedFragmentsTransformedFragmentsGPUCommand&DataStreamCPU-GPU Boundary (AGP/PCIe)Programmable pipeline
  18. 18. 18
  19. 19. 19(x, y, z)(r, g, b,a)(Nx,Ny,Nz)(tx, ty,[tz])(tx, ty)(tx, ty)Vertex Image F(x,y) = (r,g,b,a)Materialproperties*
  20. 20.  Without indexing With indexing20
  21. 21.  Vertices mapped from object space to worldspace M = model transformation (scene) V = view transformation (camera)21X’Y’Z’W’XYZ1M *V *
  22. 22.  Operate on a vertex to transform it into theviewport space The viewport is two-dimensional: however,vertex z-value is retained for depth testing.22
  23. 23.  All primitives are now converted tofragments. Data type change !Vertices to fragments The rasterizer produces a stream offragments.23Fragment attributes:(r,g,b,a)(x,y,z,w)(tx,ty), …
  24. 24. 24Color R G B APosition X Y Z WTexturecoordinatesX Y [Z] -TexturecoordinatesX Y [Z] -…Interpolated fromvertex informationX Y Z WInput: FragmentAttributes
  25. 25.  Color(v) = emissive + ambient + diffuse +specular Each term in the right hand side is a functionof the vertex color, position, normal andmaterial properties.25
  26. 26.  Each fragment undergoes a series of tests. Scissor Alpha Stencil Depth26
  27. 27.  Blending: pixels are accumulated into finalframebuffer storagenew-val = pixel-value op old-valnew-val = SrcColor * A + DstColor * B27
  28. 28. 28FragmentProcessorVertexProcessorGPUFront EndPrimitiveAssemblyRasterOperationsRasterizationandInterpolation
  29. 29.  Lock index buffer, vertex buffer, texture Create device, index buffer, vertex buffer,texture Destroy device, index buffer, vertex buffer,texture VaildateDevice Present Command buffer is full Query::GetData29
  30. 30.  Group similar material Avoid redundant state change Adv: Reduce probability of full command buffer Separate transparent / Opaque objects30
  31. 31.  Static / Dynamic type Share buffer is better Large buffer is better31
  32. 32. Thank you for attending32

×