aboutsummaryrefslogtreecommitdiff
path: root/sunrise.py
diff options
context:
space:
mode:
Diffstat (limited to 'sunrise.py')
-rw-r--r--sunrise.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/sunrise.py b/sunrise.py
index b7b2cd3..9a99605 100644
--- a/sunrise.py
+++ b/sunrise.py
@@ -10,18 +10,21 @@ mf = cl.mem_flags
from planets import earth
config = {
- 'size_x': 480,
- 'size_y': 270,
+ 'size_x': 1920//4,
+ 'size_y': 1080//4,
- 'ray_samples' : 64,
- 'light_samples': 32,
+ 'ray_samples' : 32,
+ 'light_samples': 8,
'exposure': 20.0,
+ 'zoom': 1.0,
- 'eye_pos': (0, 0, 1.00001),
- 'eye_dir': (0, 1, 0.3)
+ 'eye_pos': numpy.array([0, 0, 1.0001]),
+ 'eye_dir': numpy.array([0, 1, 0])
}
+sun_range = (-10, 90, 10)
+
cl_platform = cl.get_platforms()[0]
cl_context = cl.Context(properties=[(cl.context_properties.PLATFORM, cl_platform)])
cl_queue = cl.CommandQueue(cl_context)
@@ -29,22 +32,24 @@ cl_queue = cl.CommandQueue(cl_context)
cl_picture = cl.Buffer(cl_context, mf.WRITE_ONLY, size=config['size_x']*config['size_y']*3*numpy.float64(0).nbytes)
program = None
+print('height: %d' % (earth['earth_radius']*config['eye_pos'][2] - earth['earth_radius']))
+
with open('raymarch.cl') as f:
program = cl.Program(cl_context, Template(f.read()).substitute(
{**config, **earth}
)).build()
-for i in range(-10,10):
+for i in numpy.arange(*sun_range):
sun = make_double3(0.0,numpy.cos(i*2*numpy.pi/360),numpy.sin(i*2*numpy.pi/360))
print(sun)
program.render(
cl_queue, (config['size_x'], config['size_y']), None, cl_picture,
- make_double3(*config['eye_pos']),
- make_double3(*config['eye_dir']),
+ make_double3(*(config['eye_pos'] * earth['earth_radius'])),
+ make_double3(*(config['eye_dir'] * earth['earth_radius'])),
sun)
np_picture = numpy.ndarray(shape=(config['size_y'], config['size_x'], 3), dtype=numpy.float64)
cl.enqueue_copy(cl_queue, np_picture, cl_picture).wait();
- plt.imsave('sky_%03d.png' % (i+10), np_picture, origin='lower')
+ plt.imsave("sky_%05.1f.png" % (i-sun_range[0]), np_picture, origin='lower')