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))) #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(
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(): 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=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, 0, 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
def create_scene(): downsample = 1 camera = tc.Camera('thinlens', res=(960 // downsample, 540 // downsample), 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