예제 #1
0
def create_scene(t):
    width, height = 960 / downsample, 540 / downsample
    camera = tc.Camera('thinlens', width=width, height=height, fov=50, aperture=1, focus=(0, 0, 0),
                       origin=(0, 0, 100), look_at=(0, -0.5, 0), up=(0, 1, 0))

    scene = tc.Scene()

    with scene:
        scene.set_camera(camera)

        for p in particles:
            scene.add_mesh(p.create_mesh(t))

        envmap = tc.EnvironmentMap('base', filepath=tc.settings.get_asset_path('/envmaps/schoenbrunn-front_hd.hdr'))
        envmap.set_transform(tc.core.Matrix4(1.0).rotate_euler(tc.Vector(0, -30, 0)))
        scene.set_environment_map(envmap)

    return scene
예제 #2
0
def create_scene():
    downsample = 1
    camera = tc.Camera('pinhole',
                       res=(900 // downsample, 600 // downsample),
                       fov=60,
                       origin=(0, 10, 0),
                       look_at=(0, 0, 0),
                       up=(0, 0, -1))

    scene = tc.Scene()

    with scene:
        scene.set_camera(camera)

        text_tex = tc.Texture(
            'image', filename=tc.get_asset_path('textures/graphic_design.png'))

        for i in range(3):
            with tc.transform_scope(translate=(0, 0.101, 0),
                                    scale=(8, 4, 0.2),
                                    rotation=(-90, 0, 0)):
                with tc.transform_scope(scale=1**i):
                    mesh = tc.create_volumetric_block(text_tex * 8,
                                                      res=(512, 256, 4))
                    scene.add_mesh(mesh)

        ground_tex = tc.Texture(
            'image', filename=tc.get_asset_path('textures/metal.jpg'))

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('pbr', diffuse_map=ground_tex),
                       translate=(0, 0, 0),
                       scale=10,
                       rotation=(0, 0, 0))
        scene.add_mesh(mesh)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive', color=(1, 1, 1)),
                       translate=(-10, 3, 5),
                       scale=1,
                       rotation=(0, 0, -90))
        scene.add_mesh(mesh)

    return scene
예제 #3
0
def create_scene(t):
    downsample = 1
    width, height = 960 / downsample, 540 / downsample
    camera = tc.Camera('pinhole',
                       width=width,
                       height=height,
                       fov=50,
                       origin=(0, 2, 10),
                       look_at=(0, -0.5, 0),
                       up=(0, 1, 0))

    scene = tc.Scene()

    roughness = t * t

    with scene:
        scene.set_camera(camera)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('microfacet',
                                          color=(1, 1, 1),
                                          roughness=roughness,
                                          f0=1),
                       translate=(0, 0, 0),
                       scale=7,
                       rotation=(0, 0, 0))
        scene.add_mesh(mesh)

        for i in range(5):
            with tc.transform_scope(translate=(1.4 * (i - 2), 0.6, 0)):
                with tc.transform_scope(scale=(0.3, 1, 0.5),
                                        rotation=(90, 0, 0)):
                    mesh = tc.Mesh(
                        'plane',
                        tc.SurfaceMaterial('emissive',
                                           color=colorsys.hls_to_rgb(
                                               i * 0.2, 0.5, 1.0)))
                    scene.add_mesh(mesh)

    return scene
예제 #4
0
def create_scene():
    downsample = 1
    width, height = 960 / downsample, 540 / downsample
    camera = tc.Camera('pinhole',
                       width=width,
                       height=height,
                       fov=90,
                       origin=(0, 0, 10),
                       look_at=(0, 0, 0),
                       up=(0, 1, 0))

    scene = tc.Scene()

    with scene:
        scene.set_camera(camera)

        for i in range(3):
            with tc.TransformScope(translate=(i, 0, 0)):
                for j in range(3):
                    with tc.TransformScope(translate=(0, j, 0)):
                        mesh = tc.Mesh('plane',
                                       tc.SurfaceMaterial('pbr',
                                                          diffuse=(.1, .1,
                                                                   .1)),
                                       translate=(0, 0, -0.05),
                                       scale=0.4,
                                       rotation=(90.3, 0, 0))
                        scene.add_mesh(mesh)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive', color=(1, 1, 1)),
                       translate=(-30, 30, 10),
                       scale=2,
                       rotation=(0, 0, -90))

        scene.add_mesh(mesh)

    return scene
예제 #5
0
def create_scene():
  camera = tc.Camera(
      'pinhole',
      res=(800, 800),
      fov=40,
      origin=(0, 10, 40),
      look_at=(0, 0, 0),
      up=(0, 1, 0))

  scene = tc.Scene()

  with scene:
    scene.set_camera(camera)

    mesh = tc.Mesh(
        'plane',
        tc.SurfaceMaterial('emissive', color=(1, 1, 1)),
        translate=(0, 0, 0),
        scale=5,
        rotation=(0, 0, 0))
    scene.add_mesh(mesh)

  return scene
예제 #6
0
def create_scene():
    downsample = 2
    camera = tc.Camera('pinhole',
                       res=(1500 // downsample, 600 // downsample),
                       fov=30,
                       origin=(0, 1, 20),
                       look_at=(0, 2, 0),
                       up=(0, 1, 0))

    scene = tc.Scene()

    with scene:
        scene.set_camera(camera)

        ground_tex = tc.Texture(
            'image', filename=tc.get_asset_path('textures/paper.jpg'))

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('pbr', diffuse_map=ground_tex),
                       translate=(0, 0, -5),
                       scale=10,
                       rotation=(90, 0, 0))
        scene.add_mesh(mesh)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('pbr', diffuse_map=ground_tex),
                       translate=(0, 0, 0),
                       scale=10,
                       rotation=(0, 0, 0))
        scene.add_mesh(mesh)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive_spot',
                                          color=(1, 1, 1),
                                          exponential=3),
                       translate=(0, 0, -1.5),
                       scale=0.1,
                       rotation=(-101, 0, 0))
        scene.add_mesh(mesh)

        fill_light = 0.03
        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive',
                                          color=(fill_light, fill_light,
                                                 3 * fill_light)),
                       translate=(0, 10, 30),
                       scale=1,
                       rotation=(-90, 0, 0))
        scene.add_mesh(mesh)

        emission = 3
        with tc.transform_scope(rotation=(0, 10, 0)):
            mesh = tc.Mesh('plane',
                           tc.SurfaceMaterial('emissive_spot',
                                              color=(emission, emission,
                                                     emission),
                                              exponential=100),
                           translate=(10, 2, 1),
                           scale=0.1,
                           rotation=(0, 0, 100))
            scene.add_mesh(mesh)

        for j in range(3):
            for i in range(14):
                with tc.transform_scope(translate=(i - 7,
                                                   (random.random() - 0.5) *
                                                   0.4, j)):
                    with tc.transform_scope(rotation=(0, 0, 10 - j * 10),
                                            translate=(0, -j * 0.3 + i * 0.04 -
                                                       0.4, 0)):
                        s = random.random() * 0.5 + 0.8
                        r = random.random()
                        if r < 0.5:
                            shape = 'cube'
                        else:
                            shape = tc.geometry.create_cylinder((100, 2),
                                                                smooth=False)
                        mesh = tc.Mesh(shape,
                                       tc.SurfaceMaterial('diffuse',
                                                          color=(0.3, 0.2,
                                                                 0.1)),
                                       scale=(0.4 * s, 1 * s, 0.4 * s),
                                       rotation=(-4, -12, 0))
                        scene.add_mesh(mesh)

    return scene
예제 #7
0
파일: vcm.py 프로젝트: xj361685640/taichi
import taichi as tc
import random
import colorsys

if __name__ == '__main__':
  downsample = 2
  res = 960 // downsample, 540 // downsample

  scene = tc.Scene()
  with scene:
    camera = tc.Camera(
        'pinhole',
        res=res,
        fov=90,
        origin=(-5, 2, 0),
        look_at=(0, 1, 2),
        up=(0, 1, 0),
        aperture=10)
    scene.set_camera(camera)

    # Box
    scene.add_mesh(
        tc.Mesh(
            'cube',
            material=tc.SurfaceMaterial('pbr', diffuse=(1, 1, 1)),
            scale=10))

    tex = tc.Texture(
        'checkerboard',
        tex1=tc.Texture('const', value=(1, 1, 0.5, 1)),
        tex2=tc.Texture('const', value=(0.5, 0.5, 0.5)),
def create_scene():
  camera = tc.Camera(
      'pinhole',
      res=(1280, 720),
      fov=30,
      origin=(0, 0, 10),
      look_at=(0, 0, 0),
      up=(0, 1, 0))

  scene = tc.Scene()
  with scene:
    scene.set_camera(camera)
    tex = tc.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 = tc.SurfaceMaterial(
          'diffuse', color=(0.3, 0.2, 0.3), roughness_map=tex.id, f0=1)
      scene.add_mesh(
          tc.Mesh(
              'cube',
              material=material,
              translate=(0, -1, 0),
              scale=(2, 0.02, 1)))
      for i in range(7):
        material = tc.SurfaceMaterial(
            'diffuse',
            color=colorsys.hsv_to_rgb(i * 0.2, 0.5, 1.0),
            roughness_map=tex.id,
            f0=1)
        scene.add_mesh(
            tc.Mesh(
                'cube',
                material=material,
                translate=(2, 0.3 * (i - 3), 0.2),
                scale=(0.01, 0.10, 0.5)))
      material = tc.SurfaceMaterial(
          'diffuse', color=(0.3, 0.3, 0.3), roughness_map=tex.id, f0=1)
      scene.add_mesh(
          tc.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 = tc.Texture(
        'spherical_gradient',
        inside_val=(10, 10, 10, 10),
        outside_val=(1, 1, 1, 0),
        angle=10,
        sharpness=20)
    envmap = tc.EnvironmentMap('base', texture=envmap_texture.id, res=(1024, 1024))
    scene.set_environment_map(envmap)
  return scene
예제 #9
0
import taichi as tc
import random
import colorsys

if __name__ == '__main__':
    downsample = 2
    width = 960 / downsample
    height = 540 / downsample

    scene = tc.Scene()
    with scene:
        camera = tc.Camera('pinhole',
                           width=width,
                           height=height,
                           fov=90,
                           origin=(-5, 2, 0),
                           look_at=(0, 1, 2),
                           up=(0, 1, 0),
                           aperture=10)
        scene.set_camera(camera)

        # Box
        scene.add_mesh(
            tc.Mesh('cube',
                    material=tc.SurfaceMaterial('pbr', diffuse=(1, 1, 1)),
                    scale=10))

        tex = tc.Texture('checkerboard',
                         tex1=tc.Texture('const', value=(1, 1, 0.5, 1)),
                         tex2=tc.Texture('const', value=(0.5, 0.5, 0.5)),
                         repeat_u=10,
예제 #10
0
def create_scene():
    downsample = 1
    width, height = 960 / downsample, 540 / downsample
    camera = tc.Camera('pinhole',
                       width=width,
                       height=height,
                       fov=90,
                       origin=(0, 0, 10),
                       look_at=(0, 0, 0),
                       up=(0, 1, 0))

    scene = tc.Scene()

    with scene:
        scene.set_camera(camera)

        taichi_tex = tc.Texture('taichi', scale=0.96)
        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('pbr', diffuse=(.1, .1, .1)),
                       translate=(0, 0, -0.05),
                       scale=10,
                       rotation=(90.3, 0, 0))
        scene.add_mesh(mesh)

        # Taichi Text
        text = 1 - tc.Texture(
            'text',
            content='Taichi',
            width=200,
            height=200,
            font_file=tc.get_asset_path('fonts/go/Go-Bold.ttf'),
            size=50,
            dx=0,
            dy=0)
        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('transparent',
                                          nested=tc.SurfaceMaterial('diffuse',
                                                                    color=(1,
                                                                           1,
                                                                           1)),
                                          mask=text),
                       translate=(5.0, 2, 0.05),
                       scale=2,
                       rotation=(90, 0, 0))
        scene.add_mesh(mesh)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('pbr', diffuse=(0.2, 0.5, 0.2)),
                       translate=(0, 0, 0),
                       scale=(8.3, 1, 4.5),
                       rotation=(90, 0, 0))
        scene.add_mesh(mesh)
        '''
        text = 1 - tc.Texture('text', content='Physically based Computer Graphics', width=400, height=400,
                              size=30,
                              font_file=tc.get_asset_path('fonts/go/Go-Bold.ttf'),
                              dx=0, dy=0)
        mesh = tc.Mesh('plane', tc.SurfaceMaterial('transparent',
                                                   nested=tc.SurfaceMaterial('diffuse', color=(1, 0.1, 0.5)),
                                                   mask=text),
                       translate=(3.0, -6, 0.03), scale=(2, 2, 2), rotation=(90, 0, 0))
        scene.add_mesh(mesh)
        '''

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('pbr', diffuse=(0.2, 0.5, 0.2)),
                       translate=(0, 0, 0),
                       scale=(8.3, 1, 4.5),
                       rotation=(90, 0, 0))
        scene.add_mesh(mesh)

        ring_tex = 1 - tc.Texture('ring', inner=0.0, outer=1.0)
        grid_tex = (1 - tc.Texture('rect', bounds=(0.9, 0.9, 1.0))).repeat(
            6, 6, 1)

        # Taichi circle
        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('transparent',
                                          nested=tc.SurfaceMaterial('diffuse',
                                                                    color=(1,
                                                                           1,
                                                                           1)),
                                          mask=taichi_tex),
                       translate=(-3.7, 0, 0.05),
                       scale=2,
                       rotation=(90, 0, 0))
        scene.add_mesh(mesh)

        for i in range(1, 5):
            inv_ring_tex = tc.Texture('ring', inner=0.0, outer=0.5 + i * 0.1)
            color = colorsys.hls_to_rgb(i * 0.1, 0.5, 1.0)
            scene.add_mesh(
                tc.Mesh('plane',
                        tc.SurfaceMaterial('transparent',
                                           nested=tc.SurfaceMaterial(
                                               'diffuse', color=color),
                                           mask=inv_ring_tex),
                        translate=(-3.7, 1, i * 0.03),
                        scale=4,
                        rotation=(90, 0, 0)))

        scene.add_mesh(
            tc.Mesh('plane',
                    tc.SurfaceMaterial('transparent',
                                       nested=tc.SurfaceMaterial('diffuse',
                                                                 color=(0, 0.2,
                                                                        0.5)),
                                       mask=grid_tex),
                    translate=(4.3, 0, 0.17),
                    scale=1,
                    rotation=(90, 0, 0)))

        scene.add_mesh(
            tc.Mesh('plane',
                    tc.SurfaceMaterial('transparent',
                                       nested=tc.SurfaceMaterial('diffuse',
                                                                 color=(1, 1,
                                                                        0)),
                                       mask=grid_tex),
                    translate=(4.3, 0, 0.07),
                    scale=2,
                    rotation=(90, 0, 0)))

        scene.add_mesh(
            tc.Mesh('plane',
                    tc.SurfaceMaterial('transparent',
                                       nested=tc.SurfaceMaterial('diffuse',
                                                                 color=(0, 1,
                                                                        1)),
                                       mask=grid_tex),
                    translate=(4.3, 0, 0.02),
                    scale=3,
                    rotation=(90, 0, 0)))

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive', color=(1, 1, 1)),
                       translate=(-30, 30, 10),
                       scale=6,
                       rotation=(0, 0, -90))
        scene.add_mesh(mesh)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive', color=(1, 1, 1)),
                       translate=(30, 0, 10),
                       scale=2,
                       rotation=(0, 0, 90))
        scene.add_mesh(mesh)

    return scene
예제 #11
0
def create_scene():
    downsample = 1
    width, height = 600 / downsample, 900 / downsample
    camera = tc.Camera('pinhole',
                       width=width,
                       height=height,
                       fov=30,
                       origin=(0, 12, 20),
                       look_at=(0, 0.5, 0),
                       up=(0, 1, 0))

    scene = tc.Scene()

    with scene:
        scene.set_camera(camera)

        ground_tex = tc.Texture(
            'image', filename=tc.get_asset_path('textures/paper.jpg'))

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('pbr', diffuse_map=ground_tex),
                       translate=(0, 0, 0),
                       scale=10,
                       rotation=(0, 0, 0))
        scene.add_mesh(mesh)

        text = 1 - tc.Texture(
            'text',
            content='taichi',
            width=200,
            height=200,
            font_file=tc.get_asset_path('fonts/go/Go-Bold.ttf'),
            size=50,
            dx=0,
            dy=0)
        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('transparent',
                                          nested=tc.SurfaceMaterial(
                                              'emissive', color=(10, 10, 10)),
                                          mask=text),
                       translate=(0.20, 3.3, 0),
                       scale=0.4,
                       rotation=(90, 0, 0))
        scene.add_mesh(mesh)

        with tc.transform_scope(translate=(0, 1, 0), rotation=(0, -20, 0)):
            grid_tex = (1 - tc.Texture('rect', bounds=(0.8, 0.8, 1.0))).repeat(
                5, 5, 1)
            tex = tc.Texture('image',
                             filename=tc.get_asset_path('textures/paper.jpg'))
            material = tc.SurfaceMaterial('transparent',
                                          nested=tc.SurfaceMaterial(
                                              'reflective', color_map=tex),
                                          mask=grid_tex)
            for i in range(1):
                mesh = tc.Mesh('plane',
                               material,
                               translate=(0, 0.4, -i * 0.3),
                               scale=(1, 1, 1.4),
                               rotation=(90, 0, 0))
                scene.add_mesh(mesh)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive', color=(9, 9, 9)),
                       translate=(1, 3, -4),
                       scale=0.1,
                       rotation=(150, 0, 0))
        scene.add_mesh(mesh)

        emission = 0.001
        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive',
                                          color=(emission, emission,
                                                 emission)),
                       translate=(0, 10, 0),
                       scale=10,
                       rotation=(180, 0, 0))
        scene.add_mesh(mesh)

    return scene
예제 #12
0
def create_scene():
    downsample = 1
    width, height = 960 / downsample, 540 / downsample
    camera = tc.Camera('thinlens',
                       width=width,
                       height=height,
                       fov=40,
                       origin=(0, 20, 40),
                       look_at=(0, 1, 0),
                       up=(0, 1, 0),
                       aperture=0.3)

    scene = tc.Scene()

    base_mesh = tc.geometry.create_sphere((50, 50), smooth=True)

    materials = [
        tc.SurfaceMaterial('diffuse', color=(1, 0, 0)),
        tc.SurfaceMaterial('diffuse', color=(0, 1, 0)),
        tc.SurfaceMaterial('diffuse', color=(0, 0, 1)),
        tc.SurfaceMaterial('reflective', color=(1, 1, 1)),
        tc.SurfaceMaterial('glossy', color=(1, 1, 1), glossiness=(10, 10, 10)),
        tc.SurfaceMaterial('refractive', color=(1, 1, 1), ior=2.5),
        tc.SurfaceMaterial('pbr',
                           diffuse=(1, 0, 0),
                           specular=(0, 1, 0),
                           glossiness=(100, 0, 0)),
    ]

    with scene:
        scene.set_camera(camera)

        for i, mat in enumerate(materials):
            scene.add_mesh(
                tc.Mesh(base_mesh,
                        mat,
                        translate=((i - (len(materials) - 1) / 2) * 3, 1.3, 0),
                        scale=1))

        # Ground
        tex = (((tc.Texture('perlin') + 1) * 6).zoom(
            (0.6, 0.6, 0.6))).fract() * (1.0, 0.7, 0.4)
        scene.add_mesh(
            tc.Mesh('plane',
                    tc.SurfaceMaterial('pbr', diffuse_map=tex),
                    scale=200,
                    translate=(0, 0, 0),
                    rotation=(0, 0, 0)))

        # Board
        gradient = tc.Texture('uv', coeff_u=1, coeff_v=0)

        scene.add_mesh(
            tc.Mesh('plane',
                    tc.SurfaceMaterial('pbr',
                                       diffuse_map=gradient,
                                       specular_map=1 - gradient),
                    scale=(10, 1, 1),
                    translate=(0, 0.3, 2),
                    rotation=(0, 0, 0)))

        scene.add_mesh(
            tc.Mesh('plane',
                    tc.SurfaceMaterial('glossy',
                                       color=(1, 1, 1),
                                       glossiness_map=gradient * 100),
                    scale=(10, 1, 1),
                    translate=(0, 0.3, 4.5),
                    rotation=(0, 0, 0)))

        scene.add_mesh(
            tc.Mesh('plane',
                    tc.SurfaceMaterial('pbr',
                                       diffuse_map=gradient * (1, 0, 0) +
                                       (1 - gradient) * (0, 1, 1)),
                    scale=(10, 1, 1),
                    translate=(0, 0.3, 7),
                    rotation=(0, 0, 0)))

        scene.add_mesh(
            tc.Mesh('plane',
                    tc.SurfaceMaterial('transparent',
                                       mask=gradient,
                                       nested=tc.SurfaceMaterial('diffuse',
                                                                 color=(1, 1,
                                                                        1))),
                    scale=(10, 1, 1),
                    translate=(0, 0.3, 9.5),
                    rotation=(0, 0, 0)))

        for i in range(10):
            scene.add_mesh(
                tc.Mesh(tc.geometry.create_mesh_from_functions(
                    (50, 50), lambda p: Vector(
                        p.x * 2 - 1,
                        sin(p.x * 10 * pi) + cos(p.y * 5 * pi), p.y * 2 - 1)),
                        material=tc.SurfaceMaterial('reflective',
                                                    color=(1, 1, 1)),
                        translate=(0, 1, -6),
                        scale=(8, 0.2, 2)))

        envmap = tc.EnvironmentMap('base',
                                   filepath=tc.settings.get_asset_path(
                                       'envmaps/schoenbrunn-front_hd.hdr'))
        envmap.set_transform(
            tc.core.Matrix4(1.0).rotate_euler(Vector(0, 30, 0)))
        scene.set_environment_map(envmap)

    return scene
예제 #13
0
                    translate=(0, 1.3, 0)))

        #color = (0.46, 0.55, 0.63)


if __name__ == '__main__':
    downsample = 1
    width = 540 / downsample
    height = 960 / downsample

    scene = tc.Scene()
    with scene:
        camera = tc.Camera('pinhole',
                           width=width,
                           height=height,
                           fov=4,
                           origin=(200, 500, 700),
                           look_at=(0, 0, 0),
                           up=(0, 1, 0),
                           aperture=10)
        scene.set_camera(camera)

        # Ground
        scene.add_mesh(
            tc.Mesh(tc.geometry.create_plane(),
                    material=tc.SurfaceMaterial(
                        'pbr',
                        diffuse=tc.color255(225, 182, 166),
                    ),
                    scale=30))

        # Trees
예제 #14
0
    generation = tc.Texture('sphere', radius=0.08, center=(0.25, 0.1, 0.25)) + \
        tc.Texture('sphere', radius=0.08, center=(0.25, 0.1, 0.75)) + \
        tc.Texture('sphere', radius=0.08, center=(0.75, 0.1, 0.25)) + \
        tc.Texture('sphere', radius=0.08, center=(0.75, 0.1, 0.75))
    smoke.update(
        generation=generation * 100,
        color=tc.Texture(
            'const', value=colorsys.hls_to_rgb(0.02 * i + 0.0, 0.7, 1.0)),
        temperature=tc.Texture('const', value=(1, 0, 0, 0)),
        initial_velocity=tc.Texture('const', value=(0, 100, 0, 0)))
    smoke.step(0.03)
    particles = smoke.c.get_render_particles()
    width, height = 512, 1024
    image_buffer = tc.core.Array2DVector3(
        Vectori(width, height), Vector(0, 0, 0.0))
    radius = resolution[0] * 4
    camera = tc.Camera(
        'pinhole',
        origin=(0, radius * 0.3, radius),
        look_at=(0, 0, 0),
        up=(0, 1, 0),
        fov=70,
        res=(width, height))
    particle_renderer.set_camera(camera)
    particle_renderer.render(image_buffer, particles)
    img = image_buffer_to_ndarray(image_buffer)
    show_image('Vis', img)
    images.append(img)
  video_manager.write_frames(images)
  video_manager.make_video()
예제 #15
0
파일: vaze.py 프로젝트: xj361685640/taichi
def create_scene():
    downsample = 2
    res = 600 // downsample, 800 // downsample
    camera = tc.Camera('pinhole',
                       res=res,
                       fov=30,
                       origin=(0, 4, 40),
                       look_at=(0, 4, 0),
                       up=(0, 1, 0))

    scene = tc.Scene()

    radius = lambda x: exp(sin(x * 2 * pi + 0.1) + x + sin(150 * x) * 0.02) / 3
    surf = lambda p: tc.geometry.rotate_y(Vector(radius(p.x), p.x * 4, 0), p.y
                                          * 2 * pi)

    tex = ((tc.Texture('perlin') + 1) *
           5).zoom(zoom=(10, 10, 2)).fract() * (1.0, 0.4, 0.2)

    with scene:
        scene.set_camera(camera)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('diffuse', color=(1, 1, 1)),
                       translate=(0, 0, 0),
                       scale=40,
                       rotation=(0, 0, 0))
        scene.add_mesh(mesh)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('diffuse', color=(1, 1, 1)),
                       translate=(0, 0, -40),
                       scale=40,
                       rotation=(90, 0, 0))
        scene.add_mesh(mesh)

        mesh = tc.geometry.create_mesh_from_functions((150, 150),
                                                      surf,
                                                      smooth=False)
        scene.add_mesh(
            tc.Mesh(mesh,
                    tc.SurfaceMaterial('pbr', diffuse_map=tex),
                    translate=(0, 0, 0),
                    scale=2))

        # Lights

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive', color=(1, 0.9, 0.6)),
                       translate=(-10, 10, 30),
                       scale=1,
                       rotation=(-110, -45, 0))
        scene.add_mesh(mesh)

        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive',
                                          color=(0.01, 0.02, 0.04)),
                       translate=(10, 10, 30),
                       scale=3,
                       rotation=(-110, 45, 0))
        scene.add_mesh(mesh)

        with tc.transform_scope(translate=(9, 10, -10),
                                scale=(0.3, 1.3, 0.3),
                                rotation=(88, -27, 0)):
            mesh = tc.Mesh(
                'plane', tc.SurfaceMaterial('emissive', color=(100, 100, 10)))
            scene.add_mesh(mesh)
            surf = lambda p: tc.geometry.rotate_y(
                Vector(p.x * 3, p.x * p.x * 4 - 2, 0), p.y * 2 * pi)
            bowl = tc.geometry.create_mesh_from_functions((50, 50), surf)
            mesh = tc.Mesh(bowl, tc.SurfaceMaterial('diffuse',
                                                    color=(0, 0, 0)))
            scene.add_mesh(mesh)

    return scene