예제 #1
0
파일: core.c 프로젝트: Siyanda-Mzam/rt
static inline t_color	soft_shadows(t_params p, t_ray *r, t_objects *s, int j)
{
	int		x;
	int		y;
	t_vec3f	w;
	t_color	trans;
	t_vec3f	tmp;
	t_vec3f	lp;

	trans = new_uni_color((x = 0));
	while (x < 5 && !(y = 0))
	{
		while (y < 5)
		{
			tmp = new_vec3f(x, 0, y);
			lp = add_vec3f(&s->store[j].pos, &tmp);
			if (sharp_shadows(p, r, s,
				normalize_vec3f(sub_vec3f(&lp, &p.phit))).x != 0)
			{
				w = new_vec3f(1 / 25., 1 / 25., 1 / 25.);
				trans = add_vec3f(&trans, &w);
			}
			y++;
		}
		x++;
	}
	return (trans);
}
예제 #2
0
파일: app_environ.c 프로젝트: May4m/RT
void		cast_ray(int x, int y, t_vec3f *pixel, t_interface *env)
{
	t_vec3f	dir;
	t_ray	ray;
	t_f64	xx;
	t_f64	yy;

	xx = (2 * ((x + 0.5) * (1.0 / WIDTH)) - 1) * env->camera.angle * ARATIO;
	yy = (1 - 2 * ((y + 0.5) * (1.0 / HEIGHT))) * env->camera.angle;
	dir = new_vec3f(xx, yy, 0);
	dir = add_vec3f(&dir, &env->camera.up);
	ray = new_ray(env->camera.pos, normal_vec3f(&dir));
	*pixel = trace_ray(&ray, env->objects, 0);
}