3D Games Rendering


        Érico de Morais Nunes -            nunes.erico@gmail.com
                  Universidade Feder...
Summary
 ●
     About me
 ●
     This talk is not about
 ●
     Introduction
 ●
     Definitions
 ●
     OpenGL
 ●
     3D...
●
     About me
 ●
     This talk is not about
 ●
     Introduction
 ●
     Definitions
 ●
     OpenGL
 ●
     3D Pipeline...
About Me
 ●
     I am a Computer Engineering student.
 ●
     3D Rendering is not my main research
     area, though I hav...
Summary
 ●
     About me
 ●
     This talk is not about
 ●
     Introduction
 ●
     Definitions
 ●
     OpenGL
 ●
     3D...
This talk is not about
 ●
     Unfortunately, this talk is not aimed at...
     ●
         NVIDIA A is better than ATI B.
...
●
     About me
 ●
     This talk is not about
 ●
     Introduction
 ●
     Definitions
 ●
     OpenGL
 ●
     3D Pipeline...
Introduction
 ●
     Games nowadays look just damn real!
     ●
         And in real time!




May 23, 2009               ...
Introduction
 ●
     How do they do it?




May 23, 2009         Tchelinux 2009   9
Introduction
 ●
     We could also go a bit back...
 ●
     How did they do it, back at the days?

     Doom, 1993
     Sy...
Introduction
 ●
     In this talk, we shall see the science
     behind graphics.




May 23, 2009          Tchelinux 2009...
●
     About me
 ●
     This talk is not about
 ●
     Introduction
 ●
     Definitions
 ●
     OpenGL
 ●
     3D Pipeline...
Definitions
 ●
     Rendering – Process of creating the 3D image
     you see on the screen.
 ●
     Modeling – Process of...
Definitions
 ●
     Pixel – One “dot of color” in your screen.
 ●
     Vertex – It could be a coordinate in the 3D
     sp...
Definitions
 ●
     OpenGL – The cross platform standard API for
     3D graphics.
 ●
     API – Application Programming I...
●
     About me
 ●
     This talk is not about
 ●
     Introduction
 ●
     Definitions
 ●
     OpenGL
 ●
     3D Pipeline...
OpenGL
 ●
     “The Industry's Foundation for High
     Performance Graphics.”
 ●
     “From games to virtual reality, mob...
OpenGL


    OpenGL (Open Graphics Library) is a
    standard specification defining a cross-
    platform API for writing...
OpenGL
 ●
     Some considerations:
     ●
         It is a rendering API!
     ●
         OpenGL is not open source.
    ...
OpenGL
 ●
     As for this talk, we are mainly interested
     in understanding the OpenGL Rendering
     Pipeline.




Ma...
●
     About me
 ●
     This talk is not about
 ●
     Introduction
 ●
     Definitions
 ●
     OpenGL
 ●
     3D Pipeline...
3D Pipeline
 ●
     Do not be scared!
 ●
     Pipeline: “a chain of data-processing
     stages”.


     Ok. I want to dra...
3D Pipeline




                  http://www.lighthouse3d.com/opengl/glsl/index.php?pipeline

May 23, 2009      Tchelinux ...
3D Pipeline - Vertex
 ●
     Vertices are user defined (or loaded from
     a model). They define your geometry.
 ●
     N...
3D Pipeline - Transformation
 ●
     Transformation is related to changing the vertex
     position.
 ●
     It is importa...
3D Pipeline – Assembly

 ●
     So far, we only have
     vertices, coordinates.


 ●
     Besides vertices, we have also ...
3D Pipeline - Rasterization
 ●
     Very important step!


 ●
     Your eyes trick you:
     Your screen is 2D.


 ●
     ...
3D Pipeline - Interpolation
 ●
     Finally, we perform interpolation between
     the fragments.
 ●
     That is: calcula...
3D Pipeline
 ●
     That's it.


 ●




 ●
     You now have base knowledge on how it
     goes for rendering geometry, in...
3D Pipeline
 ●
     To finish with it, here is a more complete
     (and complex) pipeline model:




May 23, 2009        ...
●
     About me
 ●
     This talk is not about
 ●
     Introduction
 ●
     Definitions
 ●
     OpenGL
 ●
     3D Pipeline...
3D Rendering Topics
 ●
     Now, let's touch at some interesting
     topics in 3D rendering that are vastly
     employed...
3D Rendering Topics
 ●
     Objects can be hidden behind other
     objects.
 ●
     OpenGL does not do standard check to
...
3D Rendering Topics
 ●
     Well, this might happen:




May 23, 2009          Tchelinux 2009   34
3D Rendering Topics
 ●
     One way to do it is called Depth Testing.
 ●
     Each fragment has a depth associated to
    ...
3D Rendering Topics
 ●
     Depth testing works!




 ●
     However, you shouldn't rely on that only.
 ●
     For large s...
3D Rendering Topics
 ●
     Ok, think on this:
     Could you ever possibly see anything
     inside the building from her...
3D Rendering Topics
 ●
     Probably not.
 ●
     In this case, wouldn't it be wise to discard
     everything inside it, ...
3D Rendering Topics
 ●
     We can extend this even more:




 ●
     We can't see behind that door. We can
     discard t...
3D Rendering Topics
 ●
     This is a kind of Space Partitioning.
 ●
     It consists in knowing which parts of the
     m...
3D Rendering Topics




           Doom was only possible back then
            because of Space Partitioning!
May 23, 200...
3D Rendering Topics
 ●
     Out of hidden surfaces, another cool
     feature is Ray Tracing.
 ●
     Ray Tracing is a vec...
3D Rendering Topics




May 23, 2009          Tchelinux 2009   43
3D Rendering Topics
 ●
     Texture Mapping: consists of adding
     pictures to geometry to simulate extra
     detail.
 ...
3D Rendering Topics
 ●
     Detailed scenery?!




 ●
     Textures are a cheap way to add realism.

May 23, 2009         ...
3D Rendering Topics
 ●
     Modeling: how can models made in 3D
     modelers be added to the OpenGL
     Pipeline?




Ma...
3D Rendering Topics
 ●
     That's no OpenGL business.
 ●
     Your 3D modeler probably supports
     exporting to many di...
●
     About me
 ●
     This talk is not about
 ●
     Introduction
 ●
     Definitions
 ●
     OpenGL
 ●
     3D Pipeline...
Shaders and the “future”
 ●
     So far, we have only seen a hard defined
     3D pipeline, with well defined functions.
 ...
Shaders and the “future”
 ●
     A Shader is a piece of code which is used
     primarily to calculate rendering effects o...
Shaders and the “future”




           Cell Shading




                                           Per Pixel Lighting



...
Shaders and the “future”
 ●
     OpenGL currently supports Vertex
     Shaders and Pixel Shaders.
 ●
     Let's take a loo...
Shaders and the “future”




May 23, 2009      Tchelinux 2009    53
Shaders and the “future”
 ●
     Some sources say that Shaders are the
     future of 3D graphics.
 ●
     It is not the f...
●
     About me
 ●
     This talk is not about
 ●
     Introduction
 ●
     Definitions
 ●
     OpenGL
 ●
     3D Pipeline...
Conclusion
 ●
     The pipeline is a very important part of graphics
     rendering.
 ●
     Understanding the pipeline is...
Just in case...
 ●
     Good reference books:
     ●
         The OpenGL Superbible 4th Edition
     ●
         The OpenGL...
Thank you!



                Érico de Morais Nunes
               nunes.erico@gmail.com




May 23, 2009          Tchelin...
Upcoming SlideShare
Loading in...5
×

3D Games Rendering - Érico de Morais Nunes

705

Published on

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

No Downloads
Views
Total Views
705
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
15
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "3D Games Rendering - Érico de Morais Nunes"

  1. 1. 3D Games Rendering Érico de Morais Nunes - nunes.erico@gmail.com Universidade Federal do Pampa May 23, 2009 Tchelinux 2009 1
  2. 2. Summary ● About me ● This talk is not about ● Introduction ● Definitions ● OpenGL ● 3D Pipeline Overview ● 3D Rendering Topics ● Shaders and the “future” of 3D development ● Conclusion May 23, 2009 Tchelinux 2009 2
  3. 3. ● About me ● This talk is not about ● Introduction ● Definitions ● OpenGL ● 3D Pipeline Overview ● 3D Rendering Topics ● Shaders and the “future” of 3D development ● Conclusion May 23, 2009 Tchelinux 2009 3
  4. 4. About Me ● I am a Computer Engineering student. ● 3D Rendering is not my main research area, though I have used it in projects. ● I have been into computer graphics for around a year and a half. ● I have not produced any commercial games. ● I am a (casual) gamer. :) May 23, 2009 Tchelinux 2009 4
  5. 5. Summary ● About me ● This talk is not about ● Introduction ● Definitions ● OpenGL ● 3D Pipeline Overview ● 3D Rendering Topics ● Shaders and the “future” of 3D development ● Conclusion May 23, 2009 Tchelinux 2009 5
  6. 6. This talk is not about ● Unfortunately, this talk is not aimed at... ● NVIDIA A is better than ATI B. ● Card X runs game Y. ● How to code a game. ● How to get past level N of game X. ● It is aimed at rendering! May 23, 2009 Tchelinux 2009 6
  7. 7. ● About me ● This talk is not about ● Introduction ● Definitions ● OpenGL ● 3D Pipeline Overview ● 3D Rendering Topics ● Shaders and the “future” of 3D development ● Conclusion May 23, 2009 Tchelinux 2009 7
  8. 8. Introduction ● Games nowadays look just damn real! ● And in real time! May 23, 2009 Tchelinux 2009 8
  9. 9. Introduction ● How do they do it? May 23, 2009 Tchelinux 2009 9
  10. 10. Introduction ● We could also go a bit back... ● How did they do it, back at the days? Doom, 1993 System req: 80386 class CPU (12~40 MHz) 4 MB RAM May 23, 2009 Tchelinux 2009 10
  11. 11. Introduction ● In this talk, we shall see the science behind graphics. May 23, 2009 Tchelinux 2009 11
  12. 12. ● About me ● This talk is not about ● Introduction ● Definitions ● OpenGL ● 3D Pipeline Overview ● 3D Rendering Topics ● Shaders and the “future” of 3D development ● Conclusion May 23, 2009 Tchelinux 2009 12
  13. 13. Definitions ● Rendering – Process of creating the 3D image you see on the screen. ● Modeling – Process of generating models to render. For example, designing the characters' models in software like Blender. May 23, 2009 Tchelinux 2009 13
  14. 14. Definitions ● Pixel – One “dot of color” in your screen. ● Vertex – It could be a coordinate in the 3D space. Like the ones in math. ● Fragment – It is all the data needed to generate a pixel. Depth, color, texture coordinate... Do not confuse it with the pixel itself – you can have many fragments in a pixel space. ● Texture – Name given to an image attached to some geometry in your scene. May 23, 2009 Tchelinux 2009 14
  15. 15. Definitions ● OpenGL – The cross platform standard API for 3D graphics. ● API – Application Programming Interface. Used to provide an interface to some device. ● GPU – Graphics Processing Unit. Same as the “Graphics card”. → These definitions only aim to make quick explanations so that we can go further without major problems :) May 23, 2009 Tchelinux 2009 15
  16. 16. ● About me ● This talk is not about ● Introduction ● Definitions ● OpenGL ● 3D Pipeline Overview ● 3D Rendering Topics ● Shaders and the “future” of 3D development ● Conclusion May 23, 2009 Tchelinux 2009 16
  17. 17. OpenGL ● “The Industry's Foundation for High Performance Graphics.” ● “From games to virtual reality, mobile phones to supercomputers.” May 23, 2009 Tchelinux 2009 17
  18. 18. OpenGL OpenGL (Open Graphics Library) is a standard specification defining a cross- platform API for writing applications that produce 2D and 3D computer graphics. May 23, 2009 Tchelinux 2009 18
  19. 19. OpenGL ● Some considerations: ● It is a rendering API! ● OpenGL is not open source. (There is an open source implementation similar to it, Mesa). ● Maintained by the OpenGl ARB. ● OpenGL is the standard API used in Linux 3D rendering software. May 23, 2009 Tchelinux 2009 19
  20. 20. OpenGL ● As for this talk, we are mainly interested in understanding the OpenGL Rendering Pipeline. May 23, 2009 Tchelinux 2009 20
  21. 21. ● About me ● This talk is not about ● Introduction ● Definitions ● OpenGL ● 3D Pipeline Overview ● 3D Rendering Topics ● Shaders and the “future” of 3D development ● Conclusion May 23, 2009 Tchelinux 2009 21
  22. 22. 3D Pipeline ● Do not be scared! ● Pipeline: “a chain of data-processing stages”. Ok. I want to draw a line and a triangle. What do I need to provide and what steps are performed for it to be rendered? May 23, 2009 Tchelinux 2009 22
  23. 23. 3D Pipeline http://www.lighthouse3d.com/opengl/glsl/index.php?pipeline May 23, 2009 Tchelinux 2009 23
  24. 24. 3D Pipeline - Vertex ● Vertices are user defined (or loaded from a model). They define your geometry. ● Note that each one has an associated color. ● At games, generally, a texture is provided instead. May 23, 2009 Tchelinux 2009 24
  25. 25. 3D Pipeline - Transformation ● Transformation is related to changing the vertex position. ● It is important – when something needs to move/animate, its vertices need to be transformed! ● Transformation is defined by the user, performed by the pipeline. May 23, 2009 Tchelinux 2009 25
  26. 26. 3D Pipeline – Assembly ● So far, we only have vertices, coordinates. ● Besides vertices, we have also provided the information on how to connect them. May 23, 2009 Tchelinux 2009 26
  27. 27. 3D Pipeline - Rasterization ● Very important step! ● Your eyes trick you: Your screen is 2D. ● Rasterization: converting from the 3D space into the “plane” screen space. Fragments. May 23, 2009 Tchelinux 2009 27
  28. 28. 3D Pipeline - Interpolation ● Finally, we perform interpolation between the fragments. ● That is: calculate the color on each pixel, based on the colors at the vertices. May 23, 2009 Tchelinux 2009 28
  29. 29. 3D Pipeline ● That's it. ● ● You now have base knowledge on how it goes for rendering geometry, in a few simple steps! May 23, 2009 Tchelinux 2009 29
  30. 30. 3D Pipeline ● To finish with it, here is a more complete (and complex) pipeline model: May 23, 2009 Tchelinux 2009 30
  31. 31. ● About me ● This talk is not about ● Introduction ● Definitions ● OpenGL ● 3D Pipeline Overview ● 3D Rendering Topics ● Shaders and the “future” of 3D development ● Conclusion May 23, 2009 Tchelinux 2009 31
  32. 32. 3D Rendering Topics ● Now, let's touch at some interesting topics in 3D rendering that are vastly employed in games, such as: ● Depth Testing ● Space Partitioning ● Ray Tracing ● Texture Mapping ● Modeling May 23, 2009 Tchelinux 2009 32
  33. 33. 3D Rendering Topics ● Objects can be hidden behind other objects. ● OpenGL does not do standard check to figure out which object should be in front and which should be hidden. ● You need to find a way to do it yourself. ● What if you don't? May 23, 2009 Tchelinux 2009 33
  34. 34. 3D Rendering Topics ● Well, this might happen: May 23, 2009 Tchelinux 2009 34
  35. 35. 3D Rendering Topics ● One way to do it is called Depth Testing. ● Each fragment has a depth associated to it, resulting from rasterization ● Depth testing performs per fragment check to identify which fragment is closer to the viewer. May 23, 2009 Tchelinux 2009 35
  36. 36. 3D Rendering Topics ● Depth testing works! ● However, you shouldn't rely on that only. ● For large sceneries, checking every fragment could be very slow. :( May 23, 2009 Tchelinux 2009 36
  37. 37. 3D Rendering Topics ● Ok, think on this: Could you ever possibly see anything inside the building from here? May 23, 2009 Tchelinux 2009 37
  38. 38. 3D Rendering Topics ● Probably not. ● In this case, wouldn't it be wise to discard everything inside it, ahead of time? May 23, 2009 Tchelinux 2009 38
  39. 39. 3D Rendering Topics ● We can extend this even more: ● We can't see behind that door. We can discard that part of the map. May 23, 2009 Tchelinux 2009 39
  40. 40. 3D Rendering Topics ● This is a kind of Space Partitioning. ● It consists in knowing which parts of the map aren't visible and loading them as they appear. May 23, 2009 Tchelinux 2009 40
  41. 41. 3D Rendering Topics Doom was only possible back then because of Space Partitioning! May 23, 2009 Tchelinux 2009 41
  42. 42. 3D Rendering Topics ● Out of hidden surfaces, another cool feature is Ray Tracing. ● Ray Tracing is a vector based model which is used to, for example, model light rays and achieve high lighting and shadows realism. May 23, 2009 Tchelinux 2009 42
  43. 43. 3D Rendering Topics May 23, 2009 Tchelinux 2009 43
  44. 44. 3D Rendering Topics ● Texture Mapping: consists of adding pictures to geometry to simulate extra detail. ● For long, games have been relying in texturing to achieve some degree of realism. May 23, 2009 Tchelinux 2009 44
  45. 45. 3D Rendering Topics ● Detailed scenery?! ● Textures are a cheap way to add realism. May 23, 2009 Tchelinux 2009 45
  46. 46. 3D Rendering Topics ● Modeling: how can models made in 3D modelers be added to the OpenGL Pipeline? May 23, 2009 Tchelinux 2009 46
  47. 47. 3D Rendering Topics ● That's no OpenGL business. ● Your 3D modeler probably supports exporting to many different model formats. ● To load it into your game, you load and parse the file yourself, and pass OpenGL the raw ready data :) May 23, 2009 Tchelinux 2009 47
  48. 48. ● About me ● This talk is not about ● Introduction ● Definitions ● OpenGL ● 3D Pipeline Overview ● 3D Rendering Topics ● Shaders and the “future” of 3D development ● Conclusion May 23, 2009 Tchelinux 2009 48
  49. 49. Shaders and the “future” ● So far, we have only seen a hard defined 3D pipeline, with well defined functions. ● While this could be enough for many tasks, in order to achieve realism, you would need more flexibility. May 23, 2009 Tchelinux 2009 49
  50. 50. Shaders and the “future” ● A Shader is a piece of code which is used primarily to calculate rendering effects on graphics hardware with a high degree of flexibility. ● GLSL, HLSL, ● In your shader, you can do many cool things like... May 23, 2009 Tchelinux 2009 50
  51. 51. Shaders and the “future” Cell Shading Per Pixel Lighting May 23, 2009 Tchelinux 2009 51
  52. 52. Shaders and the “future” ● OpenGL currently supports Vertex Shaders and Pixel Shaders. ● Let's take a look on the new pipeline, with shaders in! May 23, 2009 Tchelinux 2009 52
  53. 53. Shaders and the “future” May 23, 2009 Tchelinux 2009 53
  54. 54. Shaders and the “future” ● Some sources say that Shaders are the future of 3D graphics. ● It is not the future. It is the current state of the art. ● Almost everything came down to shaders. … everything else is on its way to become a shader. May 23, 2009 Tchelinux 2009 54
  55. 55. ● About me ● This talk is not about ● Introduction ● Definitions ● OpenGL ● 3D Pipeline Overview ● 3D Rendering Topics ● Shaders and the “future” of 3D development ● Conclusion May 23, 2009 Tchelinux 2009 55
  56. 56. Conclusion ● The pipeline is a very important part of graphics rendering. ● Understanding the pipeline is on way to understand what goes on the GPU. ● Figuring out data to be discarded plays major part on performance and detailing level. ● Current games rely heavily in shaders and texturing for highly realistic graphics. May 23, 2009 Tchelinux 2009 56
  57. 57. Just in case... ● Good reference books: ● The OpenGL Superbible 4th Edition ● The OpenGL Programming Guide (The Redbook) ● OpenGL Shading Language (Orange Book) ● Good web resources for starters: ● http://www.lighthouse3d.com ● http://nehe.gamedev.net ● http://www.videotutorialsrock.com ● http://www.opengl.org May 23, 2009 Tchelinux 2009 57
  58. 58. Thank you! Érico de Morais Nunes nunes.erico@gmail.com May 23, 2009 Tchelinux 2009 58
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×