Esempio n. 1
0
mesh1 = nvisii.entity.create(name="mesh1",
                             mesh=nvisii.mesh.create_teapotahedron("mesh1"),
                             transform=nvisii.transform.create("mesh1"),
                             material=nvisii.material.create("mesh1"))

mesh1.get_material().set_roughness(1.0)
mesh1.get_material().set_base_color((1.0, 0.0, 0.0))

mesh1.get_transform().set_position((-0.05, 0.0, 0), previous=True)
mesh1.get_transform().set_scale((0.1, 0.1, 0.1), previous=False)
mesh1.get_transform().set_scale((0.1, 0.1, 0.1), previous=True)
mesh1.get_transform().set_position((0.05, 0.0, 0), previous=False)

tex = nvisii.texture.create_from_file("dome",
                                      "./content/teatro_massimo_2k.hdr")
nvisii.set_dome_light_texture(tex, enable_cdf=True)
nvisii.set_dome_light_intensity(0.8)

nvisii.set_direct_lighting_clamp(10.0)
nvisii.set_indirect_lighting_clamp(10.0)
nvisii.set_max_bounce_depth(0, 0)
nvisii.sample_pixel_area((.5, .5), (.5, .5))

# # # # # # # # # # # # # # # # # # # # # # # # #
# First, let's render out the scene with motion blur to understand
# how the object is moving
nvisii.sample_time_interval((0.0, 1.0))
nvisii.render_to_file(width=opt.width,
                      height=opt.height,
                      samples_per_pixel=opt.spp,
                      file_path=f"{opt.outf}/motion_blur.png")
opt.height = 1080
opt.noise = False
opt.out = '15_camera_motion_car_blur.png'
opt.control = True

# # # # # # # # # # # # # # # # # # # # # # # # #
nvisii.initialize()
nvisii.set_dome_light_intensity(.8)
nvisii.resize_window(int(opt.width), int(opt.height))
# # # # # # # # # # # # # # # # # # # # # # # # #

# load the textures
dome = nvisii.texture.create_from_file("dome", "content/teatro_massimo_2k.hdr")

# we can add HDR images to act as dome
nvisii.set_dome_light_texture(dome)
nvisii.set_dome_light_rotation(
    nvisii.angleAxis(nvisii.pi() * .5, nvisii.vec3(0, 0, 1)))

car_speed = 0
car_speed_x = car_speed
car_speed_y = -2 * car_speed

camera_height = 80
# # # # # # # # # # # # # # # # # # # # # # # # #

if not opt.noise is True:
    nvisii.enable_denoiser()

camera = nvisii.entity.create(name="camera",
                              transform=nvisii.transform.create("camera"),
    at=random_camera_movement['at'],  # look at (world coordinate)
    up=random_camera_movement['up'],  # up vector
    eye=random_camera_movement['eye'],
)

visii.set_camera_entity(camera)

# # # # # # # # # # # # # # # # # # # # # # # # #

# lets turn off the ambiant lights
# load a random skybox
skyboxes = glob.glob(f'{opt.skyboxes_folder}/*.hdr')
skybox_random_selection = skyboxes[random.randint(0, len(skyboxes) - 1)]

dome_tex = visii.texture.create_from_file('dome_tex', skybox_random_selection)
visii.set_dome_light_texture(dome_tex)
visii.set_dome_light_intensity(random.uniform(1.1, 2))
# visii.set_dome_light_intensity(1.15)
visii.set_dome_light_rotation(
    # visii.angleAxis(visii.pi()/2,visii.vec3(1,0,0)) \
    # * visii.angleAxis(visii.pi()/2,visii.vec3(0,0,1))\
    visii.angleAxis(random.uniform(-visii.pi(),visii.pi()),visii.vec3(0,0,1))\
    # * visii.angleAxis(visii.pi()/2,visii.vec3(0,1,0))\
    # * visii.angleAxis(random.uniform(-visii.pi()/8,visii.pi()/8),visii.vec3(0,0,1))\
)

# # # # # # # # # # # # # # # # # # # # # # # # #
# Lets set some objects in the scene

mesh_loaded = {}
objects_to_move = []