Skip to content

Commit

Permalink
Merge pull request #32 from owl-project/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
natevm authored Jul 17, 2020
2 parents acc78e8 + 70962b0 commit 4964e35
Show file tree
Hide file tree
Showing 36 changed files with 830 additions and 451 deletions.
12 changes: 4 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ include(${SWIG_USE_FILE})
# python
if (EXISTS ${Python_ROOT_DIR})
set(Python_FIND_STRATEGY "LOCATION")
message(WARN "${Python_ROOT_DIR}")
endif()

message(WARN "PYTHON_INCLUDE_DIR SET TO " ${PYTHON_INCLUDE_DIR})
message(WARN "PYTHON_LIBRARY SET TO " ${PYTHON_LIBRARY})
message(WARN "PYTHON_EXECUTABLE SET TO " ${PYTHON_EXECUTABLE})

# On windows, require finding python always.
# On unix, since we only require the include dir, it's useful to be able to specify this include
# dir on commandline when building artifacts on the CI machines. Don't find python if a custom include
# dir is specified.
if(WIN32 OR NOT Python_INCLUDE_DIRS)
set(PYTHON_VERSION "" CACHE STRING "Optional user-selected Python version")
if(PYTHON_VERSION)
Expand All @@ -148,9 +147,6 @@ else()
endif()
endif()

message(WARN "PYTHON_INCLUDE_DIRS SET TO " ${Python_INCLUDE_DIRS})
message(WARN "PYTHON_LIBRARIES SET TO " ${Python_LIBRARIES})

if (UNIX AND NOT Python_INCLUDE_DIRS)
message(FATAL_ERROR "Python development headers missing!"
"You probably dont have python 2.7 or later development headers installed on your system. It is possible to recover "
Expand Down
86 changes: 82 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,95 @@
# ViSII - A VIrtual Scene Imaging Interface

This library provides a simple, primarily python-user targetted, interface to rendering images of a virtual scene. Its key cornerstones are:
![ViSII domain randomization examples](https://imgur.com/5sfS6YD.jpg)

ViSII is a python-enabled ray tracing based renderer built on top of NVIDIA OptiX (C++/CUDA backend).
The tool allows you to define complex scenes: 3d meshes, object materials, lights, loading textures, _etc._, and render
them using ray tracing techniques.
A scene can be described in many ways, you can use our simple mesh definitions, use multiple obj files, or
load a complex scene defined in an obj file.
ViSII can be used to export metadata about the scene, _e.g._, object segmentation.


<!--
This library provides a simple, primarily python-user targeted, interface to rendering images of a virtual scene. Its key cornerstones are:
a) a relatively simple, RTX/OptiX-accelerated path tracer, and
b) a interface (available in both python and C) for declaring a scene, doing basic modifications to it, and rendering images
The two primary goals of this lirary are
The two primary goals of this lirary are
a) ease of use (in particular, for non-expert users, and from languages like python), and
b) ease of deployment (ie, allowing headless rendering, minimal dependenies, etc).
To be clear: There will be more sophisitcated renderers out there, as well as faster ones, better ones, etc;
the goal of _this_ project is to offer something that's easy to get started with.
-->
## Installing

We highly recommend that you use the pre-built wheels for python as follow:
```
pip install visii
```
Also make sure the NVIDIA drivers 451 (or above) are installed as well as CUDA 10.2 (or above) is installed.
If you need more information about how to install NVIDIA drivers and CUDA on Ubuntu please consult
[this](https://ingowald.blog/installing-the-latest-nvidia-driver-cuda-and-optix-on-linux-ubuntu-18-04/).


## Getting Started

We wrote 10 basic examples covering most of the functionalities of ViSII, [here](examples/).
You can also find more extensive documentation [here](https://owl-project.github.io/ViSII/).

## Building

Information on how to build to be added in near future.

<!-- Although we do not recommend building visii from scratch. Here are the rudimentary
requirements:
-->

## Docker

Here are the steps to build a docker image for ViSII.

```
cd docker
sudo sh get_nvidia_libs.sh
```

Since the CUDA docker image includes limited libs, this script adds the missing one for ViSII to run.
This could potentially cause problems if the docker image is deployed on a different system,
please make sure the NVIDIA drivers match on all your systems.

```
docker build . -t visii:07.20
```

You can run an example like follow,
make sure you change `/PATH/TO/ViSII/` to your path to the root of this repo.
```
docker run --gpus 1 -v /PATH/TO/ViSII/:/code visii:07.20 python examples/01.simple_scene.py
```
This will save a `tmp.png` in the root folder.

## Citation

If you use this tool in your research project, please cite as follows:

@misc{Morrical20visii,
author = {Nathan Morrical and Jonathan Tremblay and Stan Birchfield and Ingo Wald},
note= {\url{ https://github.com/owl-project/ViSII/ }},
title = {{ViSII}: VIrtual Scene Imaging Interface},
Year = 2020
}

## Extra examples

[Falling teapots](https://imgur.com/Fzjg7ZQ)

[Falling objects dans une salle de bain](https://imgur.com/BqSKTO7)

[Random camera pose around objects](https://imgur.com/79eMgUv)

## Code Structure
<!-- ## Code Structure
- submodules/ : external git submodule dependencies to build this
- visii/ : the (static) library that provides the renderer
Expand All @@ -35,4 +113,4 @@ todo: need (at least) the following samples
- same as before, but two scene (probably need way of "naming" objects when loading), with one rotating around the other
- same as before, but also render depth, and primID
- same as before, but also render depth, and primID -->
36 changes: 36 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM nvidia/cuda:10.2-runtime-ubuntu18.04


RUN apt-get update && apt-get install -y --no-install-recommends --allow-downgrades --allow-change-held-packages \
build-essential \
cmake \
git \
curl \
vim \
wget \
ca-certificates \
libjpeg-dev \
libpng-dev \
strace


RUN apt-get -qq update && apt-get -qq -y install curl bzip2 \
&& curl -sSL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o /tmp/miniconda.sh \
&& bash /tmp/miniconda.sh -bfp /usr/local \
&& rm -rf /tmp/miniconda.sh \
&& conda install -y python=3 \
&& conda update conda \
&& apt-get -qq -y remove curl bzip2 \
&& apt-get -qq -y autoremove \
&& apt-get autoclean \
&& rm -rf /var/lib/apt/lists/* /var/log/dpkg.log \
&& conda clean --all --yes

ENV PATH /opt/conda/bin:$PATH

RUN pip install visii

COPY nvidia/* /usr/lib/x86_64-linux-gnu/

WORKDIR "/code"

6 changes: 6 additions & 0 deletions docker/get_nvidia_libs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mkdir nvidia
cd nvidia/
cp /usr/lib/x86_64-linux-gnu/libnvoptix.so.1 .
cp /usr/lib/x86_64-linux-gnu/*nvidia* .
cd ../
cp ../examples/requirements.txt .
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion externals/owl
Submodule owl updated 52 files
+28 −18 CMakeLists.txt
+29 −14 README.md
+93 −12 owl/api/Buffer.cpp
+12 −2 owl/api/Buffer.h
+6 −3 owl/api/Context.cpp
+1 −14 owl/api/Context.h
+23 −3 owl/api/Group.cpp
+9 −1 owl/api/Group.h
+10 −0 owl/api/LaunchParams.cpp
+3 −0 owl/api/LaunchParams.h
+18 −0 owl/api/Object.cpp
+9 −40 owl/api/RayGen.cpp
+2 −5 owl/api/Texture.cpp
+24 −0 owl/api/Variable.cpp
+9 −4 owl/api/Variable.h
+55 −11 owl/api/impl.cpp
+16 −14 owl/common/cmake/configure_build_type.cmake
+28 −21 owl/common/cmake/configure_glfw.cmake
+2 −10 owl/common/cmake/configure_owl.cmake
+18 −10 owl/common/cmake/configure_tbb.cmake
+7 −1 owl/include/owl/common/math/LinearSpace.h
+11 −2 owl/include/owl/common/math/vec.h
+1 −1 owl/include/owl/common/owl-common.h
+2 −1 owl/include/owl/owl_device.h
+33 −0 owl/include/owl/owl_device_buffer.h
+264 −196 owl/include/owl/owl_host.h
+8 −8 owl/ll/Buffers.cpp
+36 −28 owl/ll/Device.cpp
+44 −26 owl/ll/Device.h
+30 −4 owl/ll/DeviceGroup.cpp
+3 −2 owl/ll/DeviceGroup.h
+49 −37 owl/ll/InstanceGroup.cpp
+86 −48 owl/ll/TrianglesGeomGroup.cpp
+43 −14 owl/ll/UserGeomGroup.cpp
+0 −21 owl/ll/c-api.cpp
+17 −17 samples/advanced/optix7course/SampleRenderer.cpp
+1 −1 samples/cmdline/s05-rtow/Materials.h
+2 −2 samples/cmdline/s05-rtow/deviceCode.cu
+1 −1 samples/common/owlViewer/CMakeLists.txt
+28 −1 samples/common/owlViewer/OWLViewer.cpp
+8 −1 samples/common/owlViewer/OWLViewer.h
+1 −1 samples/interactive/int10-texturedTriangles/CMakeLists.txt
+29 −0 samples/interactive/int11-rotatingBoxes/CMakeLists.txt
+104 −0 samples/interactive/int11-rotatingBoxes/deviceCode.cu
+61 −0 samples/interactive/int11-rotatingBoxes/deviceCode.h
+405 −0 samples/interactive/int11-rotatingBoxes/hostCode.cpp
+37 −0 samples/interactive/int12-switchingTextureSets/CMakeLists.txt
+130 −0 samples/interactive/int12-switchingTextureSets/deviceCode.cu
+70 −0 samples/interactive/int12-switchingTextureSets/deviceCode.h
+457 −0 samples/interactive/int12-switchingTextureSets/hostCode.cpp
+0 −2 tests/CMakeLists.txt
+0 −2 tests/t00-c99-compliant-header/CMakeLists.txt
8 changes: 7 additions & 1 deletion include/visii/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Entity : public StaticFactory {
/** @returns a string representation of the current component */
std::string toString();

/** Indicates whether or not any entities are "out of date" and need to be updated through the "update components" function*/
/** Indicates whether or not any entities are "out of date" and need to be updated through the "update components" function */
static bool areAnyDirty();

/** @returns True if the Entity has been modified since the previous frame, and False otherwise */
Expand Down Expand Up @@ -184,6 +184,12 @@ class Entity : public StaticFactory {
/** @returns a reference to the connected mesh component, or None/nullptr if no component is connected. */
Mesh* getMesh();

/**
* Objects can be set to be invisible to particular ray types:
* @camera Makes the object visible to camera rays
*/
void setVisibility(bool camera = true);

/** For internal use. Returns the mutex used to lock entities for processing by the renderer. */
static std::shared_ptr<std::mutex> getEditMutex();
};
15 changes: 15 additions & 0 deletions include/visii/entity_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@
#include <stdint.h>
#define MAX_ENTITIES 100000

#ifndef ENTITY_VISIBILITY_FLAGS
#define ENTITY_VISIBILITY_FLAGS
#define ENTITY_VISIBILITY_CAMERA_RAYS (1<<0)
// #define LIGHT_FLAGS_SHOW_END_CAPS (1<<1)
// #define LIGHT_FLAGS_CAST_SHADOWS (1<<2)
// #define LIGHT_FLAGS_USE_VSM (1<<3)
// #define LIGHT_FLAGS_DISABLED (1<<4)
// #define LIGHT_FLAGS_POINT (1<<5)
// #define LIGHT_FLAGS_SPHERE (1<<6)
// #define LIGHT_FLAGS_DISK (1<<7)
// #define LIGHT_FLAGS_ROD (1<<8)
// #define LIGHT_FLAGS_PLANE (1<<9)
#endif

struct EntityStruct {
int32_t initialized = 0;
int32_t transform_id = -1;
int32_t camera_id = -1;
int32_t material_id = -1;
int32_t light_id = -1;
int32_t mesh_id = -1;
int32_t visibilityFlags = 1;
};
1 change: 0 additions & 1 deletion include/visii/light_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ struct LightStruct {
float b = 0.f;
float intensity = 0.f;
int32_t color_texture_id = -1;
uint32_t flags = 0;
};
10 changes: 5 additions & 5 deletions include/visii/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,14 @@ class Material : public StaticFactory
float getTransmissionRoughness();

/**
* A grayscale bump map texture used to displace surface normals.
* A normal map texture used to displace surface normals.
*
* @param texture A grayscale texture containing a surface displacement between 0 and 1. G, B, and A channels are ignored.
* @param texture A texture containing a surface normal displacement between 0 and 1. A channel is ignored.
*/
void setBumpTexture(Texture *texture);
void setNormalMapTexture(Texture *texture);

/** Disconnects the Bump texture, reverting back to any existing constant Bump */
void clearBumpTexture();
/** Disconnects the normal map texture */
void clearNormalMapTexture();

// /* A uniform base color can be replaced with per-vertex colors as well. */
// void use_vertex_colors(bool use);
Expand Down
78 changes: 39 additions & 39 deletions include/visii/material_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,51 @@ using namespace glm;

/* Follows the disney BSDF */
struct MaterialStruct {
vec4 base_color; // 16 // Note: also contains alpha
vec4 subsurface_radius; // 32
vec4 subsurface_color; //48
vec4 base_color = vec4(0.f); // 16 // Note: also contains alpha
vec4 subsurface_radius = vec4(0.f); // 32
vec4 subsurface_color = vec4(0.f); //48

float subsurface; // 52
float metallic; // 56
float specular; // 60
float specular_tint; // 64
float roughness; // 68
float anisotropic; // 72
float anisotropic_rotation; // 76
float sheen; // 80
float sheen_tint; // 84
float clearcoat; // 88
float clearcoat_roughness; // 92
float ior; // 96
float transmission; // 100
float transmission_roughness; // 104
float subsurface = 0.f; // 52
float metallic = 0.f; // 56
float specular = 0.f; // 60
float specular_tint = 0.f; // 64
float roughness = 0.f; // 68
float anisotropic = 0.f; // 72
float anisotropic_rotation = 0.f; // 76
float sheen = 0.f; // 80
float sheen_tint = 0.f; // 84
float clearcoat = 0.f; // 88
float clearcoat_roughness = 0.f; // 92
float ior = 0.f; // 96
float transmission = 0.f; // 100
float transmission_roughness = 0.f; // 104

int32_t flags; // 116
int32_t volume_texture_id; // 108
int32_t transmission_roughness_texture_id; // 112
int32_t base_color_texture_id; // 120
int32_t roughness_texture_id; // 124
int32_t occlusion_texture_id; // 128
int32_t flags = 0; // 116
int32_t volume_texture_id = -1; // 108
int32_t transmission_roughness_texture_id = -1; // 112
int32_t base_color_texture_id = -1; // 120
int32_t roughness_texture_id = -1; // 124
int32_t occlusion_texture_id = -1; // 128


/* Addresses for texture mapped parameters */
int32_t alpha_texture_id; // 132
int32_t bump_texture_id; // 136
int32_t subsurface_color_texture_id; // 140
int32_t subsurface_radius_texture_id; // 144
int32_t subsurface_texture_id; // 148
int32_t metallic_texture_id; // 152
int32_t specular_texture_id; // 156
int32_t specular_tint_texture_id; // 160
int32_t alpha_texture_id = -1; // 132
int32_t normal_map_texture_id = -1; // 136
int32_t subsurface_color_texture_id = -1; // 140
int32_t subsurface_radius_texture_id = -1; // 144
int32_t subsurface_texture_id = -1; // 148
int32_t metallic_texture_id = -1; // 152
int32_t specular_texture_id = -1; // 156
int32_t specular_tint_texture_id = -1; // 160

int32_t anisotropic_texture_id; // 164
int32_t anisotropic_rotation_texture_id; // 168
int32_t sheen_texture_id; // 172
int32_t sheen_tint_texture_id; // 176
int32_t clearcoat_texture_id; // 180
int32_t clearcoat_roughness_texture_id; // 184
int32_t ior_texture_id; // 188
int32_t transmission_texture_id; // 192
int32_t anisotropic_texture_id = -1; // 164
int32_t anisotropic_rotation_texture_id = -1; // 168
int32_t sheen_texture_id = -1; // 172
int32_t sheen_tint_texture_id = -1; // 176
int32_t clearcoat_texture_id = -1; // 180
int32_t clearcoat_roughness_texture_id = -1; // 184
int32_t ior_texture_id = -1; // 188
int32_t transmission_texture_id = -1; // 192
// int32_t ph8_id; // 196
// int32_t ph8_id; // 200
// int32_t ph8_id; // 184
Expand Down
Loading

0 comments on commit 4964e35

Please sign in to comment.