Praseed Pai

1,480 views

Published on

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

No Downloads
Views
Total views
1,480
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
11
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Praseed Pai

  1. 1. 3D Computer Graphics - a Technical Introduction AKA 3D Graphics Programming ! By Praseed Pai K.T. http://praseedp.blogspot.com [email_address]
  2. 2. Background <ul><li>UT Game Engine Release </li></ul><ul><li>Discussion in the BarCamp user Group </li></ul><ul><li>Volunteered to take a session on Graphics Programming Aspects </li></ul><ul><li>Has in the past consulted for companies in the CAD/CAM space. </li></ul><ul><li>Lack of Graphics Programmers in Kerala ( INDIA) </li></ul>
  3. 3. Computer Graphics – What the heck is it ? <ul><li>William Fetter in 1960 coined the term </li></ul><ul><li>Ivan Sutherland's Sketch Pad Thesis @ MIT </li></ul>
  4. 4. Part - 1 PIXELS !
  5. 5. What is a Pixel ? <ul><li>Pixel or Picture Element is a 32 bit integer value </li></ul><ul><li>RGBA – Red Green Blue Alpha </li></ul><ul><li>One can use an array of unsigned integers to store the pixel data. </li></ul><ul><li>Once the data is populated , we can transfer the stuff into a Windows Device Independent Bitmap. </li></ul>
  6. 6. After Pixels , what else ? <ul><li>Bresenham's Line Algorithm </li></ul><ul><li>Midpoint Circle Algorithm </li></ul><ul><li>Triangle , Rectangle , Polygon Filling </li></ul><ul><li>Copy the Stuff into the Device </li></ul>
  7. 7. Demo <ul><li>Clear the Screen Background </li></ul><ul><li>Plotting Arbitary data at a point </li></ul><ul><li>Rectangle,Triangle , Circle , Arc Rasterization demo </li></ul><ul><li>Image Point Processing ( Color to Grey Scale and Image Negative ) </li></ul><ul><li>Procedural Image </li></ul>
  8. 8. Part 2 Transformation and Matrices
  9. 9. 2D Physical Co-ordinate System
  10. 10. Transformation <ul><li>Translation </li></ul><ul><li>Rotation </li></ul><ul><li>Scale </li></ul>
  11. 11. Logical Co-ordinates
  12. 12. Demo <ul><li>A Clock Program using MFC </li></ul><ul><li>Manual co-ordinate Transformation. </li></ul><ul><li>Clock Geometry </li></ul>
  13. 13. Part 3 Finally it's 3D Time
  14. 14. 3D Co-ordinate System – Are you on the Left or Right ?
  15. 15. 3D Transformation - Translation
  16. 16. 3D Transformation - Rotate
  17. 17. 3D Transform - Scale
  18. 18. 3D Viewing - Perspective
  19. 19. 3D viewing – Perspective Matrix
  20. 20. 3D viewing - Ortho
  21. 21. 3D viewing – Ortho Matrix
  22. 22. Primitives
  23. 23. Primitives ( contd.. )
  24. 24. Jim Kajiya and his Rendering Equation
  25. 25. Lights Please
  26. 26. Rendering A scene using Global illumination
  27. 27. Numerical Evaluation of Rendering Equation <ul><li>Computationally Very Expensive </li></ul><ul><li>Monte Carlo Rendering </li></ul><ul><li>Global Illumination Algorithm </li></ul><ul><li>Radiosity , Photon Rendering , Bidirectional Path Tracing , MetroPolis Light Transport Algorithms solve the Rendering Equation to determine the Pixel Color </li></ul><ul><li>AQSIS – A RenderMan Compliant Renderer </li></ul>
  28. 28. How do i Light in a feasible manner?
  29. 29. Local Illumination Models <ul><li>Global Illumination by solving Rendering Equation is not suitable for Real Time Graphics </li></ul><ul><li>We go for Approximation algorithms to create illumination models which are close to the physically based models </li></ul><ul><li>Phong Lighting Model with Gourord Shading ( more about it later ) was the only feasible thing for real time work. </li></ul><ul><li>Thanks to GPU we can have per pixel lighting like Phong Shading. </li></ul>
  30. 30. Phong Lighting Model
  31. 31. Phong Lighting Model
  32. 32. Shading – Flat Shading <ul><li>Every Polygonal face will have same color </li></ul><ul><li>Fastest Shading Method </li></ul><ul><li>Visual Fidelity is not good </li></ul>
  33. 33. Shading – Gourord Shading <ul><li>Calculation is done per vertex </li></ul><ul><li>The Colors are interpolated </li></ul>
  34. 34. Shading – Phong Shading <ul><li>Per Pixel Lighting Calculation </li></ul><ul><li>Most Expensive </li></ul><ul><li>Feasible only on a GPU </li></ul>
  35. 35. Lights – Directional Light
  36. 36. Lights – Point Lights
  37. 37. Light – Spot Light
  38. 38. Images , so far ar synthetic .how do i add details ?
  39. 39. Texture Mapping - Adding Detail to the surface
  40. 40. Texture co-ordinates
  41. 41. Demos <ul><li>Texture Mapping an Image on to a Quad </li></ul><ul><li>Environment Mapping Demo </li></ul><ul><li>Terrain </li></ul><ul><li>MultiTexturing </li></ul><ul><li>Fog </li></ul><ul><li>Demos from Ultimate Game Programming book </li></ul>
  42. 42. Duo Who made PC a graphics Platform
  43. 43. Part 4 Procedural Techniques
  44. 44. GPU <ul><li>Aka Graphics Cards </li></ul><ul><li>Became Programmable from 1999 </li></ul><ul><li>Now one can write code using High Level Languages </li></ul><ul><li>Cg from Nvidia </li></ul><ul><li>GLSL from OpenGL ARB/Khronos </li></ul><ul><li>HLSL from Microsoft </li></ul><ul><li>Modern day GPU </li></ul>
  45. 45. Graphics Pipeline
  46. 46. Demo – Ambient Light Vertex Program //////////////////////// // // Vertex Program to Demonstrate Ambient Light // varying vec3 normal, lightDir; void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }
  47. 47. Demo – Ambient Light Fragment Processor ////////////////// // Fragment Program for Ambient Light // // varying vec3 normal, lightDir; void main() { float intensity=0.2; vec4 color= vec4(1.0,1.0,0.0,0.0); gl_FragColor = color*intensity; }
  48. 48. Rasterizing Triangle using Shaders Vertex Shader void main() { gl_Position = ftransform(); }
  49. 49. Triangle – Fragment Shader uniform vec2 v0, v1, v2; ///////////////////////////////////// // // 2D cross product; // float crs(const vec2 u, const vec2 v) { return u.x * v.y - u.y * v.x; } ///////////////////////////////////// // Main routine test whether screen pixel is // within the triangle // void main() { vec2 p = gl_FragCoord.xy; if (crs(v1 - v0, p - v0) >= 0 && crs(v2 - v1, p - v1) >= 0 && crs(v0 - v2, p - v2) >= 0) gl_FragColor = vec4(1.0,0.0,0.0,0.0); else gl_FragColor = vec4(0.5); // gl_FragColor = vec4(1.0,0.0,0.0,0.0); }
  50. 50. More Demos <ul><li>GLSL Code snippets for doing various Lighting Models </li></ul><ul><li>GLSL demo from now defunct 3D Labs inc.. </li></ul>
  51. 51. Turner Whitted and his Rendering Technique
  52. 52. Ray Tracing <ul><li>Shooting a Ray from Eye into the scene ( for every pixel we need to do this ) </li></ul><ul><li>It reverses the actual vision process to reduce the computational time.. </li></ul><ul><li>We require robust computational primitives </li></ul><ul><li>Ray Casting Demo </li></ul><ul><li>Ray Tracing Demo </li></ul><ul><li>A Discussion on POV Ray </li></ul>
  53. 53. Q & A <ul><li>THANK YOU </li></ul>

×