Ejemplo n.º 1
0
PassOwnPtr<DrawLooperBuilder> ShadowList::createDrawLooper(DrawLooperBuilder::ShadowAlphaMode alphaMode) const
{
    OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create();
    for (size_t i = shadows().size(); i--; ) {
        const ShadowData& shadow = shadows()[i];
        drawLooperBuilder->addShadow(FloatSize(shadow.x(), shadow.y()), shadow.blur(), shadow.color(),
                                     DrawLooperBuilder::ShadowRespectsTransforms, alphaMode);
    }
    drawLooperBuilder->addUnmodifiedContent();
    return drawLooperBuilder.release();
}
PassOwnPtr<DrawLooperBuilder> ShadowList::createDrawLooper(DrawLooperBuilder::ShadowAlphaMode alphaMode, const Color& currentColor, bool isHorizontal) const
{
    OwnPtr<DrawLooperBuilder> drawLooperBuilder = DrawLooperBuilder::create();
    for (size_t i = shadows().size(); i--; ) {
        const ShadowData& shadow = shadows()[i];
        float shadowX = isHorizontal ? shadow.x() : shadow.y();
        float shadowY = isHorizontal ? shadow.y() : -shadow.x();
        drawLooperBuilder->addShadow(FloatSize(shadowX, shadowY), shadow.blur(), shadow.color().resolve(currentColor),
            DrawLooperBuilder::ShadowRespectsTransforms, alphaMode);
    }
    drawLooperBuilder->addUnmodifiedContent();
    return drawLooperBuilder.release();
}
Ejemplo n.º 3
0
// does the recursive (shadow rays & recursive/glossy rays) work
Vec3f RayTracer::TraceRay(const Ray &ray, Hit &hit, int bounce_count) const
{
        hit = Hit();
        bool intersect = CastRay(ray,hit,false);

        Vec3f answer(args->background_color_linear);

        if (intersect == true) {
                const Material *m = hit.getMaterial();
                assert (m != NULL);

                // rays coming from the light source are set to white, don't bother to ray trace further.
                if (m->getEmittedColor().Length() > 0.001) {
                        answer = Vec3f(1,1,1);
                } else {
                        // ambient light
                        answer = args->ambient_light_linear *
                                 m->getDiffuseColor(hit.get_s(),hit.get_t());

                        // Shadows
                        answer += shadows(ray, hit);

                        // Reflections
                        Vec3f reflectiveColor = m->getReflectiveColor();
                        double roughness = m->getRoughness();
                        if (bounce_count > 0 && reflectiveColor.Length() > MIN_COLOR_LEN) {
                        	answer += reflectiveColor * reflections(ray, hit, bounce_count, roughness);
                        }
                }
        }

        return answer;
}
Ejemplo n.º 4
0
colour		get_the_scene(t_rt_client *rt, int x, int y)
{
  t_ray		ray;
  t_color	color;
  t_obj		*tmp;
  t_obj		*obj_result;

  tmp = rt->objs;
  obj_result = NULL;
  ray.color = &color;
  init_ray(rt, &ray, x, y);
  while (rt && tmp && tmp->color)
    {
      assign_ray(rt, &ray, tmp);
      obj_result = cast_ray(&ray, tmp, obj_result);
      tmp = tmp->next;
    }
  if (obj_result && obj_result->color)
    {
      assign_ray(rt, &ray, obj_result);
      obj_result->color->color = perlin_color(rt, &ray, obj_result);
      lighting(&ray, obj_result, rt->spot);
      shadows(rt, &ray, obj_result);
    }
  return (ray.color->color);
}
Ejemplo n.º 5
0
FloatRectOutsets ShadowList::rectOutsetsIncludingOriginal() const {
  FloatRectOutsets outsets;
  for (const ShadowData& shadow : shadows()) {
    if (shadow.style() == Inset)
      continue;
    outsets.unite(shadow.rectOutsets());
  }
  return outsets;
}
Ejemplo n.º 6
0
void		calc_color_alias(t_rt *img, t_ray *ray, t_obj *tmp)
{
  t_obj		*obj_result;

  init_alias(img, ray);
  obj_result = NULL;
  while (img && ray && tmp && tmp->color)
    {
      assign_ray(img, ray, tmp);
      obj_result = cast_ray(ray, tmp, obj_result);
      tmp = tmp->next;
    }
  if (obj_result != NULL && obj_result->color)
    {
      assign_ray(img, ray, obj_result);
      obj_result->color->color = perlin_color(img, ray, obj_result);
      lighting(ray, obj_result, img->spot);
      shadows(img, ray, obj_result);
    }
}
Ejemplo n.º 7
0
Archivo: light.c Proyecto: lnieto-m/RT
void			light(t_env *rt, t_figure object, t_light light)
{
	t_vector	n;
	t_vector	light_ray;
	double		spec;
	t_vector	vecs[2];

	light_ray = light_rotate(rt, object, light);
	if (!shadows(rt, rt->tmp_rlight, rt->inter))
	{
		n = calcul_normal(rt, object, light_ray);
		if (rt->cel_shading)
			rt->angle = calcul_cel_shading(rt->angle);
		if (rt->angle > 0.0001)
		{
			vecs[0] = n;
			vecs[1] = light_ray;
			spec = specular_light(vecs, object, rt->ambient, rt->cel_shading);
			color_light(rt, spec, object, light.color);
		}
	}
}