Cannot set reflection for object (Pyrender)

42 Views Asked by At

I am using pyrender's example meshes for some experiment. The goal is to visualize the reflection of fuze (the soft drink object) on the floor. I tried modify both floor and fuze material properties, but still don't get the reflection. Anyone has experiences what should I do? I am using point light, which I think is right for reflection generation. I tried directional light as well, and can see clear shadow.

Code:

fuze_trimesh = trimesh.load('./models/fuze.obj')
fuze_mesh = Mesh.from_trimesh(fuze_trimesh)

wood_trimesh = trimesh.load('./models/wood.obj')
wood_mat = MetallicRoughnessMaterial(metallicFactor=0.5, roughnessFactor=0)
wood_mesh = Mesh.from_trimesh(wood_trimesh) #, material=wood_mat)
point_l = PointLight(color=np.ones(3), intensity=5000.0)

cam = PerspectiveCamera(yfov=(np.pi / 3.0))
cam_pose = np.array([
    [0.0,  -np.sqrt(2)/2, np.sqrt(2)/2, 1.0],
    [1.0, 0.0,           0.0,           -0.2],
    [0.0,  np.sqrt(2)/2,  np.sqrt(2)/2, 0.8],
    [0.0,  0.0,           0.0,          1.0]
])

lit_pose = np.array([
    [0.0,  -np.sqrt(2)/2, np.sqrt(2)/2, 1.0],
    [1.0, 0.0,           0.0,           -1.3],
    [0.0,  np.sqrt(2)/2,  np.sqrt(2)/2, 10.0],
    [0.0,  0.0,           0.0,          1.0]
])

scene = Scene(ambient_light=np.array([0.02, 0.02, 0.02, 2.0]))
fuze_node = Node(mesh=fuze_mesh, translation=np.array([0.3, 0.15, -np.min(fuze_trimesh.vertices[:,2])]), scale=(2.0, 2.0, 2.0))
scene.add_node(fuze_node)
wood_node = Node(mesh=wood_mesh, scale=(2.0, 2.0, 2.0))
scene.add_node(wood_node)
point_l_node = scene.add(point_l, pose=lit_pose)

r = OffscreenRenderer(viewport_width=640*2, viewport_height=480*2)
flags = RenderFlags.RGBA | RenderFlags.SHADOWS_DIRECTIONAL
color, depth = r.render(scene, flags=flags)

import matplotlib.pyplot as plt
plt.figure()
plt.imshow(color)
plt.show()

enter image description here

Share the effect of table reflection I hope to see.

enter image description here

0

There are 0 best solutions below