Home

Awesome

OptixRenderer

An optix GPU based path tracer. This is the renderer built and used in the following 2 projects:

Please contact Zhengqin Li about any questions with regard to the renderer. Please consider citing the 2 papers if you find the renderer useful in your own project.

Dependencies and compiling the code

The requirements are almost the same as optix_advanced_samples. We also need opencv 2 for image processing. ccmake is needed to compile the code. Please check INTALL-LINUX.txt and INSTALL-WIN.txt for details. After compiling, the executable file will be ./src/bin/optixRenderer

Running the code

To run the code, use the following command

./src/bin/optixRenderer -f [shape_file] -o [output_file] -c [camera_file] -m [mode] --gpuIds [gpu_ids]

Other flags

There are some other flags to control the program.

Shape file

We use xml file to define the scene. The format will be very similar to mitsuba. The main elements of the shape file include integrator, sensor, material, shape and emitter. We will introduce how to define the 5 elements in details in the following. An example rendering file can be find in ./src/optixRenderer/cbox. A typical shape file will look like:

<?xml version="1.0" encoding="utf-8"?>

<scene version="0.5.0">
  <integrator .../>
  ...
  <sensor .../>
  ...
  <bsdf .../>
  ...
  <emitter ../>
  ...
  <shape ../>
  ...
</scene>

Integrator

Currently we only support path tracer. So the only acceptable way to define the integrator will be

<integrator type="path"/>

Sensor

We support three types of sensors, the panorama camera (envmap), the hemisphere camera (hemisphere) and the perspective camera (perspective). The sub-elements belong to sensor include

Following is an example of the xml file of a perspective sensor. The xml for envmap and hemisphere camera should be almost the same, except that fov and fovAxis is no longer useful.

<sensor type="perspective">
  <string name="fovAxis" value="x"/>
  <float name="fov" value="60.0"/>
  <transform name="toWorld">
    <lookAt origin="278, 273, -800" target="278, 273, -799" up="0, 1, 0"/>
  </transform>
  <sampler type="independent">
    <integer name="sampleCount" value="10000"/>
  </sampler>

  <film type="ldrfilm">
    <integer name="width" value="512"/>
    <integer name="height" value="512"/>
  </film>
</sensor>

Material

The renderer currently supports three kinds of materials: diffuse, phong and microfacet

Following is an example of phong material. Notice that the path to the texture should be absolute path.

<bsdf id="Model#317-1_material_28" type="phong">
  <texture name="diffuseReflectance" type="bitmap">
    <string name="filename" value="/home/exx/Zhengqin/SceneMaterial/Dataset/texture/wood_5.jpg"/>
  </texture>
  <rgb name="specularReflectance" value="0.43922 0.43922 0.43922"/>
  <float name="alpha" value="40.00000"/>
</bsdf>

Shape

Currently we support .obj file and .ply file formats. .mtl file is not supported so the material can only be defined in .xml file. However, we support using usemtl ... in .obj file so that you can have different materials for a single .obj file. Following is an example of a shape with two different materials. In .obj file, the material is defined using

...
usemtl Model#317-1_material_28
...
usemtl Model#317-1_material_29
...

The corresponding .xml file should be

<shape id="Model#317-1_object" type="obj">
  <string name="filename" value="/home/exx/Zhengqin/SceneMaterial/Dataset/house_obj_render/train/Shape__0004d52d1aeeb8ae6de39d6bd993e992/Model#317-1_object.obj"/>
  <bsdf id="Model#317-1_material_27" type="phong">
    <rgb name="diffuseReflectance" value="0.27843 0.27843 0.27843"/>
    <rgb name="specularReflectance" value="1.00000 1.00000 1.00000"/>
    <float name="alpha" value="300.00000"/>
  </bsdf>
  <bsdf id="Model#317-1_material_28" type="phong">
    <texture name="diffuseReflectance" type="bitmap">
      <string name="filename" value="/home/exx/Zhengqin/SceneMaterial/Dataset/texture/wood_5.jpg"/>
    </texture>
    <rgb name="specularReflectance" value="0.43922 0.43922 0.43922"/>
    <float name="alpha" value="40.00000"/>
  </bsdf>
</shape>

Notice that the id of brdf should be consistent with the material defined by usemtl commmand. We also support scale, translate and rotate an object. The format is exactly the same as mitsuba.

Emitter

We support three kinds of emitter, area light (area), point light (point), flash light (flash) and environment map (envmap).

Followings are examples of area light and envmap respectively.

<shape type="obj">
  <string name="filename" value="/home/exx/Zhengqin/SceneMaterial/Code/optix_advanced_samples/src/optixSUNCG/cbox/meshes/cbox_luminaire.obj"/>
  <emitter type="area">
    <rgb name="radiance" value="20.0 20.0 20.0"/>
  </emitter>
</shape>

<emitter type = "envmap">
  <string name="filename" value="/home/exx/Zhengqin/SceneMaterial/Code/optix_advanced_samples/src/optixSUNCG/cbox/envmap.hdr"/>
</emitter>

Examples

There are three .xml files in src/optixRenderer/cbox directory, which can be directly used for testing.

To be finished