Example #1
0
Scene* create_test_scene_sphere() {
    auto camera             = new Camera();
    camera->frame           = frame3f(z3f*2.5,x3f,y3f,z3f);
    camera->focus           = 2.5f;
    
    auto light_point        = new Light();
    light_point->frame      = frame3f(z3f*5,x3f,y3f,z3f);
    light_point->intensity  = one3f*10;
    
    auto surf_sphere        = new Surface();
    surf_sphere->mat        = new Material();
    surf_sphere->mat->n     = 100;
    
    auto scene              = new Scene();
    scene->background       = one3f*0.2;
    scene->ambient          = one3f*0.2;
    scene->image_width      = 512;
    scene->image_height     = 512;
    scene->image_samples    = 1;
    scene->camera           = camera;
    scene->surfaces         = { surf_sphere };
    scene->lights           = { light_point };
    
    scene->path_max_depth = 2;
    
    return scene;
}
Example #2
0
Scene* create_test_scene_sphereplane() {
    // sphere, plane, and shadows
    auto camera            = new Camera();
    camera->frame          = frame3f(z3f*4,x3f,y3f,z3f);
    camera->focus          = 4.0f;
    
    auto light_point       = new Light();
    light_point->frame     = frame3f({6,12,6},x3f,y3f,z3f);
    light_point->intensity = one3f*100;
    
    auto surf_plane        = new Surface();
    surf_plane->frame      = frame3f(-y3f,x3f,-z3f,y3f);
    surf_plane->radius     = 100;
    surf_plane->isquad     = true;
    surf_plane->mat        = new Material();
    surf_plane->mat->kd    = one3f;
    surf_plane->mat->ks    = zero3f;
    surf_plane->mat->n     = 100;
    surf_plane->mat->kr    = one3f*0.25f;
    
    auto surf_sphere       = new Surface();
    surf_sphere->frame     = identity_frame3f;
    surf_sphere->radius    = 1;
    surf_sphere->isquad    = false;
    surf_sphere->mat       = new Material();
    surf_sphere->mat->kd   = {1,0.75,0.75};
    surf_sphere->mat->ks   = zero3f;
    surf_sphere->mat->n    = 100;
    surf_sphere->mat->kr   = zero3f;
    
    auto surf_light         = new Surface();
    surf_light->frame       = frame3f({60,120,60},x3f,y3f,z3f);
    surf_light->radius      = 1.0f;
    surf_light->mat         = new Material();
    surf_light->mat->kd     = zero3f;
    surf_light->mat->ks     = zero3f;
    surf_light->mat->ke     = vec3f(1,1,1.1)*10000;
    
    auto scene             = new Scene();
    scene->background      = one3f*0.2f; //one3f*0.2;
    scene->ambient         = zero3f; //one3f*0.2;
    scene->image_width     = 512;
    scene->image_height    = 512;
    scene->image_samples   = 8;
    scene->camera          = camera;
    scene->surfaces        = { surf_plane, surf_sphere, surf_light };
    scene->lights = {};
    //scene->lights          = { light_point };
    
    scene->path_max_depth = 16;
    scene->path_sample_brdf = true;
    
    return scene;
}
Scene* create_test_scene_cyl() {
    // sphere, plane, and shadows
    auto camera            = new Camera();
    camera->frame          = frame3f(z3f*4,x3f,y3f,z3f);

    auto light_point       = new Light();
    light_point->frame     = frame3f({6,12,6},x3f,y3f,z3f);
    light_point->intensity = one3f*100;

    auto surf_plane        = new Surface();
    surf_plane->frame      = frame3f(-y3f,x3f,-z3f,y3f);
    surf_plane->radius     = 100;
    surf_plane->isquad     = true;
    surf_plane->mat        = new Material();
    surf_plane->mat->kd    = one3f;
    surf_plane->mat->ks    = zero3f;
    surf_plane->mat->n     = 100;
    surf_plane->mat->kr    = zero3f;

//    auto surf_sphere       = new Surface();
//    surf_sphere->frame     = identity_frame3f;
//    surf_sphere->radius    = 1;
//    surf_sphere->isquad    = false;
//    surf_sphere->iscyl     = true;
//    surf_sphere->mat       = new Material();
//    surf_sphere->mat->kd   = {1,0.75,0.75};
//    surf_sphere->mat->ks   = zero3f;
//    surf_sphere->mat->n    = 100;
//    surf_sphere->mat->kr   = zero3f;

    auto surf_cyl          = new Surface();
    surf_cyl->frame     = identity_frame3f;
    surf_cyl->radius    = 1;
    surf_cyl->isquad    = false;
    surf_cyl->iscyl     = true;
    surf_cyl->mat       = new Material();
    surf_cyl->mat->kd   = {1,0.75,0.75};
    surf_cyl->mat->ks   = zero3f;
    surf_cyl->mat->n    = 100;
    surf_cyl->mat->kr   = zero3f;

    auto scene             = new Scene();
    scene->background      = one3f*0.2;
    scene->ambient         = one3f*0.2;
    scene->image_width     = 512;
    scene->image_height    = 512;
    scene->image_samples   = 1;
    scene->camera          = camera;
    scene->surfaces        = { surf_plane, surf_cyl };
    scene->lights          = { light_point };

    return scene;
}