1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package main
import (
"fmt"
"os"
"time"
)
func main() {
start := time.Now();
mat_ground := Lambertian{Vec3{0.8, 0.8, 0}};
mat_centre := Lambertian{Vec3{0.1, 0.2, 0.5}};
mat_left := Dielectric{1.5};
mat_bubble := Dielectric{1.0 / 1.5};
mat_right := Metal{Vec3{0.8, 0.6, 0.2}, 1.0};
var world Hittables;
world.Add(Sphere{Vec3{ 0, -100.5, -1 }, 100 , mat_ground});
world.Add(Sphere{Vec3{ 0, 0 , -1.2}, 0.5, mat_centre});
world.Add(Sphere{Vec3{-1.0, 0 , -1 }, 0.5, mat_left});
world.Add(Sphere{Vec3{-1.0, 0 , -1 }, 0.4, mat_bubble});
world.Add(Sphere{Vec3{ 1.0, 0 , -1 }, 0.5, mat_right});
cam := NewCamera(400, 16.0/9.0,
100, 50,
20, Vec3{-2, 2, 1},
Vec3{0, 0, -1}, Vec3{0, 1, 0},
10.0, 3.4);
cam.Render(world);
dur := time.Since(start);
fmt.Fprintf(os.Stderr,
"[GDone, in %5.2f seconds! \n",
dur.Seconds());
}
|