Exemplo n.º 1
0
static void Matrix4x4Mult(benchmark::State& state) {
    Transform xf1 = makeRotation(0.3, Vector4(0.2, 0.3, 0.4));
    Transform xf2 = makeRotation(0.6, Vector4(0.9, 0.2, 0.1));
    for (auto _ : state) {
        benchmark::DoNotOptimize(mult(xf1.fwd, xf2.fwd));
    }
}
Exemplo n.º 2
0
static void Matrix4x4Vector4Mult(benchmark::State& state) {
    Transform xf = makeRotation(0.3, Vector4(0.2, 0.3, 0.4));
    Vector4 v(2.0, 4.0, 0.3);
    for (auto _ : state) {
        benchmark::DoNotOptimize(mult(xf.fwd, v));
    }
}
Exemplo n.º 3
0
void TestScene::setup()
{
    logger.normalf("Creating image tracer %d x %d, %d frames, %d rays per pixel",
                   image_width, image_height, anim_frames, rays_per_pixel);
    logger.normalf("Output directory: %s", output_dir.c_str());

    tracer = new ImageTracer( image_width, image_height,
                              anim_frames, rays_per_pixel );

#if 0
    // Create a subdirectory in the output directory named with the test name, and put standard
    // output files in there
    tracer->artifacts.output_path = output_dir + "/" + name;
    mkdir(tracer->artifacts.output_path.c_str(), 0777);
    tracer->artifacts.file_prefix = "";
#else
    // Prefix each output file with the test name and put them in the output directory
    tracer->artifacts.output_path = output_dir;
    tracer->artifacts.file_prefix = name + "_";
#endif

    tracer->shader = new BasicDiffuseSpecularShader();

    tracer->setCameraTransform( compose(
        // move up a bit
        makeTranslation( 0.0, 0.5, 0.0 ),
        // rotate so we are looking down
        makeRotation( -0.2, Vector4(1, 0, 0) ),
        // back away from the origin
        makeTranslation( 0.0, 0.0, 10.0 )
        ) );
}
Exemplo n.º 4
0
void addTransformedCubes( std::shared_ptr<Container> container )
{
    // Offset cubes for testing AO
    float cube_size = 0.2;
    auto cube1 = std::make_shared<AxisAlignedSlab>( 0.0, 0.0, 0.0,
                                                   cube_size );
    auto cube2 = std::make_shared<AxisAlignedSlab>( 0.0, 0.0, 0.0,
                                                    cube_size );
    auto cube3 = std::make_shared<AxisAlignedSlab>( 0.0, 0.0, 0.0,
                                                    cube_size );

    cube1->material = std::make_shared<DiffuseMaterial>( 1.0, 0.0, 0.0 );
    cube2->material = std::make_shared<DiffuseMaterial>( 0.0, 0.0, 1.0 );
    cube3->material = std::make_shared<DiffuseMaterial>( 0.0, 1.0, 0.0 );

    cube1->transform = std::make_shared<Transform>();
    *cube1->transform = makeTranslation( Vector4( 0.1, 0.5, -1.0 ) );

    cube2->transform = std::make_shared<Transform>();
    *cube2->transform = 
        compose(
            makeTranslation( Vector4( 0.0, 0.15, -1.0 ) ),
            compose( 
                makeRotation( M_PI / 4.0, Vector4( 0.0, 1.0, 0.0 ) ),
                makeRotation( M_PI / 4.0, Vector4( 0.0, 0.0, 1.0 ) )
                )
            );

    cube3->transform = std::make_shared<Transform>();
    *cube3->transform = 
        compose(
            makeTranslation( Vector4( -0.3, 0.0, -1.0 ) ),
            makeScaling( 0.2, 3.0, 2.0 )
            );

    container->add( cube1 );
    container->add( cube2 );
    container->add( cube3 );

    addSphereLight( container,
                    Vector4( 3.0, 3.0, -1.0 ), 0.5,
                    RGBColor( 1.0, 1.0, 1.0 ), 200.0 );

    addGroundPlane( container );
}
Exemplo n.º 5
0
void testCosineHalfSphere()
{
    Plot2D plot_down_z( output_path + "/cosine_half_sphere__down_z.png", plot_size, plot_size );
    Plot2D plot_down_y( output_path + "/cosine_half_sphere__down_y.png", plot_size, plot_size );
    Plot2D plot_rot( output_path + "/cosine_half_sphere__rot.png", plot_size, plot_size );
    Transform xform = makeRotation( 0.5, Vector4( 1.0f, 1.0f, 1.0f ) );
    Vector4 v, rot;

    for( auto i = 0; i < points_per_plot; i++ ) {
        rng.cosineUnitHalfSphere( v );
        plot_down_z.addPoint( v.x, v.y );
        plot_down_y.addPoint( v.x, v.z );
        rot = mult( xform.fwd, v );
        plot_rot.addPoint( rot.x, rot.y );
    }

}
Exemplo n.º 6
0
void TestScene::setup()
{
    tracer = new ImageTracer( image_width, image_height,
                              anim_frames, rays_per_pixel );

    tracer->artifacts.output_path = output_dir;
    tracer->artifacts.file_prefix = name + "_";

    tracer->shader = new BasicDiffuseSpecularShader();

    tracer->setCameraTransform( compose(
        // move up a bit
        makeTranslation( 0.0, 0.5, 0.0 ),
        // rotate so we are looking down
        makeRotation( -0.2, Vector4(1, 0, 0) ),
        // back away from the origin
        makeTranslation( 0.0, 0.0, 10.0 )
        ) );
}