L11 Handout
L11 Handout
Understanding Rendering
Process in XR
Dr. Samit Bhattacharya
Dept. of Comp. Sc. & Engg.,
IIT Guwahati
Our Objective
Space-partitioning
Representing region with set of non-overlapping,
contiguous solids (usually cubes)
Mesh
Connected set of
polygons (usually
triangles)
Curve Representation
Translation
Rotation
Scale
Shear
Matrix Representation
x' a b x x' ax by
y ' c d y y ' cx dy
Basic 2D Transformations
x ' 1 0 t x x x ' s x 0 0 x
y ' 0 1 t y y ' 0
y
sy 0 y
1 0 0 1 1 1 0 0 1 1
Translate Scale
x' 1 0 0 0 x x ' s x 0 0 0 x
y ' 0 1 0 0 y y ' 0 0 y
z ' 0 sy 0
0 1 0 z
w 0 0 0 1 w z' 0 0 sz 0 z
Identity w 0 0 0 1 w
Scale
x ' 1 0 0 t x x
y ' 0 x' 1 0 0 0 x
1 0 t y y y ' 0 1 0 0 y
z ' 0 0 1 tz z z' 0 0 1 0 z
w 0 0 0 1 w
w 0 0 0 1 w
Mirror about Y/Z plane
Translation
Basic 3D Transformations
x' 1 0 0 0 x
y ' 0 cos sin 0 y
z ' 0 sin cos
Rotate around X axis:
0 z
w 0 0 0 1 w
Issue
Translation matrix
Procedure
Third Step –
obtain new
coordinate
position
Multiply
current
vertices with
composite
matrix
Procedure
Important components
Ambient light
Diffuse reflection
Specular reflection
I ambdiff k d I a
Diffuse Reflection
I diff k d I s cos
Diffuse Reflection
N = surface normal,
L = unit direction
vector to the light source
Then, N L cos
Thus,
k d I s ( N L ) if N L 0
I diff
0 if N L 0
Specular Reflection
I spec k s I s cos ns
k s I s (V R ) ns if V R 0 and N L 0
I spec
0.0 if V R 0 or N L 0
Computing color
I1/I0=I2/I1=…=In/In-1 = r
I0=I0
Ik = rkI0, k > 0
ex: B/W monitor with 8 I1 = rI0
bits/pixel
I2 = rI1 = r2I0
n = 255
r = 1.0182 (typical)
…
I0 = 0.01 (say)
Ints = 0.0100. 0.0102, I255=rI254=r255I0
0.0104…1…
Assign 256 bit patterns to
the 256 intensities
Intensity – IM to Device
Center of interest
Also called look-at point
Converge at a center of
projection (perspective
projection)
Perspective projection –
view volume is a frustrum
Parallel Projection
x ' ' 1 0 0 0 x
y ' ' 0 1 0 0 y
z ' ' 0 0 0 d z
w 0 0 0 1 1
x' ' 1 0 0 0 x
y ' ' 0 1 0 0 y
z ' ' 0 0 1
0 z
0 0
1
0 1
w d
Viewport Transformation
Transform from projection coordinates
(normalized clipping window) to device
coordinates
Window vs Viewport
Window
World-coordinate area selected for display
What is to be viewed
Viewport
Area on the display device to which a window is
mapped
Where it is to be displayed
Viewport Transformations
Transformation matrix,
sx o tx
M WV 0 sy ty
0 0 1
We must determine
what is visible within a
scene from a chosen
viewing position
Note
Circle rendering
Curve rendering
Surface rendering
Character rendering
Anti-aliasing (to make the rendering smooth)
Transformation = multiplication of
transformation matrix with vertex
vector
Same vector-matrix multiplication
done for all vertices we want to
transform
Need for Parallelism
Consider geometric
transformation of vertices
Instruction (multiplication)
same; data (vertex vectors)
varies
Instance of single instruction
multiple data (SIMD)
GPU
Organization
Each SM
designed to
perform SIMD
operations
How It Works
Most real-time
graphics systems
assume scene
made of triangles
Surfaces such as
quadrilaterals or
curved surface
converted to meshes
How It Works
Through APIs
supported in graphics
library
(OpenGL/Direct3D),
triangles sent to GPU
one vertex at a time
GPU assembles
vertices into triangles
How It Works
Vertices expressed with
homogeneous coordinates
Objects they define
represented in
local/modeling coordinate
GPU performs modeling
transformations on vertices
How It Works
Transformation
(single/composite)
achieved with a
single matrix
(transformation)-
vector (point)
multiplication
How It Works
Multicore GPU
perform multiple
such operations
simultaneously -
multiple vertices
simultaneously
transformed
How It Works
Output - stream of
triangles
In world coordinate
system
Viewer located at the
origin and view direction
aligned with z-axis
How It Works
Next - GPU computes vertex
color based on light defined for
the scene
Recall color can be
computed by vector dot
products and a series of add
and multiply operations
GPU performs simultaneously
for multiple vertices
How It Works
Next stage - each
colored 3D vertex
projected onto the view
plane
GPU does this using matrix-
vector multiplication
Output - stream of triangles
in screen/device
coordinates, ready to be
converted to pixels
How It Works
During pixel
processing stage,
two more activities
take place
Surface texturing
Hidden surface
removal
How It Works
Simplest surface
texturing method -
texture images
draped over
geometry to give
illusion of detail
Pixel color replaced
by texture color
How It Works
GPUs store textures in high-
speed memory
Each pixel calculation must
access it
Access very regular (nearby
pixels tend to access nearby
texture image locations) -
specialized memory caches
to reduce access time
How It Works
GPUs implement
depth(Z)-buffer
algorithm for HSR
All modern-day GPUs
contain depth-buffer as
dedicated memory
Stores distance of
viewer from each pixel
How It Works