def render_frame(frame_no, frame_count): from handsome.util import save_array_as_image time = 2 * frame_no / (frame_count - 1) if time > 1.: time = 2 - time set_time = load_sampler_lib()['set_time'] set_time(time) canvas = make_canvas({ 'extents' : (512, 512), 'color' : '#fff', }) surface = generate_surface() shader = generate_shader() mesh = generate_mesh(surface, shader) meshes = subdivide_mesh(mesh) for mesh in meshes: cache = render_mesh(mesh) cache.composite_into(canvas) buffer = array_view(canvas.downsample(1)) buffer = np.clip(buffer, 0., 1.) buffer = (255 * buffer).astype(np.uint8) frame_path = 'render/008/frame_{:03}.tiff'.format(frame_no) save_array_as_image(pixel_view(buffer), frame_path, 'RGBA') return frame_path
def render_scene(scene): canvas = make_canvas(scene.data['canvas']) meshes = extract_meshes(scene.data['top']) for mesh in meshes: cache = render_mesh(mesh) cache.composite_into(canvas) return canvas
def render_scene(scene, sample_rate=4, mesh_extractor=None): canvas = make_canvas(scene.data['canvas']) if mesh_extractor is None: mesh_extractor = MeshExtractor(scene) top = scene.data['top'] meshes = mesh_extractor.extract_meshes(top) meshes = list(meshes) for mesh in meshes: cache = render_mesh(mesh, sample_rate=sample_rate) cache.composite_into(canvas) return canvas
def main(): from handsome.util import save_array_as_image canvas = make_canvas({ 'extents' : (512, 512), 'color' : '#fff', }) surface = generate_surface() shader = generate_texture_shader() mesh = generate_mesh(surface, shader) cache = render_mesh(mesh) cache.composite_into(canvas) buffer = array_view(canvas.downsample(1)) buffer = np.clip(buffer, 0., 1.) buffer = (255 * buffer).astype(np.uint8) save_array_as_image(pixel_view(buffer), 'render/006_texture.tiff', 'RGBA')