Skip to content

Commit

Permalink
Merge pull request #39 from owl-project/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
natevm authored Jul 27, 2020
2 parents ecfec15 + 70ecf70 commit 0f67916
Show file tree
Hide file tree
Showing 58 changed files with 2,940 additions and 948 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ include\visii\utilities\version.h
include/visii/utilities/version.h
*.png
data
*.obj
*.mp4
*.hdr
*.jpg
*.mtl
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ find_program(BIN2C bin2c
/usr/local/cuda/bin)

# optix 7
set(OptiX_INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/optix-7.0.0/)
find_package(OptiX REQUIRED VERSION 7)
set(OptiX_INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/optix-7.1.0/)
find_package(OptiX REQUIRED VERSION 7.1)
include_directories(${OptiX_INCLUDE})

# owl
Expand Down Expand Up @@ -370,7 +370,7 @@ cuda_compile_and_embed(ptxCode ${SRC_CU})
# ┌──────────────────────────────────────────────────────────────────┐
# │ ViSII Library │
# └──────────────────────────────────────────────────────────────────┘
cuda_add_library(visii_lib SHARED ${SRC} ${HDR} ${ptxCode} OPTIONS -Xcudafe --diag_suppress=esa_on_defaulted_function_ignored)
cuda_add_library(visii_lib SHARED ${SRC} ${HDR} ${ptxCode} OPTIONS --expt-relaxed-constexpr -Xcudafe --diag_suppress=esa_on_defaulted_function_ignored)
target_link_libraries(visii_lib ${LIBRARIES})
set_target_properties(visii_lib PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS true)
install(TARGETS visii_lib
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ A scene can be described in many ways, you can use our simple mesh definitions,
load a complex scene defined in an obj file.
ViSII can be used to export metadata about the scene, _e.g._, object segmentation.

[Documentation](https://owl-project.github.io/ViSII/).

<!--
This library provides a simple, primarily python-user targeted, interface to rendering images of a virtual scene. Its key cornerstones are:
Expand Down
2 changes: 1 addition & 1 deletion examples/00.helloworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

input("Press Enter to continue...")

visii.cleanup()
visii.deinitialize()
2 changes: 1 addition & 1 deletion examples/01.simple_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@
)

# let's clean up the GPU
visii.cleanup()
visii.deinitialize()
2 changes: 1 addition & 1 deletion examples/02.random_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ def add_random_obj(name = "name"):
)

# let's clean up the GPU
visii.cleanup()
visii.deinitialize()
2 changes: 1 addition & 1 deletion examples/03.pybullet.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,6 @@
)

p.disconnect()
visii.cleanup()
visii.deinitialize()

subprocess.call(['ffmpeg', '-y', '-framerate', '30', '-i', r"%05d.png", '-vcodec', 'libx264', '-pix_fmt', 'yuv420p', '../output.mp4'], cwd=os.path.realpath(opt.outf))
2 changes: 1 addition & 1 deletion examples/04.load_obj_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@
)

# let's clean up the GPU
visii.cleanup()
visii.deinitialize()
2 changes: 1 addition & 1 deletion examples/05.lights.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,4 @@
)

# let's clean up the GPU
visii.cleanup()
visii.deinitialize()
2 changes: 1 addition & 1 deletion examples/06.textures.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@
)

# let's clean up the GPU
visii.cleanup()
visii.deinitialize()
2 changes: 1 addition & 1 deletion examples/07.procedural_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@
)

# let's clean up the GPU
visii.cleanup()
visii.deinitialize()
2 changes: 1 addition & 1 deletion examples/08.obj_scene_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@
)

# let's clean up the GPU
visii.cleanup()
visii.deinitialize()
50 changes: 41 additions & 9 deletions examples/09.meta_data_exporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
mesh = visii.mesh.create_teapotahedron("areaLight1"),
)
areaLight1.get_light().set_intensity(10000.)
areaLight1.get_light().set_temperature(4000)
areaLight1.get_light().set_temperature(8000)
areaLight1.get_transform().set_position(
visii.vec3(0, 0, 5))

Expand All @@ -93,22 +93,27 @@
material = visii.material.create("mesh1")
)

mesh1.get_material().set_metallic(0) # should 0 or 1
mesh1.get_material().set_transmission(0.8) # should 0 or 1
mesh1.get_material().set_roughness(0.2) # default is 1
mesh1.get_material().set_roughness(0.1)
mesh1.get_material().set_base_color(
visii.vec3(0.9, 0.2, 0.7))
visii.vec3(1.0, 0.0, 0.0))

mesh1.get_transform().set_position(
visii.vec3(0.0, 0.0, 0))
mesh1.get_transform().set_scale(
visii.vec3(0.1))

visii.set_dome_light_intensity(0)
# # # # # # # # # # # # # # # # # # # # # # # # #

# visii offers different ways to export meta data
# these are exported in HDR which offers very good
# storage for values.
# these are exported as raw arrays of numbers

# for many segmentations, it might be beneficial to only
# sample pixel centers instead of the whole pixel area.
# to do so, call this function
visii.sample_pixel_area(
x_sample_interval = visii.vec2(.5,.5),
y_sample_interval = visii.vec2(.5, .5))

depth_array = visii.render_data(
width=int(opt.width),
Expand Down Expand Up @@ -188,12 +193,39 @@
img = Image.fromarray((position_array*255).astype(np.uint8)).transpose(PIL.Image.FLIP_TOP_BOTTOM)
img.save(f"{opt.outf}/positions.png")

# motion vectors can be useful for reprojection

# induce motion, sample only at T=0
mesh1.get_transform().set_angular_velocity(visii.angleAxis(1.5, visii.vec3(0,0,1)))
visii.sample_time_interval(visii.vec2(0,0))
motion_vectors_array = visii.render_data(
width=int(opt.width),
height=int(opt.height),
start_frame=0,
frame_count=1,
bounce=int(0),
options="diffuse_motion_vectors"
)

# transform vectors to be between 0 and 1
motion_vectors_array = np.array(motion_vectors_array).reshape(opt.width,opt.height,4)
motion_vectors_array = (motion_vectors_array * .5) + .5

# save the segmentation image
img = Image.fromarray((motion_vectors_array*255).astype(np.uint8)).transpose(PIL.Image.FLIP_TOP_BOTTOM)
img.save(f"{opt.outf}/diffuse_motion_vectors.png")

# for the final image, sample the entire pixel area to anti-alias the result
visii.sample_pixel_area(
x_sample_interval = visii.vec2(0.0, 1.0),
y_sample_interval = visii.vec2(0.0, 1.0))
visii.set_direct_lighting_clamp(10.0)
visii.set_indirect_lighting_clamp(10.0)
visii.render_to_png(
width=int(opt.width),
height=int(opt.height),
samples_per_pixel=int(opt.spp),
image_path=f"{opt.outf}/img.png"

)

visii.render_to_hdr(
Expand All @@ -204,4 +236,4 @@
)

# let's clean up the GPU
visii.cleanup()
visii.deinitialize()
6 changes: 3 additions & 3 deletions examples/10.light_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
parser = argparse.ArgumentParser()

parser.add_argument('--spp',
default=256,
default=400,
type=int,
help = "number of sample per pixel, higher the more costly")
parser.add_argument('--width',
Expand Down Expand Up @@ -160,7 +160,7 @@
material = visii.material.create("sphere3")
)
sphere3.get_transform().set_position(
visii.vec3(0.6,-0.5,0.1))
visii.vec3(0.6,-0.5,0.16))
sphere3.get_transform().set_scale(
visii.vec3(0.16))
sphere3.get_material().set_base_color(
Expand Down Expand Up @@ -196,4 +196,4 @@
)

# let's clean up the GPU
visii.cleanup()
visii.deinitialize()
2 changes: 1 addition & 1 deletion examples/11.instance_motion_blur.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@
)

# let's clean up the GPU
visii.cleanup()
visii.deinitialize()
6 changes: 3 additions & 3 deletions examples/12.pybullet_motion_blur.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
# Use linear velocity to blur the object in motion.
# 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)
obj_entity.get_transform().set_linear_velocity(dpos, frames_per_second, mix = .7)

# visii quat expects w as the first argument
new_rot = visii.quat(rot[3], rot[0], rot[1], rot[2])
Expand All @@ -300,7 +300,7 @@

# 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)
obj_entity.get_transform().set_angular_velocity(visii.quat(1.0, drot), frames_per_second, mix = .7)

print(f'rendering frame {str(i).zfill(5)}/{str(opt.nb_frames).zfill(5)}')
visii.render_to_png(
Expand All @@ -311,6 +311,6 @@
)

p.disconnect()
visii.cleanup()
visii.deinitialize()

subprocess.call(['ffmpeg', '-y', '-framerate', '30', '-i', r"%05d.png", '-vcodec', 'libx264', '-pix_fmt', 'yuv420p', '../output.mp4'], cwd=os.path.realpath(opt.outf))
Loading

0 comments on commit 0f67916

Please sign in to comment.