rendering is now performed in a separate thread. this is of little use now but lays the groundwork for adding parallel rendering. i just need to think about data ownership a little harder to make the tile renderer nice.
25 lines
740 B
Python
Executable file
25 lines
740 B
Python
Executable file
#!python
|
|
import argparse
|
|
from PIL import Image
|
|
from mechthild import Session, Shape, Camera
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('width', type=int, default=400, nargs='?')
|
|
parser.add_argument('height', type=int, default=400, nargs='?')
|
|
parser.add_argument('samples', type=int, default=32, nargs='?')
|
|
|
|
args = parser.parse_args()
|
|
|
|
s1 = Shape.sphere((0.75, 1.0, 1.0), 1.0)
|
|
s2 = Shape.sphere((-1.5, 2.0, -2.0), 2.0)
|
|
ground = Shape.plane((0.0, 1.0, 0.0), 0.0)
|
|
|
|
camera = Camera((0.0, 1.5, 5.0), (0.0, 1.0, 0.0), (0.0, 1.0, 0.0), 80.0)
|
|
|
|
session = Session([s1, s2, ground], camera, args.width, args.height, args.samples)
|
|
|
|
film = (session.get_output() * 255).astype('uint8')
|
|
|
|
image = Image.fromarray(film)
|
|
image.save("test.png")
|
|
|