How to use the taichi.SurfaceMaterial function in taichi

To help you get started, we’ve selected a few taichi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yuanming-hu / taichi / projects / examples / rendering / fractals.py View on Github external
'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
github yuanming-hu / taichi / projects / examples / rendering / trashbin / veach_mis_scene.py View on Github external
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)
github yuanming-hu / taichi / projects / examples / rendering / trashbin / microfacet.py View on Github external
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)

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

  return scene
github yuanming-hu / taichi / projects / examples / rendering / geometry.py View on Github external
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
github yuanming-hu / taichi / projects / examples / rendering / trashbin / gunter_rambow.py View on Github external
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',
github yuanming-hu / taichi / projects / examples / rendering / bubbles.py View on Github external
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
github yuanming-hu / taichi / projects / examples / rendering / trashbin / sdf.py View on Github external
height=height,
      fov=70,
      aperture=0.1,
      focus=(0, 0, 0),
      origin=(10, 3, 10),
      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=(3, 3, 3),
        scale=0.1,
        rotation=(0, 0, 180))
    scene.add_mesh(mesh)

  return scene
github yuanming-hu / taichi / projects / examples / rendering / trashbin / gunter_rambow.py View on Github external
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