Beispiel #1
0
/*********************************************************************
 * This function traverses all the pixels and cast rays. It calls the
 * recursive ray tracer and assign return color to frame
 *
 * You should not need to change it except for the call to the recursive
 * ray tracer. Feel free to change other parts of the function however,
 * if you must.
 *********************************************************************/
void ray_trace() {
	int i, j;
	float x_start = -0.5 * image_width;
	float y_start = -0.5 * image_height;
	RGB_float ret_color;
	Point cur_pixel_pos;

	Vector ray;

	// ray is cast through center of pixel
	cur_pixel_pos.x = x_start + 0.5 * x_grid_size;
	cur_pixel_pos.y = y_start + 0.5 * y_grid_size;
	cur_pixel_pos.z = image_plane;

	for (i=0; i<win_height; i++) {
		for (j=0; j<win_width; j++) {

			ray = get_vec(eye_pos, cur_pixel_pos);
			ret_color = recursive_ray_trace(ray, eye_pos, 0);
			if(supersampling_on) //supersampling
			{
				ret_color = supersample(cur_pixel_pos, ray, ret_color);
			}
			frame[i][j][0] = GLfloat(ret_color.r);
			frame[i][j][1] = GLfloat(ret_color.g);
			frame[i][j][2] = GLfloat(ret_color.b);

			cur_pixel_pos.x += x_grid_size;
		}
	cur_pixel_pos.y += y_grid_size;
	cur_pixel_pos.x = x_start;
	}
}
Beispiel #2
0
void process(const image   *src,
             const image   *dst,
             const pattern *pat,
             const float   *rot,
             filter fil, to_img img, to_env env, int n)
{
    int i;
    int j;
    int f;

    /* Sample all destination rows, columns, and pages. */

    #pragma omp parallel for private(j, f)
    for         (i = 0; i < dst->h; i++)
        for     (j = 0; j < dst->w; j++)
            for (f = 0; f <      n; f++)
                supersample(src, dst, pat, rot, fil, img, env, f, i, j);
}