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

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

        envmap_texture = Texture('sky', height=0.5, direction=0.3)
        envmap_texture.show(res=(500, 500), post_processor=LDRDisplay())
        envmap = EnvironmentMap('base',
                                texture=envmap_texture.id,
                                res=(1024, 1024))
        scene.set_environment_map(envmap)
    return scene
コード例 #2
0
import math
from taichi.misc.util import Vector
from taichi.visual import *
from taichi.visual.post_process import *
from taichi.visual.texture import Texture
import time

if __name__ == '__main__':
    while True:
        for i in range(100):
            envmap_texture = Texture('spherical_gradient',
                                     inside_val=(1, 1, 10, 1),
                                     outside_val=(0.5, 0.5, 0.5, 1),
                                     angle=3,
                                     sharpness=5)
            envmap_texture.show(res=(512, 512), post_processor=LDRDisplay())