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
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))) 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
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
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
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
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
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
def create_mpm_sand_block(fn): particles = tc_core.RenderParticles() assert particles.read(fn) downsample = grid_downsample tex = Texture.from_render_particles((255 / downsample, 255 / downsample, 255 / downsample), particles) * 5 # tex = Texture('sphere', center=(0.5, 0.5, 0.5), radius=0.5) with tc.transform_scope(scale=2): return tc.create_volumetric_block(tex, res=(128, 128, 128))
def create_mpm_snow_block(fn): particles = tc_core.RenderParticles() assert particles.read(fn) downsample = grid_downsample tex = Texture.from_render_particles( (511 / downsample, 127 / downsample, 255 / downsample), particles) * 5 # tex = Texture('sphere', center=(0.5, 0.5, 0.5), radius=0.5) with tc.transform_scope(translate=(0, -0.75, 0), scale=(2, 0.5, 1)): return tc.create_volumetric_block(tex, res=(256, 256, 256))
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
def create_volumetric_block(): fn = 'particles.bin' # or your file name... import os print(os.getcwd()) particles = tc.core.RenderParticles() assert particles.read(fn) # pls. use the same resolution as in the .bin file... res = (128, 128, 64) # 5 is the density tex = tc.Texture.from_render_particles(res, particles) * 15 with tc.transform_scope(scale=2): return tc.create_volumetric_block(tex, res=res)
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
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)))
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
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
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
# 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) # Light sources scene.add_mesh( tc.Mesh(tc.geometry.create_plane(), material=tc.SurfaceMaterial('emissive', color=(0.5, 1, 1)), scale=100, translate=(150, 100, -50), rotation=(180, 0, 0))) scene.add_mesh( tc.Mesh(tc.geometry.create_plane(),