obj3.get_material().set_sheen(1) obj4.get_transform().set_position(visii.vec3(1.5, 0, 0)) obj4.get_transform().set_rotation(visii.quat(0.7071, 0.7071, 0, 0)) obj4.get_material().set_base_color(visii.vec3(.5, .5, .5)) obj4.get_material().set_roughness(0.7) obj4.get_material().set_specular(1) obj4.get_material().set_sheen(1) # Use linear motion blur on the first object... obj1.get_transform().set_linear_velocity(visii.vec3(.0, .0, .2)) # angular motion blur on the second object... obj2.get_transform().set_angular_velocity( visii.quat(1, visii.pi() / 16, visii.pi() / 16, visii.pi() / 16)) # and scalar motion blur on the third object obj3.get_transform().set_scalar_velocity(visii.vec3(-.5, -.5, -.5)) # # # # # # # # # # # # # # # # # # # # # # # # # visii.render_to_png(width=int(opt.width), height=int(opt.height), samples_per_pixel=int(opt.spp), image_path=f"{opt.out}") # let's clean up the GPU visii.cleanup()
areaLight1.get_transform().add_rotation(v.angleAxis(ry, v.vec3(0, 1, 0))) areaLight1.get_transform().add_rotation(v.angleAxis(rz, v.vec3(0, 0, 1))) interact(rotateLight, rx=(-3.14, 3.14, .001), ry=(-3.14, 3.14, .001), rz=(-3.14, 3.14, .001)) areaLight1.get_transform().set_scale(v.vec3(.25)) floor.get_transform().set_scale(v.vec3(100)) areaLight1.get_light().set_temperature(4000) # %% # %% v.render_to_png(512, 512, 1024, "area_light_3.png") # %% v.enable_denoiser() # %% # %% # %% floor.get_material().set_base_color(v.vec3(1.0)) mesh1.get_material().set_base_color(v.vec3(1.0)) mesh2.get_material().set_base_color(v.vec3(1.0)) # %% mesh1.get_material().set_base_color(v.vec3(1, 0, 0))
if r > 0: # for metallic and glass r2 = random.randint(0, 1) if r2 == 1: obj_mat.set_roughness(random.uniform(0, .1)) # default is 1 else: obj_mat.set_roughness(random.uniform(0.9, 1)) # default is 1 obj_mat.set_sheen(random.uniform(0, 1)) # degault is 0 obj_mat.set_clearcoat(random.uniform(0, 1)) # degault is 0 obj_mat.set_specular(random.uniform(0, 1)) # degault is 0 r = random.randint(0, 1) if r == 0: obj_mat.set_anisotropic(random.uniform(0, 0.1)) # degault is 0 else: obj_mat.set_anisotropic(random.uniform(0.9, 1)) # degault is 0 # create a random scene, the values are hard coded in the function defines the values for i in range(NB_OBJS): add_random_obj(str(i)) # # # # # # # # # # # # # # # # # # # # # # # # # visii.render_to_png(width=WIDTH, height=HEIGHT, samples_per_pixel=SAMPLES_PER_PIXEL, image_path=FILE_NAME) # let's clean up the GPU visii.cleanup()
"o" + str(i), visii.vec3(O_DIST * math.sin((i / NUM_OBJECTS) * twopi), O_DIST * math.cos((i / NUM_OBJECTS) * twopi), 1)) def create_sphere_light(name, position, intensity): L = visii.entity.create( name=name, light=visii.light.create(name), transform=visii.transform.create(name), mesh=visii.mesh.create_sphere(name), ) L.get_light().set_intensity(intensity) L.get_transform().set_position(position) L.get_transform().set_scale(.2) L.get_light().set_temperature(4000) for i in range(0, NUM_LIGHTS): twopi = math.pi * 2 create_sphere_light( "l" + str(i), visii.vec3(L_DIST * math.sin((i / NUM_LIGHTS) * twopi), L_DIST * math.cos((i / NUM_LIGHTS) * twopi), 1), 100000) visii.render_to_png(width=WIDTH, height=HEIGHT, samples_per_pixel=SAMPLES_PER_PIXEL, image_path="test_area_light_many_objects.png") input()
# We use frames per second here to internally convert velocity in meters / second into meters / frame. # The "mix" parameter smooths out the motion blur temporally, reducing flickering from linear motion blur obj_entity.get_transform().set_linear_velocity(dpos, frames_per_second, mix=.8) # visii quat expects w as the first argument new_rot = visii.quat(rot[3], rot[0], rot[1], rot[2]) drot = visii.vec3(_drot[0], _drot[1], _drot[2]) obj_entity.get_transform().set_rotation(new_rot) # Use angular velocity to blur the object in motion. Same concepts as above, but for # angular velocity instead of scalar. obj_entity.get_transform().set_angular_velocity(visii.quat(1.0, drot), frames_per_second, mix=.8) print(f'rendering frame {str(i).zfill(5)}/{str(opt.nb_frames).zfill(5)}') visii.render_to_png(width=int(opt.width), height=int(opt.height), samples_per_pixel=int(opt.spp), image_path=f"{opt.outf}/{str(i).zfill(5)}.png") p.disconnect() visii.cleanup() subprocess.call([ 'ffmpeg', '-y', '-framerate', '30', '-i', r"%05d.png", '-vcodec', 'libx264', '-pix_fmt', 'yuv420p', '../output.mp4' ], cwd=os.path.realpath(opt.outf))
tex = visii.texture.create_from_file("dome", "./content/teatro_massimo_2k.hdr") visii.set_dome_light_texture(tex, enable_cdf=True) visii.set_dome_light_intensity(0.8) visii.set_direct_lighting_clamp(10.0) visii.set_indirect_lighting_clamp(10.0) visii.set_max_bounce_depth(0, 0) visii.sample_pixel_area((.5, .5), (.5, .5)) # # # # # # # # # # # # # # # # # # # # # # # # # # First, let's render out the scene with motion blur to understand # how the object is moving visii.sample_time_interval((0.0, 1.0)) visii.render_to_png(width=opt.width, height=opt.height, samples_per_pixel=opt.spp, image_path=f"{opt.outf}/motion_blur.png" ) def save_image(data, name): img = Image.fromarray(np.clip((np.abs(data) ** (1.0 / 2.2))*255, 0, 255).astype(np.uint8)).transpose(PIL.Image.FLIP_TOP_BOTTOM) img.save(name) # Now let's render out the where the object is at time = 0 and time = 1 visii.sample_time_interval((0.0, 0.0)) # only sample at t = 0 t0_array = visii.render( width=opt.width, height=opt.height, samples_per_pixel=opt.spp, seed = 0 ) t0_array = np.array(t0_array).reshape(opt.height,opt.width,4)
light = visii.light.create("areaLight1"), transform = visii.transform.create("areaLight1"), mesh = sphere_mesh ) #%% areaLight1.get_transform().set_scale(.25) floor.get_transform().set_scale(1000) areaLight1.get_transform().set_position(0, 0, 4) mesh1.get_transform().set_position(-1.0, 1.0, 1.0) mesh2.get_transform().set_position(1.0, -1.0, 1.0) mesh3.get_transform().set_position(1.0, 1.0, 1.0) areaLight1.get_transform().set_scale(.3) # %% visii.set_dome_light_intensity(0) areaLight1.get_light().set_intensity(1000000.) areaLight1.get_light().set_temperature(5000) # %% visii.disable_denoiser() visii.render_to_png(1080,1080,64,"test_denoiser_off.png") # %% visii.enable_denoiser() visii.render_to_png(1080,1080,64,"test_denoiser_on.png") # %% visii.cleanup()