praseed pai
DESCRIPTION
TRANSCRIPT
3D Computer Graphics - a Technical Introduction
AKA 3D Graphics Programming !
ByPraseed Pai K.T.
http://[email protected]
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 ShadersVertex Shader
void main() { gl_Position = ftransform();}
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); }
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