Exemplo n.º 1
0
t_color		compute_light(t_scene *scene, t_ray *ray)
{
	t_list	*current;
	t_ray	lray;
	t_color	color[3];
	t_phpa	ph;

	current = scene->lights;
	ph.normal = get_normal(*ray);
	set_ambiant_light(&ph, scene, ray, color);
	while (current)
	{
		lray.pos = ((t_light *)current->content)->pos;
		lray.dir = norm_vect(mtx_add(mtx_sub(mtx_mult(ray->dir, ray->t),
			lray.pos), ray->pos));
		lray.invdir = get_inv_vect(&lray.dir);
		if (find_closest(scene, &lray) && ray->closest == lray.closest
			&& near_enough(ray, &lray))
		{
			set_params(&ph, &lray, ray);
			ph.camera = scene->camera;
			ph.light = (t_light *)current->content;
			phong(&ph);
		}
		current = current->next;
	}
	set_color_max(&ph);
	return (*color);
}
Exemplo n.º 2
0
 bool operator==(const vec3& l, const vec3& r)
 {
   return near_enough(l, r);
 }