equal
deleted
inserted
replaced
1 #!/usr/bin/python |
1 #!/usr/bin/python |
2 |
2 |
3 from raytracer import Raytracer, Material, Box, Sphere, Light |
3 from pyrit import * |
4 import Image |
|
5 |
4 |
6 rt = Raytracer() |
5 rt = Raytracer() |
|
6 top = KdTree() |
|
7 rt.setTop(top) |
|
8 rt.setCamera(Camera()) |
7 rt.ambientOcclusion(samples=100, distance=16.0, angle=0.5) |
9 rt.ambientOcclusion(samples=100, distance=16.0, angle=0.5) |
8 |
10 |
9 light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6)) |
11 light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6)) |
10 light1.castShadows(False) |
12 light1.castShadows(False) |
11 rt.addLight(light1) |
13 rt.addLight(light1) |
29 |
31 |
30 mat3 = Material(colour=(0.0, 0.0, 1.0)) |
32 mat3 = Material(colour=(0.0, 0.0, 1.0)) |
31 tinysphere = Sphere(centre=(-1.2, 0.0, -2.0), radius=0.5, material=mat3) |
33 tinysphere = Sphere(centre=(-1.2, 0.0, -2.0), radius=0.5, material=mat3) |
32 rt.addShape(tinysphere) |
34 rt.addShape(tinysphere) |
33 |
35 |
34 imagesize = (800, 600) |
36 top.optimize() |
35 data = rt.render(imagesize) |
37 |
36 img = Image.fromstring("RGB", imagesize, data) |
38 sampler = DefaultSampler(800, 600) |
37 img.save('spheres_ao.png') |
39 rt.setSampler(sampler) |
|
40 rt.render() |
|
41 sampler.getPixmap().writePNG('spheres_ao.png') |