Skip to content

Latest commit

聽

History

History
72 lines (60 loc) 路 1.86 KB

doc.md

File metadata and controls

72 lines (60 loc) 路 1.86 KB

馃摑 Documentation

Our Ray Tracer works with a scene where we render objects we can create objects on a given position. We use the add method on scene to add the objects to the scene.

Creating Objects

For creating Object we have 4 types of object and 3 type of material for each object. The material are : Lambertian, Metal, Dielectric. We can also change the color of each objects.

Sphere

let sphere = Sphere::new(
        Vec3::new(0.0, 1.0, 0.0),
        1.0,
        Arc::new(Metal::new(Vec3::new(0.0, 0.250, 0.0), 0.3)))

Cube

let cube = Cube::new(
        Vec3::new(0.0, 1.0, 0.0),
        Vec3::new(2.0, 1.0, 1.0) * 1.5,
        Arc::new(Metal::new(Vec3::new(0.0, 0.302, 0.278), 0.3)),
    )

Flat Plane

We can make a plane with texture and without texture

let checker = Arc::new(Lambertian::new_with_texture(CheckerTexture::new(
        Vec3::new(0.2, 0.3, 0.1),
        Vec3::new(0.9, 0.9, 0.9),
        10.0,
    )));
    scene.add(Box::new(Plane::new(checker)));

Cylinder

let cylinder = Cylinder::new(
        Vec3::new(-1., 0.2, 2.0),
        0.5,
        1.0,
        Arc::new(Metal::new(Vec3::new(0.0, 0.302, 0.278), 0.8)),
    )

Adjusting brightness

scene.set_brightness(level);

Camera

The camera has 5 parameters we can adjust to see the scene from a different perspectives.

  1. The position where from where we see (lookfrom)
  2. The position where we look at (lookat)
  3. The position of the camera on the y-axis
  4. Vertical field-of-view in degrees (vfov)
  5. The aspect ratio
 let camera_setting = (
        Vec3::new(13.0, 3.0, 1.0), //lookfrom
        Vec3::new(0.0, 1.0, 0.0), //lookat
        Vec3::new(0.0, 1.0, 0.0), // y-axis
        20.0, // Vfov 
        3.0 / 2.0 , 
    );
    let mut scene = Scene::new(camera_setting);
    scene.add(Box::new(OBJECT));