View Full Version : how to generate ray form pixel coords
09-10-2008, 11:33 PM
In the ray tracing,it said that generate a ray of per pixel form pixel screen coord.
but how to compute.I cann`t found anywhere introduction for this
09-11-2008, 12:40 AM
A ray , as far as i know, is defined as
r = r0 + s*t
where r0 is a origin vector and t a vector to the destination. I think you can use your camera position as r0 and a destination vector. So you can build a ray r, from r0 to t.
r0 points to the "Point" in space where your ray starts. and t is a point along your ray.
09-11-2008, 05:05 PM
thanks,i know that and my means is how determinate the ray dir("s" in up equation of you wrote) through pixel screen coord.
09-12-2008, 01:15 AM
Hi, s is just a point in space. For instance, if you want to send a
ray from your view along your viewing direction you can say that
r0 is the position of your camera and s the point where your camera looks at. If you use glLookAt you can easy imagine.
glLookAt uses 4 vectors (?). The camera position and 3 vectors
that describe the camera's alignment. These are the up vector,
the direction vector and the right vector. The direction vector is build from camera position and the point where you want to look at.
In this case we can say it's also a ray that goes from your camera position to the point where you want to look at.
For example you camera is at (0,5,0) and your point you want to look at is (2,0,2) then your view vector (resp. ray) is
(2,0,2) - (0,5,0) = (2,-5,2)
Btw. s is just a scalar. it can be 1.
09-12-2008, 08:04 PM
In the chapater <<Implementing Ray Tracing on GPU>>
it calculate the primary ray form pixel coord as this:
vec3 raydir(vec2 pixelpos)
vec3 _upvec; // camera: up-vector
vec3 _right; // camera: vector to the right
vec3 _tl; //camera: vector to the "virtual screen" top left
float _pixelsize; // pixel size of the "virtual screen"
float psize; // Size of a pixel in texture coordinates
vec3 camera_pos; // camera position
I not determinate what means of "_right" and "_tl",such as "binormal" and "tangent" in the tangent space?
And why compute as this?
My confused is there`s no pixel position information in your method for ray
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.