コード例 #1
0
def create_scene():
    downsample = 2
    width, height = 1280 / downsample, 720 / downsample
    camera = Camera('pinhole', width=width, height=height, fov=30,
                    origin=(0, 0, 10), look_at=(0, 0, 0), up=(0, 1, 0))

    scene = Scene()
    with scene:
        scene.set_camera(camera)
        tex = Texture.create_taichi_wallpaper(20, rotation=0, scale=0.95) * 0.9

        mesh = tc.Mesh('plane', tc.SurfaceMaterial('emissive', color=(6000, 6000, 10000)),
                       translate=(30, 20, 30), scale=3, rotation=(0, 0, 180))
        scene.add_mesh(mesh)

        with tc.transform_scope(rotation=(0, 0, 0), scale=1):
            material = SurfaceMaterial('diffuse', color=(0.3, 0.2, 0.3), roughness_map=tex.id, f0=1)
            scene.add_mesh(Mesh('cube', material=material, translate=(0, -1, 0), scale=(2, 0.02, 1)))
            for i in range(7):
                material = SurfaceMaterial('diffuse', color=hsv_to_rgb(i * 0.2, 0.5, 1.0), roughness_map=tex.id, f0=1)
                scene.add_mesh(
                    Mesh('cube', material=material, translate=(2, 0.3 * (i - 3), 0.2), scale=(0.01, 0.10, 0.5)))
            material = SurfaceMaterial('diffuse', color=(0.3, 0.3, 0.3), roughness_map=tex.id, f0=1)
            scene.add_mesh(Mesh('cube', material=material, translate=(0, 0, -1), scale=(1.9, 0.9, 0.03)))

            with tc.transform_scope(rotation=(0, 30, 0), translate=(0, 0, 0)):
                scene.add_mesh(create_volumetric_block())

        envmap_texture = Texture('spherical_gradient', inside_val=(10, 10, 10, 10), outside_val=(1, 1, 1, 0),
                                 angle=10, sharpness=20)
        envmap = EnvironmentMap('base', texture=envmap_texture.id, res=(1024, 1024))
        scene.set_environment_map(envmap)
    return scene
コード例 #2
0
ファイル: test_volumetric.py プロジェクト: zorrock/taichi
def create_snow_scene(frame):
    downsample = 1
    width, height = 960 / downsample, 540 / downsample
    camera = Camera('thinlens',
                    width=width,
                    height=height,
                    fov=60,
                    origin=(0, 1, 4),
                    look_at=(0.0, -0.7, -0.0),
                    up=(0, 1, 0),
                    aperture=0.05)

    scene = Scene()
    with scene:
        scene.set_camera(camera)
        rep = Texture.create_taichi_wallpaper(
            10, rotation=0, scale=0.95) * Texture('const',
                                                  value=(0.7, 0.5, 0.5))
        material = SurfaceMaterial('pbr', diffuse_map=rep)
        scene.add_mesh(
            Mesh('holder', material=material, translate=(0, -1, -6), scale=2))

        mesh = Mesh('plane',
                    SurfaceMaterial('emissive', color=(1, 1, 1)),
                    translate=(1.0, 1.0, -1),
                    scale=(0.1, 0.1, 0.1),
                    rotation=(180, 0, 0))
        scene.add_mesh(mesh)

        # Change this line to your particle output path pls.
        fn = r'../snow-sim/particles%05d.bin' % frame
        mesh = create_mpm_snow_block(fn)
        scene.add_mesh(mesh)

    return scene
コード例 #3
0
ファイル: environment_map.py プロジェクト: xj361685640/taichi
def create_scene():
    downsample = 1
    width, height = 512 // downsample, 512 // downsample
    camera = Camera('pinhole',
                    res=(width, height),
                    fov=120,
                    origin=(0, -5, 10),
                    look_at=(0, 0, 0),
                    up=(0, 1, 0))

    scene = Scene()
    with scene:
        scene.set_camera(camera)
        tex = Texture.create_taichi_wallpaper(20, rotation=0, scale=0.95) * 0.9
        material = SurfaceMaterial('microfacet',
                                   color=(1.0, 1, 0.8),
                                   roughness_map=tex.id,
                                   f0=1)
        for i in range(-7, 5):
            scene.add_mesh(
                Mesh('sphere',
                     material=material,
                     translate=(i, -i * 1.6, -math.sin(i * 0.1)),
                     scale=0.7))

        envmap_texture = Texture('sky', height=0.5, direction=0.3)
        envmap_texture.show(res=(500, 500), post_processor=LDRDisplay())
        envmap = EnvironmentMap('base',
                                texture=envmap_texture.id,
                                res=(1024, 1024))
        scene.set_environment_map(envmap)
    return scene
コード例 #4
0
def create_sand_scene(frame, d, t):
    downsample = output_downsample
    width, height = 540 / downsample, 540 / downsample
    camera = Camera('thinlens', width=width, height=height, fov=75,
                    origin=(0, 1, 4), look_at=(0.0, -0.9, 0.0), up=(0, 1, 0), aperture=0.01)

    scene = Scene()
    with scene:
        scene.set_camera(camera)
        rep = Texture.create_taichi_wallpaper(10, rotation=0, scale=0.95) * Texture('const', value=(0.7, 0.5, 0.5))
        material = SurfaceMaterial('pbr', diffuse_map=rep)
        scene.add_mesh(Mesh('holder', material=material, translate=(0, -1, -6), scale=2))

        mesh = Mesh('plane', SurfaceMaterial('emissive', color=(1, 1, 1)),
                    translate=(1.0, 1.0, -1), scale=(0.1, 0.1, 0.1), rotation=(180, 0, 0))
        scene.add_mesh(mesh)

        material = tc.SurfaceMaterial('microfacet', color=(1, 1, 0.5), roughness=(0.1, 0, 0, 0), f0=1)
        sphere = tc.Mesh('sphere', material,
                         translate=((t+0.05) * 0.5 - 0.35, -0.60, 0), scale=0.1, rotation=(0, 0, 0))
        scene.add_mesh(sphere)

        # Change this line to your particle output path pls.
        # fn = r'../sand-sim/particles%05d.bin' % frame
        fn = d + r'/particles%05d.bin' % frame
        mesh = create_mpm_sand_block(fn)
        scene.add_mesh(mesh)

    return scene
コード例 #5
0
def create_mis_scene(eye_position):
    num_light_sources = 4
    num_plates = 5
    light_position = Vector(-0.5, 0)
    downsample = 1
    width, height = 960 / downsample, 540 / downsample
    camera = Camera('pinhole',
                    width=width,
                    height=height,
                    fov=70,
                    origin=(0, eye_position.y, eye_position.x),
                    look_at=(0, -0.3, 0),
                    up=(0, 1, 0))

    scene = Scene()
    with scene:
        scene.set_camera(camera)
        rep = Texture.create_taichi_wallpaper(20, rotation=0, scale=0.95)
        material = SurfaceMaterial('pbr', diffuse_map=rep.id)
        scene.add_mesh(
            Mesh('holder', material=material, translate=(0, -1, -7), scale=2))
        for i in range(num_light_sources):
            radius = 0.002 * 3**i
            e = 0.01 / radius**2
            material = SurfaceMaterial('emissive', color=(e, e, e))
            mesh = Mesh('sphere',
                        material,
                        translate=(0.2 * (i - (num_light_sources - 1) * 0.5),
                                   light_position.y, light_position.x),
                        scale=radius)
            scene.add_mesh(mesh)

        for i in range(num_plates):
            fraction = -math.pi / 2 - 1.0 * i / num_plates * 0.9
            z = math.cos(fraction) * 1
            y = math.sin(fraction) * 1 + 0.5
            board_position = Vector(z, y)
            vec1 = eye_position - board_position
            vec2 = light_position - board_position
            vec1 *= 1.0 / math.hypot(vec1.x, vec1.y)
            vec2 *= 1.0 / math.hypot(vec2.x, vec2.y)
            half_vector = vec1 + vec2
            angle = math.degrees(math.atan2(half_vector.y, half_vector.x))
            mesh = Mesh('plane',
                        SurfaceMaterial('pbr',
                                        diffuse=(0.1, 0.1, 0.1),
                                        specular=(1, 1, 1),
                                        glossiness=100 * 3**i),
                        translate=(0, board_position.y, board_position.x),
                        rotation=(90 - angle, 0, 0),
                        scale=(0.4, 0.7, 0.05))
            scene.add_mesh(mesh)

            # envmap = EnvironmentMap('base', filepath='d:/assets/schoenbrunn-front_hd.hdr')
            # scene.set_environment_map(envmap)
    return scene
コード例 #6
0
ファイル: test_volumetric.py プロジェクト: zgsxwsdxg/taichi
def create_taichi_scene(eye_position):
    downsample = 2
    width, height = 960 / downsample, 540 / downsample
    camera = Camera('pinhole',
                    width=width,
                    height=height,
                    fov=70,
                    origin=(0.5, 0.5, 3),
                    look_at=(0.5, 0.5, 0.5),
                    up=(0, 1, 0))

    scene = Scene()
    with scene:
        scene.set_camera(camera)
        rep = Texture.create_taichi_wallpaper(
            10, rotation=0, scale=0.95) * Texture('const',
                                                  value=(0.5, 0.5, 1.0))
        material = SurfaceMaterial('pbr', diffuse_map=rep)
        scene.add_mesh(
            Mesh('holder', material=material, translate=(0, -1, -7), scale=2))

        mesh = Mesh('plane',
                    SurfaceMaterial('emissive', color=(1, 1, 1)),
                    translate=(0.5, 1.3, 0),
                    scale=(0.1, 1.0, 0.1),
                    rotation=(180, 0, 0))
        scene.add_mesh(mesh)

        material = SurfaceMaterial('plain_interface')
        #vol = VolumeMaterial("homogeneous", scattering=10, absorption=0)
        tex = 1 - Texture('taichi', scale=0.95)
        vol = VolumeMaterial('voxel',
                             scattering=100,
                             absorption=0,
                             resolution=256,
                             tex=tex)
        material.set_internal_material(vol)
        mesh = Mesh('cube',
                    material=material,
                    translate=(0.5, 0.5, 0.5),
                    scale=(0.5, 0.5, 0.2),
                    rotation=(0, 0, 0))
        scene.add_mesh(mesh)

        #envmap = EnvironmentMap('base', filepath='d:/assets/schoenbrunn-front_hd.hdr')
        #scene.set_environment_map(envmap)

    return scene