コード例 #1
0
ファイル: run2.py プロジェクト: EyeOfPython/Beyond-Infinity
import cmath
import sys
from world.generate.diamondsquaregenerator import DiamondSquareGenerator
from world.generate.perlinnoisegenerator import PerlinNoiseGenerator

if __name__ == '__main__':
    platform = pyopencl.get_platforms()
    my_gpu_devices = platform[0].get_devices(device_type=pyopencl.device_type.CPU)
    ctx = pyopencl.Context(devices=my_gpu_devices)
    print(ctx.devices[0].max_compute_units)
    queue = pyopencl.CommandQueue(ctx)
    scene = Scene(ctx, queue)

    gen = DiamondSquareGenerator({ 'widthlog2': 8, 'roughness': 1, 'factor': 0.6 })
    #gen = PerlinNoiseGenerator({ 'widthlog2': 8, 'freq': 32, 'steps': 4, 'amplitude_factor': 1 })
    gen.generate(scene._chunk_array, ctx, queue, scene.raytrace_pgrm.write_height_map)
    
    sphere  = scene.create_object("sphere", position=(2,0,0), radius=2)
    #cube = scene.create_object("aacube", position=(0,0,0,0), width=6)
    scene.create_object("sphere", position=(-4,0,0), radius=1)
    scene.create_object("aacube", position=(-4,0,-5), width=1)
    scene.create_object("aacube", position=(-2, 0, 0), width=1.5)
    scene.create_object("aacube", position=(-2, 0, -5), width=1.5)
    scene.create_object("aacube", position=(-10, 3, -10), width=15)
    
    light   = scene.create_light("directional", direction=(1,1,1), color=(1,1,1))
    #scene.create_light("directional", direction=(1,1,1), color=(1,1,1))
    
    size = (800, 600)
    h_result_image = numpy.empty((size[0]*4, size[1]), dtype=numpy.ubyte)
    im_format = pyopencl.ImageFormat(pyopencl.channel_order.RGBA, pyopencl.channel_type.UNORM_INT8)