Skip to content

Commit

Permalink
Merge pull request #73 from owl-project/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
natevm authored Nov 13, 2020
2 parents 377d6ec + 26861d0 commit 5ee8821
Show file tree
Hide file tree
Showing 52 changed files with 17,690 additions and 1,143 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ data
*.jpg
*.mtl
*.zip
*.exr
*__pycache__
examples/content
examples\content
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "externals/assimp"]
path = externals/assimp
url = https://github.com/n8vm/assimp.git
[submodule "externals/gli"]
path = externals/gli
url = https://github.com/g-truc/gli.git
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ option(NVCC_VERBOSE "verbose cuda -> ptx -> embedded build" OFF)

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# Enable c++11 and hide symbols which shouldn't be visible
message(WARN "ENABLING FPIC")
# message(WARN "ENABLING FPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" CACHE STRING "" FORCE)
endif()

Expand Down Expand Up @@ -189,8 +189,8 @@ if (MSVC AND NOT Python_LIBRARIES)
endif()
include_directories(SYSTEM ${Python_INCLUDE_DIRS})
include_directories(SYSTEM ${Python_NumPy_INCLUDE_DIRS})
message(WARN "Numpy Include Dir is: ")
message(WARN ${Python_NumPy_INCLUDE_DIRS})
# message(WARN "Numpy Include Dir is: ")
# message(WARN ${Python_NumPy_INCLUDE_DIRS})
if (NOT EXISTS ${Python_NumPy_INCLUDE_DIRS})
message(ERROR "ERROR, numpy include dir does not exist!")
endif()
Expand All @@ -199,6 +199,10 @@ if (NOT EXISTS ${Python_NumPy_INCLUDE_DIRS}/numpy/arrayObject.h)
message(ERROR "ERROR, arrayObject does not exist!")
endif()

# gli
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/externals/gli)


# glm
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/externals/glm)

Expand Down
31 changes: 26 additions & 5 deletions docs/source/visii.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,42 @@ Visii
=================================
.. automodule:: visii
:members:
initialize_interactive,
initialize_headless,
cleanup,
initialize,
clear_all,
deinitialize,
register_pre_render_callback,
set_camera_entity,
set_dome_light_intensity,
set_dome_light_exposure,
set_dome_light_color,
set_dome_light_sky,
set_dome_light_texture,
clear_dome_light_texture,
set_dome_light_rotation,
set_indirect_lighting_clamp,
set_direct_lighting_clamp,
set_max_bounce_depth,
resize_window,
set_light_sample_count,
sample_pixel_area,
sample_time_interval,
enable_denoiser,
disable_denoiser,
render,
render_to_hdr,
render_to_png,
render_data,
import_obj
render_data_to_file,
import_scene,
get_scene_min_aabb_corner,
get_scene_max_aabb_corner,
get_scene_aabb_center,
enable_updates,
disable_updates,
are_updates_enabled,
resize_window,
get_window_size,
should_window_close,
is_button_pressed,
is_button_held,
get_cursor_pos,
set_cursor_mode
7 changes: 5 additions & 2 deletions examples/00.helloworld.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# 00.helloworld.py
#
# This example will create a window where you
# should only see a gaussian noise pattern

import visii

# this will create a window where you should
# only see gaussian noise pattern
visii.initialize()

input("Press Enter to continue...")
Expand Down
99 changes: 32 additions & 67 deletions examples/01.simple_scene.py
Original file line number Diff line number Diff line change
@@ -1,96 +1,67 @@
# 01.simple_scene.py
#
# This shows a sphere on top of a mirror floor.
# You should see how to set up a simple scene with visii, where light is
# provided by the dome.

import visii

SAMPLES_PER_PIXEL = 50
WIDTH = 500
HEIGHT = 500
USE_DENOISER = True
FILE_NAME = "tmp.png"
opt = lambda: None
opt.spp = 50
opt.width = 512
opt.height = 512
opt.out = '01_simple_scene.png'

# headless - no window
# verbose - output number of frames rendered, etc..
visii.initialize(headless = True, verbose = True)

# Uses a neural network to denoise ray traced
if USE_DENOISER: visii.enable_denoiser()
# Use a neural network to denoise ray traced
visii.enable_denoiser()

# First, lets create an entity that will serve as our camera.
camera = visii.entity.create(name = "camera")

# To place the camera into our scene, we'll add a "transform" component
# Note that all visii objects have a "name" that can be used for easy lookup later.
# These names must be unique per component-type, but can be reused across types.
# To place the camera into our scene, we'll add a "transform" component.
# (All visii objects have a "name" that can be used for easy lookup later.)
camera.set_transform(visii.transform.create(name = "camera_transform"))

# To make our camera entity act like a "camera", we'll add a camera component
camera.set_camera(
visii.camera.create_from_fov(
name = "camera_camera",
field_of_view = 0.785398, # note, this is in radians
aspect = float(WIDTH)/float(HEIGHT)
aspect = opt.width / float(opt.height)
)
)

# Finally, we'll select this entity to be the current camera entity.
# (visii can only use one camera at the time)
visii.set_camera_entity(camera)

# Lets place our camera in the scene to look at an object

# All positions and vectors are defined through a sequence of three numbers.
# That sequence can be specified using lists, tuples, through numpy,
# or using the built in visii.vec3 type:
# transform.set_position([x, y, z]) <- lists
# transform.set_position((x, y, z)) <- tuples
# transform.set_position(np.array([x, y, z])) <- numpy arrays
# transform.set_position(visii.vec3(x, y, z)) <- visii vec3 object

# note that visii quaternions are slightly out of order from a normal list
# transform.set_rotation([x, y, z, w]) <- lists
# transform.set_rotation(visii.quat(w, x, y, z)) <- visii quat object

# Lets set the camera to look at an object.
# We'll do this by editing the transform component,
# which functionally acts like the camera's "view" transform.
# (Note that any of the below three vectors can match any of
# the above mentioned patterns)
camera.get_transform().look_at(
at = (0, 0, 0.9), # at position
up = (0, 0, 1), # up vector
eye = (0, 5, 1) # eye position
)
# We'll do this by editing the transform component.
camera.get_transform().look_at(at = (0, 0, .9), up = (0, 0, 1), eye = (0, 5, 1))

# Next, lets at an object (a floor).
# For an entity to be visible to a camera, that entity
# must have a mesh component, a transform component, and a
# material component.
visii.entity.create(
floor = visii.entity.create(
name = "floor",
mesh = visii.mesh.create_plane("mesh_floor"),
transform = visii.transform.create("transform_floor"),
material = visii.material.create("material_floor")
)

# Lets make our floor act as a mirror
# we first get the material associated with our floor entity
# if you do not have a direct handler to the entity, you
# search for a specific entity, material, transform, etc.
# name.
mat = visii.material.get("material_floor")

# Lets change the color
# the colors are RGB and the values are expected to be between
# 0 and 1.
mat = floor.get_material()
# mat = visii.material.get("material_floor") # <- this also works

# Mirrors are smooth and "metallic".
mat.set_base_color((0.19,0.16,0.19))
# Lets now change the metallic propreties for shinyness
mat.set_metallic(1)
# to make sure we get a perfect mirror lets change the roughness
mat.set_roughness(0)

# we want to make sure our floor is large so let's update the
# scale of the object.
trans = visii.transform.get("transform_floor")

# the scale takes as input a vector of 3 numbers
# Make the floor large by scaling it
trans = floor.get_transform()
trans.set_scale((5,5,1))

# Let's also add a sphere
Expand All @@ -100,24 +71,18 @@
transform = visii.transform.create("sphere"),
material = visii.material.create("sphere")
)
# lets set the sphere up
sphere.get_transform().set_position((0,0,0.41))
sphere.get_transform().set_scale((0.4, 0.4, 0.4))
sphere.get_material().set_base_color((0.1,0.9,0.08))
sphere.get_material().set_roughness(0.7)
sphere.get_material().set_specular(1)


# # # # # # # # # # # # # # # # # # # # # # # # #
# now that we have a simple scene set up let's render it
print("rendering to", FILE_NAME)
visii.render_to_png(
width = WIDTH,
height = HEIGHT,
samples_per_pixel = SAMPLES_PER_PIXEL,
image_path = FILE_NAME
# Now that we have a simple scene, let's render it
print("rendering to", "01_simple_scene.png")
visii.render_to_file(
width = opt.width,
height = opt.height,
samples_per_pixel = opt.spp,
file_path = "01_simple_scene.png"
)

# let's clean up the GPU
visii.deinitialize()
print("done!")
Loading

0 comments on commit 5ee8821

Please sign in to comment.