Ejemplo n.º 1
0
def create_scene():
    downsample = 1
    width, height = 960 / downsample, 540 / downsample
    camera = tc.Camera('pinhole', width=width, height=height, fov=50,
                       origin=(0, 2, 5), look_at=(0, 0, 0), up=(0, 1, 0))

    scene = tc.Scene()

    with scene:
        scene.set_camera(camera)

        num_spheres = 6
        for i in range(num_spheres):
            with tc.transform_scope(translate=(0.7 * (i - (num_spheres - 1) / 2.0), 0, 0)):
                r = 1.0 * i / (num_spheres - 1)
                r = r * r
                scene.add_mesh(tc.Mesh('sphere', tc.SurfaceMaterial('microfacet', color=(1, 1, 0.5),
                                                                    roughness=(0.01 + r, 0, 0, 0), f0=1),
                                       scale=0.3))

            mesh = tc.Mesh('holder',
                           tc.SurfaceMaterial('pbr', diffuse_map=tc.Texture.create_taichi_wallpaper(20)),
                           translate=(0, -1, -3), scale=1, rotation=(0, 0, 0))
            scene.add_mesh(mesh)

        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
Ejemplo n.º 2
0
def create_scene(frame, d, t):
    downsample = output_downsample
    width, height = 1280 / downsample, 720 / downsample

    camera = Camera('pinhole',
                    width=width,
                    height=height,
                    fov=25,
                    origin=(0, 0, 6),
                    look_at=(0, 0, 0),
                    up=(0, 1, 0))
    # camera = Camera('pinhole', width=width, height=height, fov=30,
    #                 origin=(2, 4, 4), look_at=(0, 0, 0), up=(0, 1, 0))

    scene = Scene()
    with scene:
        scene.set_camera(camera)

        with tc.transform_scope(rotation=(20, 0, 0),
                                translate=(0, 0.75, 0),
                                scale=1):
            mesh = tc.Mesh('plane',
                           tc.SurfaceMaterial('emissive',
                                              color=(30000, 40000, 60000)),
                           translate=(-20, 30, 0),
                           scale=3,
                           rotation=(0, 0, 180))
            scene.add_mesh(mesh)
            mesh = tc.Mesh('plane',
                           tc.SurfaceMaterial('emissive',
                                              color=(6000, 8000, 12000)),
                           translate=(20, 30, 40),
                           scale=3,
                           rotation=(0, 0, -180))
            scene.add_mesh(mesh)

            material = SurfaceMaterial('diffuse',
                                       color=(0.24, 0.18, 0.12),
                                       f0=1)
            scene.add_mesh(
                Mesh('cube',
                     material=material,
                     translate=(0, -1.01, 0),
                     scale=(1, 0.02, 0.6)))

            fn = d + r'/particles%05d.bin' % frame
            mesh = create_mpm_snow_block(fn)
            scene.add_mesh(mesh)

        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
Ejemplo n.º 3
0
def create_scene():
    downsample = 1
    width, height = 960 / downsample, 540 / downsample
    camera = tc.Camera('thinlens', width=width, height=height, fov=50,
                    origin=(1, 1, 3), look_at=(0, -0.6, 0), up=(0, 1, 0), focus=(0, 0, 0), aperture=0.08)

    scene = tc.Scene()

    dist = 100

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

        mesh = tc.Mesh('plane', tc.SurfaceMaterial('emissive', color=(1, 1, 1)),
                    translate=(-0.5 * dist, 0.7 * dist, 0.4 * dist), scale=0.01, rotation=(180, 0, 0))
        scene.add_mesh(mesh)

        mesh = tc.Mesh('cube', tc.SurfaceMaterial(
            'pbr', color=(1, 1, 1), specular=(1, 1, 1), transparent=True, ior=2.5, glossiness=-1),
                    translate=(0, -0.5, 0), scale=0.4)
        scene.add_mesh(mesh)
        mesh = tc.Mesh('torus', tc.SurfaceMaterial(
            'pbr', diffuse=(1, 0.5, 0)),
                    translate=(0, -0.5, 0), scale=0.25, rotation=(90, 0, 0))
        scene.add_mesh(mesh)

    return scene
Ejemplo n.º 4
0
def create_scene():
    downsample = 1
    width, height = 900 / downsample, 600 / downsample
    camera = tc.Camera('pinhole', width=width, height=height, 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
Ejemplo n.º 5
0
def create_scene():
  camera = tc.Camera(
      'thinlens',
      res=(960, 540),
      fov=55,
      origin=(30, 40, 50),
      look_at=(0, 0, 0),
      up=(0, 1, 0),
      focus=(0, 3, 0),
      aperture=0.1)

  scene = tc.Scene()

  with scene:
    scene.set_camera(camera)

    # Plane
    scene.add_mesh(
        tc.Mesh(
            'plane',
            tc.SurfaceMaterial('pbr', diffuse=(1, 1, 1.0)),
            translate=(0, 0, 0),
            scale=100,
            rotation=(0, 0, 0)))

    for i in range(8):
      menger = 1 - tc.Texture("menger", limit=i)
      scene.add_mesh(
          tc.Mesh(
              'plane',
              tc.SurfaceMaterial(
                  'transparent',
                  mask=menger,
                  nested=tc.SurfaceMaterial(
                      'diffuse',
                      color=colorsys.hls_to_rgb(i * 0.1 + 0.3, 0.3, 1.0))),
              translate=(i * 7 - 28, 3.5, -5),
              scale=3,
              rotation=(90, 0, 0)))

    # Lights
    scene.add_mesh(
        tc.Mesh(
            'plane',
            tc.SurfaceMaterial('emissive', color=(1, 1, 1)),
            translate=(0, 100, -200),
            scale=5,
            rotation=(180, 0, 0)))

    scene.add_mesh(
        tc.Mesh(
            'plane',
            tc.SurfaceMaterial('emissive', color=(1, 1, 1)),
            translate=(0, 100, 200),
            scale=3,
            rotation=(180, 0, 0)))

  return scene
def create_scene():
  res = 1280, 720
  camera = tc.Camera(
      'pinhole',
      res=res,
      fov=30,
      origin=(4, 0, 15),
      look_at=(0, 0, 0),
      up=(0, 1, 0))

  scene = tc.Scene()
  with scene:
    scene.set_camera(camera)

    emission = 100000
    mesh = tc.Mesh(
        'plane',
        tc.SurfaceMaterial('emissive', color=(emission, emission, emission)),
        translate=(300, 200, 300),
        scale=30,
        rotation=(-90, 0, 0))
    scene.add_mesh(mesh)

    material = tc.SurfaceMaterial(
        'diffuse', color=(0.5, 1, 1), roughness=1.0, f0=1)
    scene.add_mesh(
        tc.Mesh(
            'cube', material=material, translate=(0, 0, -2.0), scale=(1, 1, 1)))

    material = tc.SurfaceMaterial(
        'diffuse', color=(1, 0.5, 1), roughness=1.0, f0=1)
    scene.add_mesh(
        tc.Mesh(
            'cube', material=material, translate=(0, -2.0, 0), scale=(1, 1, 1)))

    material = tc.SurfaceMaterial(
        'diffuse', color=(1, 1, 0.5), roughness=1.0, f0=1)
    scene.add_mesh(
        tc.Mesh(
            'cube', material=material, translate=(-2.0, 0, 0), scale=(1, 1, 1)))

    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)

    vol_tex = tc.Texture('sphere', center=(0.5, 0.5, 0.5), radius=0.5)
    for i in range(3):
      with tc.transform_scope(translate=(i, 0, 0)):
        with tc.transform_scope(scale=1**i):
          mesh = tc.create_volumetric_block(vol_tex, res=(32, 32, 32))
          scene.add_mesh(mesh)

  return scene
Ejemplo n.º 7
0
def create_mis_scene(eye_position):
    num_light_sources = 4
    num_plates = 5
    light_position = tc.Vector(-0.5, 0)
    downsample = 1
    res = 960, 540
    camera = tc.Camera('pinhole',
                       res=res,
                       fov=70,
                       origin=(0, eye_position.y, eye_position.x),
                       look_at=(0, -0.3, 0),
                       up=(0, 1, 0))

    scene = tc.Scene()
    with scene:
        scene.set_camera(camera)
        rep = tc.Texture.create_taichi_wallpaper(20, rotation=0, scale=0.95)
        material = tc.SurfaceMaterial('pbr', diffuse_map=rep.id)
        scene.add_mesh(
            tc.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 = tc.SurfaceMaterial('emissive', color=(e, e, e))
            mesh = tc.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 = tc.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 = tc.Mesh('plane',
                           tc.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)

    return scene
Ejemplo n.º 8
0
def create_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))
    return mesh
Ejemplo n.º 9
0
def create_scene():
    downsample = 2
    width, height = 800 / downsample, 800 / downsample
    camera = tc.Camera('pinhole',
                       width=width,
                       height=height,
                       fov=40,
                       origin=(0, 10, 40),
                       look_at=(0, 0, 0),
                       up=(0, 1, 0))

    scene = tc.Scene()

    meshes = [
        tc.geometry.create_torus((30, 30)),
        tc.geometry.create_mobius((100, 30), 1, 0.4),
        tc.geometry.create_mobius((100, 30), 1, 0.4, 3),
        tc.geometry.create_cone((100, 2)),
        tc.geometry.create_cone((3, 2), smooth=False),
        tc.geometry.create_cylinder((10, 2), smooth=True),
        tc.geometry.create_sphere((10, 10), smooth=False)
    ]

    with scene:
        scene.set_camera(camera)
        meshes_per_row = 4
        distance = 3
        for i, m in enumerate(meshes):
            x, y = i % meshes_per_row + 0.5 - meshes_per_row / 2, \
                   i / meshes_per_row + 0.5 - meshes_per_row / 2

            color = colorsys.hls_to_rgb(i * 0.1, 0.4, 1.0)
            scene.add_mesh(
                tc.Mesh(m,
                        tc.SurfaceMaterial('pbr',
                                           diffuse=color,
                                           specular=color,
                                           glossiness=300),
                        translate=(x * distance, y * distance, 2)))

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

        scene.add_mesh(
            tc.Mesh('plane',
                    tc.SurfaceMaterial('pbr', diffuse=(1, 1, 1)),
                    scale=20,
                    translate=(0, 0, 0),
                    rotation=(90, 0, 0)))

    return scene
Ejemplo n.º 10
0
def create_scene():
  camera = tc.Camera(
      'pinhole',
      res=(960, 540),
      fov=20,
      origin=(0, 0, 30),
      look_at=(0, 0, 0),
      up=(0, 1, 0))

  scene = tc.Scene()

  with scene:
    scene.set_camera(camera)

    texture = (tc.Texture('perlin') + 1).fract()

    mesh = tc.Mesh(
        'plane',
        tc.SurfaceMaterial('diffuse', color_map=texture),
        translate=(0, 0, -0.05),
        scale=10,
        rotation=(90, 0, 0))
    scene.add_mesh(mesh)

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

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

    for i in range(30):
      s = 4
      scale = random.random() * 0.03 + 0.1
      rgb = colorsys.hls_to_rgb(random.random(), 0.6, 0.8)
      x, y = random.random() - 0.5, random.random() - 0.5
      mesh = tc.Mesh(
          'sphere',
          tc.SurfaceMaterial('pbr', diffuse=rgb, specular=rgb, glossiness=4),
          translate=(x * s, y * s, 0),
          scale=scale)
      scene.add_mesh(mesh)

  return scene
Ejemplo n.º 11
0
def create_tree(scene):
    translate = (random.random() * 0.4, 0, random.random() * 0.4)
    with tc.transform_scope(scale=(0.7, 0.7, 0.7), translate=translate):
        body_material = tc.SurfaceMaterial('pbr', diffuse=(1, 1, 1))
        scene.add_mesh(
            tc.Mesh('cube',
                    material=tc.SurfaceMaterial('diffuse', color=(1, 1, 0.4)),
                    scale=(0.1, 0.5, 0.1),
                    translate=(0, 0.5, 0)))
        scene.add_mesh(
            tc.Mesh(tc.create_cone((4, 2), False),
                    material=body_material,
                    scale=(0.6, 1.0, 0.6),
                    translate=(0, 1.3, 0)))
Ejemplo n.º 12
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
Ejemplo n.º 13
0
def create_scene(frame, d, t):
    downsample = output_downsample
    width, height = 1280 / downsample, 720 / downsample
    camera = Camera('pinhole', width=width, height=height, fov=35,
                    origin=(4, 1.5, 5), look_at=(0, -0.5, -1), up=(0, 1, 0))

    scene = Scene()
    with scene:
        scene.set_camera(camera)

        mesh = tc.Mesh('plane', tc.SurfaceMaterial('emissive', color=(30000, 40000, 60000)),
                       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.24, 0.18, 0.12), f0=1)
            scene.add_mesh(Mesh('cube', material=material, translate=(0, -1, 0), scale=(4, 0.02, 4)))

            tex = (1 - Texture('taichi', scale=0.92, rotation=0).zoom(zoom=(0.1, 0.2, 0.1), center=(0.02, 0.96, 0),
                                                                      repeat=False)) * (-0.9, -0.5, -0.0) + 1
            # material = SurfaceMaterial('diffuse', color_map=tex.id)
            material = SurfaceMaterial('diffuse', color=(0.24, 0.18, 0.12), f0=1)
            scene.add_mesh(Mesh('plane', material=material, translate=(0, 0, -1), scale=(4, 1, 4), rotation=(90, 0, 0)))

        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)

        fn = d + r'/particles%05d.bin' % frame
        mesh = create_mpm_sand_block(fn)
        scene.add_mesh(mesh)

    return scene
Ejemplo n.º 14
0
def create_scene():
  downsample = 2
  width, height = 800 // downsample, 800 // downsample
  camera = tc.Camera(
      'pinhole',
      res=(width, height),
      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)

    #scene.add_mesh(tc.Mesh('plane', tc.SurfaceMaterial('pbr', diffuse=(1, 1, 1)), scale=20,
    #                       translate=(0, 0, 0), rotation=(90, 0, 0)))

  return scene
Ejemplo n.º 15
0
def create_scene():
  camera = tc.Camera(
      'pinhole',
      res=(512, 512),
      fov=120,
      origin=(0, -5, 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
    material = tc.SurfaceMaterial(
        'microfacet', color=(1.0, 1, 0.8), roughness_map=tex.id, f0=1)
    for i in range(-7, 5):
      scene.add_mesh(
          tc.Mesh(
              'sphere',
              material=material,
              translate=(i, -i * 1.6, -math.sin(i * 0.1)),
              scale=0.7))

    envmap_texture = tc.Texture('sky', height=0.5, direction=0.3)
    envmap_texture.show(res=(500, 500), post_processor=tc.post_process.LDRDisplay())
    envmap = tc.EnvironmentMap('base', texture=envmap_texture.id, res=(1024, 1024))
    scene.set_environment_map(envmap)
  return scene
Ejemplo n.º 16
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
Ejemplo n.º 17
0
def create_scene():
    downsample = 2
    width, height = 800 / downsample, 800 / downsample
    camera = tc.Camera('thinlens',
                       width=width,
                       height=height,
                       fov=90,
                       aperture=0.0,
                       focus=(0, 0, 0),
                       origin=(3, 0, 0),
                       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, 10, 0),
                       scale=2,
                       rotation=(0, 0, 180))
        scene.add_mesh(mesh)

    return scene
Ejemplo n.º 18
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
Ejemplo n.º 19
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
Ejemplo n.º 20
0
def create_scene():
    downsample = 2
    width, height = 1500 / downsample, 600 / downsample
    camera = tc.Camera('pinhole', width=width, height=height, 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
Ejemplo n.º 21
0
def create_scene(frame, d, t):
    downsample = output_downsample
    width, height = 1280 / downsample, 720 / downsample

    camera = Camera('pinhole',
                    width=width,
                    height=height,
                    fov=30,
                    origin=(0, 0, 8),
                    look_at=(0, 0, 0),
                    up=(0, 1, 0))

    scene = Scene()
    with scene:
        scene.set_camera(camera)
        mesh = tc.Mesh('plane',
                       tc.SurfaceMaterial('emissive',
                                          color=(30000, 40000, 60000)),
                       translate=(-20, 20, -15),
                       scale=3,
                       rotation=(0, 0, 180))
        scene.add_mesh(mesh)

        with tc.transform_scope(rotation=(10, 0, 0),
                                translate=(0, 0, 0),
                                scale=1):
            with tc.transform_scope(rotation=(0, -40, 0),
                                    translate=(0, 0.5, 0),
                                    scale=1):
                fn = d + r'/particles%05d.bin' % frame
                mesh = create_mpm_sand_block(fn)
                scene.add_mesh(mesh)

        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
Ejemplo n.º 22
0
    def create_mesh(self, t):
        t += 3 - 5.0 * self.i / res[0]
        t = 1 / (1 + math.exp(-t))
        material = tc.SurfaceMaterial('microfacet',
                                      color=colorsys.hls_to_rgb(self.i * 1.0 / res[0], 0.5, 1.0),
                                      f0=1, roughness=0.0
                                      )
        transform = tc.core.Matrix4(1.0)
        with tc.transform_scope(translate=(-(res[0] + 1) * 0.5 + self.i, -(res[1] + 1) * 0.5 + self.j, 0)):
            with tc.transform_scope(transform=transform):
                transform = tc.Transform(scale=0.45, rotation=(90, 0, 0))
                for k in range(self.scales):
                    transform.translate(-self.radius[k])
                    transform.rotate(self.rotation[k] * (1 - t) * 100.0 * (0.5 ** k))
                    transform.translate(self.radius[k])

                with tc.transform_scope(transform=transform.get_matrix()):
                    mesh = tc.Mesh('plane', material)
        return mesh
Ejemplo n.º 23
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
Ejemplo n.º 24
0
def create_scene(frame, d, t):
    downsample = output_downsample
    width, height = 1280 / downsample, 720 / downsample

    camera = Camera('pinhole',
                    width=width,
                    height=height,
                    fov=25,
                    origin=(0, 0, 8),
                    look_at=(0, 0, 0),
                    up=(0, 1, 0))
    # camera = Camera('pinhole', width=width, height=height, fov=30,
    #                 origin=(2, 4, 4), look_at=(0, 0, 0), up=(0, 1, 0))

    scene = Scene()
    with scene:
        scene.set_camera(camera)

        with tc.transform_scope(rotation=(20, 0, 0),
                                translate=(0, 0, 0),
                                scale=1):
            with tc.transform_scope(rotation=(0, -20, 0),
                                    translate=(0, 0.7, 0),
                                    scale=1):
                mesh = tc.Mesh('plane',
                               tc.SurfaceMaterial('emissive',
                                                  color=(30000, 40000, 60000)),
                               translate=(-20, 30, 0),
                               scale=3,
                               rotation=(0, 0, 180))
                scene.add_mesh(mesh)
                mesh = tc.Mesh('plane',
                               tc.SurfaceMaterial('emissive',
                                                  color=(6000, 8000, 12000)),
                               translate=(20, 30, 40),
                               scale=3,
                               rotation=(0, 0, -180))
                scene.add_mesh(mesh)

                material = SurfaceMaterial('diffuse',
                                           color=(0.24, 0.18, 0.12),
                                           f0=1)
                scene.add_mesh(
                    Mesh('cube',
                         material=material,
                         translate=(0, -1, 0),
                         scale=(1.25, 0.02, 0.8)))

                material = tc.SurfaceMaterial('microfacet',
                                              color=(1, 1, 0.5),
                                              roughness=(0.1, 0, 0, 0),
                                              f0=1)
                # levelset.add_sphere(Vector(0.325 + 0.25 * t, 0.2, 0.5), 0.05, False)
                for i in range(0, 24, 3):
                    px = 0.5 + 0.2 * math.sin(45.0 * i / 180 * math.pi)
                    py = 0.5 + 0.2 * math.cos(45.0 * i / 180 * math.pi)
                    vx = -bullet_speed * math.sin(45.0 * i / 180 * math.pi)
                    vy = -bullet_speed * math.cos(45.0 * i / 180 * math.pi)
                    sphere = tc.Mesh('sphere',
                                     material,
                                     translate=((px + t * vx) * 2 - 1,
                                                0.08 * (i / 3 + 1) - 1,
                                                (py + t * vy) * 2 - 1),
                                     scale=0.04,
                                     rotation=(0, 0, 0))
                    scene.add_mesh(sphere)

                fn = d + r'/particles%05d.bin' % frame
                mesh = create_mpm_sand_block(fn)
                scene.add_mesh(mesh)

        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
Ejemplo n.º 25
0
  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)),
        repeat_u=10,
        repeat_v=10)

    # Ground
    scene.add_mesh(
        tc.Mesh(
            tc.geometry.create_plane(),
            material=tc.SurfaceMaterial(
                'pbr',
Ejemplo n.º 26
0
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
Ejemplo n.º 27
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
Ejemplo n.º 28
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
Ejemplo n.º 29
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
Ejemplo n.º 30
0
    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
        for i in range(-7, 7):
            for j in range(-7, 7):
                if -2 < i < 2 and -2 < j < 2:
                    continue
                else:
                    with tc.transform_scope(translate=(i * 4, 0, j * 4)):
                        create_tree(scene)

        with tc.transform_scope(scale=(3, 3, 3)):
            create_tree(scene)