Skip to content
Lucas Dupont edited this page May 14, 2023 · 3 revisions

How to use this beautiful raytracer

Command line

To use raytracer, enter this command

./raytracer <config_file>

Config file

To use raytracer you need to use a config file.

This is an example of config file with simple sphere and simple light

settings:
{
    threads = 10;
    sample_per_pixel = 50;
}

camera:
{
    screen = {
        width = 500;
        height = 500;
    };
    position = {x = 0.0; y = 0.0; z = 0.0};
    rotation = {x = 0.0; y = 0.0; z = 0.0};
    fov = 90;
}

scenes = ("config/scene3.cfg", "config/scene4.cfg");

primitives:
{
    sphere = (
        {
            position = {x = 1.0; y = 5.0; z = -8.0};
            rotation = {x = 0.0; y = 0.0; z = 0.0};
            radius = 0.5;
            material = {
                type = "lambertian";
                color = {r = 255; g = 0; b = 0};
            };
        }
    )
};

lights:
{
    ambient = (
        {
            color = {r = 255; g = 255; b = 255};
            intensity = 0.7;
        }
    )
};

You can see 4 main categories:

  • settings: This category allows you to set some parameters concerning the generation

    • threads: Number of threads used by the raytracer. Each thread is used to generate part of the image. The width of the scene must be able to be divided by the number of threads without remainder. If not, the set of threads might not be used. How many max threads can I use?
    • sample_per_pixel: Resolve Multiplier
  • camera: This category is for all camera settings

    • screen:
      • width: Width of the rendered image
      • height: Height of the rendered image
    • position: Position of the camera relative to the scene
    • rotation: Camera rotation relative to 0, 0, 0
    • fov: Field of view
  • scenes: This section is not mandatory. It allows other configuration files to be included in the current one. The camera and settings are not affected by this import.

  • primitives: List of all primitives. Each primitive has its own parameters. See the primitives wiki pages for more information.

  • lights: List of all lights. Each light has its own parameters. See the lights wiki pages for more information.

Clone this wiki locally