コード例 #1
0
ファイル: 5_load_trimesh.py プロジェクト: vn-os/plotoptix
def main():

    rt = TkOptiX() # create and configure, show the window later

    rt.set_param(max_accumulation_frames=500)  # accumulate up to 100 frames
    rt.set_uint("path_seg_range", 6, 12)       # allow some more ray segments
    rt.set_background(0)                       # black background
    rt.set_ambient([0.1, 0.12, 0.15])          # some ambient light
    #rt.set_param(light_shading="Hard")        # nice, accurate caustics, but slower convergence

    exposure = 1; gamma = 2.2
    rt.set_float("tonemap_exposure", exposure)
    rt.set_float("tonemap_gamma", gamma)
    rt.add_postproc("Gamma")                   # gamma correction

    # setup materials:
    m_diffuse["VarFloat3"] = { "base_color": [ 0.85, 0.87, 0.89 ] }
    rt.update_material("diffuse", m_diffuse)

    m_dispersive_glass["VarFloat3"]["base_color"] = [ 100, 110, 120 ]
    rt.setup_material("glass", m_dispersive_glass)

    # read the scene:
    scene = trimesh.load("data/chemistry.glb")

    # upload meshes to the ray tracer
    for name in scene.geometry:
        mesh = scene.geometry[name]
        if name in ["bottle", "cap", "testtube"]:
            rt.set_mesh(name, mesh.vertices, mesh.faces, mat="glass", make_normals=True)
        else:
            rt.set_mesh(name, mesh.vertices, mesh.faces)

    # camera and light
    rt.setup_light("light1", pos=[6,7.5,-15], color=30, radius=2)
    rt.setup_camera("cam1", eye=[-2,5,-10], target=[-0.75,1.4,5], fov=23, glock=True)

    rt.start()
    print("done")
コード例 #2
0
ファイル: 5_load_multi_mesh.py プロジェクト: vn-os/plotoptix
def main():

    rt = TkOptiX()  # create and configure, show the window later

    rt.set_param(max_accumulation_frames=100)  # accumulate up to 100 frames
    rt.set_background(0.99)  # white background
    rt.set_ambient(0.25)  # some ambient light

    # setup materials:
    m_diffuse["VarFloat3"] = {"base_color": [0.15, 0.17, 0.2]}
    rt.update_material("diffuse", m_diffuse)

    m_matt_plastic["VarFloat3"]["base_color"] = [0.5, 0.1, 0.05]
    rt.setup_material("plastic", m_matt_plastic)

    rt.load_texture("wing", "data/wing.png")

    m_transparent_plastic["ColorTextures"] = ["wing"]
    rt.setup_material("transparent", m_transparent_plastic)

    rt.load_normal_tilt("transparent", "data/wing.png", prescale=0.002)

    # prepare dictionary and load meshes; note that both eyes and wings
    # are assigned with single material by providing only a part of
    # the mesh name:
    materials = {"eye": "plastic", "wing": "transparent"}
    rt.load_multiple_mesh_obj("data/fly.obj",
                              materials,
                              parent="head_Icosphere")

    # camera and light position auto-fit the scene geometry
    rt.setup_camera("cam1")
    d = np.linalg.norm(rt.get_camera_target() - rt.get_camera_eye())
    rt.setup_light("light1", color=10, radius=0.3 * d)

    rt.start()
    print("done")