Homework #2 Coordinate Systems
Homework #2 Coordinate Systems
Homework #2 Coordinate Systems
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Homework</strong> <strong>#2</strong><br />
CSE 872 Fall 2011<br />
1<br />
<strong>Coordinate</strong> <strong>Systems</strong><br />
Object coordinates<br />
World coordinates<br />
Camera(eye, image) coordinates<br />
Perspective <strong>Coordinate</strong>s<br />
(Normalized device coordinates)<br />
Screen <strong>Coordinate</strong>s<br />
(Window coordinates)<br />
CSE 872 Fall 2011<br />
2
Within OpenGL<br />
Object<br />
<strong>Coordinate</strong>s<br />
CSE 872 Fall 2011<br />
Modelview<br />
Matrix<br />
Eye coordinates<br />
Projection<br />
Matrix<br />
Clip coordinates<br />
glBegin(GL_POLYGON);<br />
glVertex3dv(a);<br />
glVertex3dv(b);<br />
glVertex3dv( c);<br />
glEnd();<br />
Homogenize<br />
Window to<br />
Viewport<br />
Normalized device coordinates<br />
Viewport<br />
coordinates<br />
3<br />
Object <strong>Coordinate</strong>s<br />
Convenient place to model the<br />
object<br />
O<br />
CSE 872 Fall 2011<br />
4
World <strong>Coordinate</strong>s<br />
Common coordinates for the scene<br />
O<br />
O<br />
W<br />
CSE 872 Fall 2011<br />
5<br />
Camera <strong>Coordinate</strong>s<br />
<strong>Coordinate</strong> system with the camera<br />
in a convenient pose<br />
v<br />
n<br />
u<br />
X<br />
iw<br />
⎡ux<br />
⎢<br />
⎢<br />
vx<br />
=<br />
⎢nx<br />
⎢<br />
⎣ 0<br />
u<br />
v<br />
n<br />
y<br />
y<br />
y<br />
0<br />
u<br />
v<br />
n<br />
z<br />
z<br />
z<br />
0<br />
− r ⋅u⎤<br />
− r ⋅ v<br />
⎥<br />
⎥<br />
− r ⋅n⎥<br />
⎥<br />
1 ⎦<br />
CSE 872 Fall 2011<br />
6
Camera <strong>Coordinate</strong>s<br />
Normalize<br />
Normalize<br />
CSE 872 Fall 2011<br />
7<br />
Normalized Device <strong>Coordinate</strong>s<br />
Device independent coordinates<br />
Visible coordinate usually range<br />
from: (d is focal length)<br />
−1<br />
≤ x ≤1<br />
−1<br />
≤ y ≤1<br />
0 ≤ z ≤1<br />
CSE 872 Fall 2011<br />
8
Perspective Projection<br />
Taking the camera coordinates to<br />
NDC<br />
z<br />
FOV<br />
x<br />
CSE 872 Fall 2011<br />
9<br />
Window <strong>Coordinate</strong>s<br />
Adjusting the NDC to fit the window<br />
( x0,<br />
y0)<br />
is the lower left of the window<br />
[In hw2, only screen coordinates are in RHC]<br />
⎛ width ⎞<br />
xw<br />
= ( xnd<br />
+ 1) ⎜ ⎟ + x0<br />
⎝ 2 ⎠<br />
⎛ height ⎞<br />
yw<br />
= ( −ynd<br />
+ 1) ⎜ ⎟ + y0<br />
⎝ 2 ⎠<br />
CSE 872 Fall 2011<br />
10
APIs<br />
Render constructor<br />
- setup Xsp and anything only done once<br />
- init default camera<br />
Begin<br />
-compute Xiw<br />
- projection xform Xpi from camera definition<br />
- init Ximage - put Xsp at base of stack, push on<br />
Xpi and Xiw<br />
CSE 872 Fall 2011<br />
11<br />
Lighting and Shading<br />
Step 2: Phong illumination<br />
Simplifications<br />
L is constant for directional light<br />
E is view direction (0, 0, -1)<br />
N transformed by X_norm<br />
<br />
CSE 872 Fall 2011<br />
12
Shading issues<br />
Deal with backward faces<br />
Watch for color overflow<br />
Color interpolation<br />
Gouraud shading<br />
Normal interpolation<br />
Phong shading<br />
Xnorm--- Xsp and Xpi == Id<br />
Rotation only<br />
CSE 872 Fall 2011<br />
13<br />
Screen-Space Interpolation Correction<br />
glHint(gl_perspective_correction_hint,…)<br />
Interpolation in screen space<br />
Pixels are linearly interpolated<br />
Parameters should not…(division is costly tho)<br />
<br />
u, v texture coords, colors, normals, …<br />
Correction every 16 pixel<br />
[Mikael Kalms ]<br />
CSE 872 Fall 2011<br />
Interpolate Ps, Convert to P using Zs<br />
14
Texture Mapping (Step3)<br />
Bilinear interpolation<br />
Modulate color by texture<br />
CSE 872 Fall 2011<br />
15