next up previous contents
Next: Texture Up: Pigment Previous: Pigment Maps   Contents

Camera-is-a-Pigment principle

A camera can be used everywhere a pigment can be used. Actually the camera is like an image-plane mapped to the xy-plane. The difference is that the camera has an infinit resolution because the colour is only evaluated when and where it is needed. This also allows multiple scenes for different cameras in the same rendering.

The render process consists of evaluating the main scene's pigment (normally a camera) in the (0,0)-(1,1) range. You can also change the main scene's pigment to not be a plain camera but some mapped pigment, e.g. two cameras in a checker pattern.

Recusive camera example:

Pigment3D* setUpScene_RecCamera() {

  Scene* s = new Scene();

  CameraPerspective* c = new CameraPerspective(s);

  Object3D* sp = new Box(Vector3(0),Vector3(1,1,0.01));
  sp->scale(Vector3(2));
  sp->rotate(Vector3(-1,-35,0));
  sp->translate(Vector3(-2,0,4));
  sp->setPigment(*c);
  sp->setFinish(Finish(1,0,0,0,0));
  s->addObject(sp);

  Pigment3DMapped check = Pigment3DMapped(new Checker());
  check.insertCol(0,Colour3(1,0,0));
  check.insertCol(1,Colour3(0,0,1));

  sp = new Box(Vector3(-.1,-.1,.01),Vector3(1.1,1.1,0.2));
  sp->scale(Vector3(2));
  sp->setPigment(Pigment3DConstant(Colour5(0,1,0,0,0)));
  sp->rotate(Vector3(-1,-35,0));
  sp->translate(Vector3(-2,0,4));
  s->addObject(sp);

  sp = new Plane(Vector3(0,1,0));
  sp->translate(Vector3(0,-2,0));
  sp->setPigment(check);
  s->addObject(sp);

  sp = new Plane(Vector3(0,0,1));
  sp->translate(Vector3(0,0,10));
  sp->setPigment(Pigment3DConstant(Colour3(1)));
  s->addObject(sp);

  PointLight* l = new PointLight(Vector3(0,0,0),Colour3(1),s);
  s->addLight(l);

  Material3D m = Material3D(new Texture3D(new Pigment3DConstant(Colour5(0)), new Finish(0.1,0.6,0,0,0)), new Interior() );
  s->setDefaultMaterial(m);

  return c;

}

Blending between two different cameras:

Pigment3D* setUpScene_BlendCamera() {

    Pigment3D* s1 = setUpScene_Isosurface();
    Pigment3D* s2 = setUpScene_Menger();

    Pigment3DMapped* imap = new Pigment3DMapped(new Gradient(Vector3(1,0,0)));
    imap->insert(0,s1);
    imap->insert(1,s2);

    return imap;

}



Micha Riser 2002-10-24