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

Praseed Pai

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