praseed pai
DESCRIPTION
TRANSCRIPT
![Page 1: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/1.jpg)
3D Computer Graphics - a Technical Introduction
AKA 3D Graphics Programming !
ByPraseed Pai K.T.
http://[email protected]
![Page 2: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/2.jpg)
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)
![Page 3: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/3.jpg)
Computer Graphics – What the heck is it ?
William Fetter in 1960 coined the term Ivan Sutherland's Sketch Pad Thesis @ MIT
![Page 4: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/4.jpg)
Part - 1
PIXELS !
![Page 5: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/5.jpg)
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.
![Page 6: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/6.jpg)
After Pixels , what else ?
Bresenham's Line Algorithm
Midpoint Circle Algorithm
Triangle , Rectangle , Polygon Filling
Copy the Stuff into the Device
![Page 7: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/7.jpg)
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
![Page 8: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/8.jpg)
Part 2
Transformation and Matrices
![Page 9: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/9.jpg)
2D Physical Co-ordinate System
![Page 10: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/10.jpg)
Transformation
Translation Rotation Scale
![Page 11: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/11.jpg)
Logical Co-ordinates
![Page 12: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/12.jpg)
Demo
A Clock Program using MFC Manual co-ordinate Transformation. Clock Geometry
![Page 13: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/13.jpg)
Part 3
Finally it's 3D Time
![Page 14: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/14.jpg)
3D Co-ordinate System – Are you on the Left or Right ?
![Page 15: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/15.jpg)
3D Transformation - Translation
![Page 16: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/16.jpg)
3D Transformation - Rotate
![Page 17: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/17.jpg)
3D Transform - Scale
![Page 18: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/18.jpg)
3D Viewing - Perspective
![Page 19: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/19.jpg)
3D viewing – Perspective Matrix
![Page 20: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/20.jpg)
3D viewing - Ortho
![Page 21: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/21.jpg)
3D viewing – Ortho Matrix
![Page 22: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/22.jpg)
Primitives
![Page 23: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/23.jpg)
Primitives ( contd.. )
![Page 24: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/24.jpg)
Jim Kajiya and his Rendering Equation
![Page 25: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/25.jpg)
Lights Please
![Page 26: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/26.jpg)
Rendering A scene using Global illumination
![Page 27: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/27.jpg)
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
![Page 28: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/28.jpg)
How do i Light in a feasible manner?
![Page 29: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/29.jpg)
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.
![Page 30: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/30.jpg)
Phong Lighting Model
![Page 31: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/31.jpg)
Phong Lighting Model
![Page 32: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/32.jpg)
Shading – Flat Shading
Every Polygonal face will have same color Fastest Shading Method Visual Fidelity is not good
![Page 33: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/33.jpg)
Shading – Gourord Shading
Calculation is done per vertex The Colors are interpolated
![Page 34: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/34.jpg)
Shading – Phong Shading
Per Pixel Lighting Calculation Most Expensive Feasible only on a GPU
![Page 35: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/35.jpg)
Lights – Directional Light
![Page 36: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/36.jpg)
Lights – Point Lights
![Page 37: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/37.jpg)
Light – Spot Light
![Page 38: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/38.jpg)
Images , so far ar synthetic .how do i add details ?
![Page 39: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/39.jpg)
Texture Mapping - Adding Detail to the surface
![Page 40: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/40.jpg)
Texture co-ordinates
![Page 41: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/41.jpg)
Demos
Texture Mapping an Image on to a Quad Environment Mapping Demo Terrain MultiTexturing Fog Demos from Ultimate Game Programming book
![Page 42: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/42.jpg)
Duo Who made PC a graphics Platform
![Page 43: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/43.jpg)
Part 4
Procedural Techniques
![Page 44: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/44.jpg)
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
![Page 45: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/45.jpg)
Graphics Pipeline
![Page 46: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/46.jpg)
Demo – Ambient Light Vertex Program
//////////////////////////// Vertex Program to Demonstrate Ambient Light//
varying vec3 normal, lightDir;
void main(){
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
![Page 47: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/47.jpg)
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;
}
![Page 48: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/48.jpg)
Rasterizing Triangle using ShadersVertex Shader
void main() { gl_Position = ftransform();}
![Page 49: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/49.jpg)
Triangle – Fragment Shaderuniform 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); }
![Page 50: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/50.jpg)
More Demos
GLSL Code snippets for doing various Lighting Models
GLSL demo from now defunct 3D Labs inc..
![Page 51: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/51.jpg)
Turner Whitted and his Rendering Technique
![Page 52: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/52.jpg)
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
![Page 53: Praseed Pai](https://reader033.vdocuments.mx/reader033/viewer/2022061217/54b4c7364a7959a7328b4640/html5/thumbnails/53.jpg)
Q & A
THANK YOU