diff options
| author | Adrian Kummerlaender | 2020-01-20 22:40:44 +0100 | 
|---|---|---|
| committer | Adrian Kummerlaender | 2020-01-20 22:40:44 +0100 | 
| commit | abbdbe64d12af732983bc11aac772d3d32682bb5 (patch) | |
| tree | fb89bd9818e33588cf295036c6feb681b92d0ff4 /fancy_local_sunrise.py | |
| parent | b0b52925fb96e417802f4b390fafc15c8536df2d (diff) | |
| download | firmament-abbdbe64d12af732983bc11aac772d3d32682bb5.tar firmament-abbdbe64d12af732983bc11aac772d3d32682bb5.tar.gz firmament-abbdbe64d12af732983bc11aac772d3d32682bb5.tar.bz2 firmament-abbdbe64d12af732983bc11aac772d3d32682bb5.tar.lz firmament-abbdbe64d12af732983bc11aac772d3d32682bb5.tar.xz firmament-abbdbe64d12af732983bc11aac772d3d32682bb5.tar.zst firmament-abbdbe64d12af732983bc11aac772d3d32682bb5.zip | |
Extract OpenCL setup into Renderer
Diffstat (limited to 'fancy_local_sunrise.py')
| -rw-r--r-- | fancy_local_sunrise.py | 36 | 
1 files changed, 7 insertions, 29 deletions
| diff --git a/fancy_local_sunrise.py b/fancy_local_sunrise.py index 39cb292..bdb23b4 100644 --- a/fancy_local_sunrise.py +++ b/fancy_local_sunrise.py @@ -1,17 +1,12 @@  import numpy as np  import matplotlib.pyplot as plt -from string import Template -import pyopencl as cl -from pyopencl.cltypes import make_double3 - -mf = cl.mem_flags - -from planets import earth - -from sun import sun_direction  from datetime import datetime +from firmament import Renderer +from firmament.planets import earth +from firmament.sun import sun_direction +  config = {      'size_x': 1000,      'size_y': 1000, @@ -35,37 +30,20 @@ config = {  time_range = (6, 20, 1) -cl_platform = cl.get_platforms()[0] -cl_context = cl.Context(properties=[(cl.context_properties.PLATFORM, cl_platform)]) -cl_queue   = cl.CommandQueue(cl_context) - -cl_picture = cl.Buffer(cl_context, mf.WRITE_ONLY, size=config['size_x']*config['size_y']*3*np.float64(0).nbytes) -program = None - -with open('raymarch.cl') as f: -    program = cl.Program(cl_context, Template(f.read()).substitute( -        {**config, **earth} -    )).build() +renderer = Renderer(config, earth)  for time in np.arange(*time_range):      pit = datetime(*config['date'], int(np.floor(time)), int((time-np.floor(time))*60), 0)      sun_dir = sun_direction(config['latitude'], config['longitude'], pit, config['timezone'], 1.0 if config['summertime'] else 0.0) -    sun = make_double3( +    sun = (          np.cos(sun_dir[0])*np.sin(sun_dir[1]),          np.cos(sun_dir[0])*np.cos(sun_dir[1]),          np.sin(sun_dir[0])      )      print(sun_dir) -    program.render_fisheye( -        cl_queue, (config['size_x'], config['size_y']), None, cl_picture, -        make_double3(*(config['eye_pos'] * earth['earth_radius'])), -        make_double3(*(config['eye_dir'] * earth['earth_radius'])), -        sun) - -    np_picture = np.ndarray(shape=(config['size_y'], config['size_x'], 3), dtype=np.float64) -    cl.enqueue_copy(cl_queue, np_picture, cl_picture).wait(); +    np_picture = renderer.render_fisheye(sun)      fig = plt.gcf() | 
