Pbrt 2: How does LookAt work?
Posted: Mon Jan 19, 2015 10:13 am
Currently I am reading the PBRT 2 book. Now I am a bit confused about the LookAt function.
I placed a sphere at (0, 0, 0) – since I want to look at this sphere I want to place the eye point at (0, 0, -5) and want to look at (0, 0, 0). The up-vector should be (0,1,0)
I tried this:
The ray looks like this
r.orgin = o = {x=0.000000000 y=0.000000000 z=5.00000000 }
r.direction = d = {x=0.000000000 y=0.000000000 z=1.00000000 }
Actually I expected the ray origin at Point(0, 0, -5) and not (0, 0, 5) since in world space the ray should start at z = -5. Any ideas what I am doing wrong?
I placed a sphere at (0, 0, 0) – since I want to look at this sphere I want to place the eye point at (0, 0, -5) and want to look at (0, 0, 0). The up-vector should be (0,1,0)
I tried this:
Code: Select all
BoxFilter b(1,1);
float screen[4];
screen[0] = -1.f;
screen[1] = 1.f;
screen[2] = -1.f;
screen[3] = 1.f;
ImageFilm film(100, 100, &b, screen, "muh.exr",false);
auto t = LookAt(
Point(0, 0, -5),
Point(0, 0, 0),
Vector(0, 1, 0));
AnimatedTransform cam2world(
&t,
0.0f,
&t,
10.0f
);
PerspectiveCamera p(cam2world, screen,
0, 0, 0, 0, 55.0f, &film);
CameraSample s;
s.imageX = 50;
s.imageY = 50;
s.time = 0;
s.lensU = 0;
s.lensV = 0;
Ray r;
p.GenerateRay(s, &r);
r.orgin = o = {x=0.000000000 y=0.000000000 z=5.00000000 }
r.direction = d = {x=0.000000000 y=0.000000000 z=1.00000000 }
Actually I expected the ray origin at Point(0, 0, -5) and not (0, 0, 5) since in world space the ray should start at z = -5. Any ideas what I am doing wrong?