Euclid
Geometry Processing and Shape Analysis in C++
|
A simple ray tracer. More...
#include <RayTracer.h>
Public Member Functions | |
RayTracer (int threads=0) | |
Create a ray tracer. More... | |
void | attach_geometry_buffers (const std::vector< float > &positions, const std::vector< unsigned > &indices) |
Attach shared geoemtry buffers to the ray tracer. More... | |
void | attach_color_buffer (const std::vector< float > *colors, bool vertex_color=false) |
Attach a shared color buffer to the ray tracer. More... | |
void | attach_face_mask_buffer (const std::vector< uint8_t > *mask) |
Attach a face maks buffer to the ray tracer. More... | |
void | release_buffers () |
Release all associated buffers. | |
void | set_material (const Material &material) |
Change the material of the model. | |
void | set_background (const Eigen::Ref< const Eigen::Array3f > &color) |
Change the color of background. | |
void | set_background (float r, float g, float b) |
Change the color of background. | |
void | enable_light (bool on) |
Enable or diable lighting. | |
void | render_shaded (std::vector< uint8_t > &pixels, const RayCamera &camera, int width, int height, bool interleaved=true) |
Render the mesh into a shaded image. More... | |
void | render_shaded (std::vector< uint8_t > &pixels, const RayCamera &camera, int width, int height, int samples, bool interleaved=true) |
Render the mesh into a shaded image. More... | |
void | render_depth (std::vector< uint8_t > &pixels, const RayCamera &camera, int width, int height) |
Render the mesh into a depth image. More... | |
void | render_depth (std::vector< float > &values, const RayCamera &camera, int width, int height) |
Render the mesh into a depth image. More... | |
void | render_silhouette (std::vector< uint8_t > &pixels, const RayCamera &camera, int width, int height) |
Render the mesh into a silhouette image. More... | |
void | render_index (std::vector< uint8_t > &pixels, const RayCamera &camera, int width, int height, bool interleaved=true) |
Render the mesh based on face index. More... | |
void | render_index (std::vector< uint32_t > &indices, const RayCamera &camera, int width, int height) |
Render the mesh based on face index. More... | |
This ray tracer could render several types of images of a triangle mesh.
|
inlineexplicit |
threads | Set to 0 to use number of hardware threads. |
|
inline |
Attach a color buffer storing either per-face colors or per-vertex colors. This buffer is mapped directly by the RayTracer so their lifetime should outlive the end of rendering. Attach another buffer will automatically release the previously attached one.
Note
The user is responsible of padding the positions buffer with one more float for Embree's SSE instructions to work correctly, if you are in vertex color mode. Otherwise the padding will not be necessary.
colors | A color array storing [r,g,b,r,g,b...] values of each elements. The values range in [0 1]. Set colors to nullptr to disable color buffering and fall back to the material. |
vertex_color | True for vertex color and false for face color. Default to false. |
|
inline |
This mask is used to filter out specified faces.
mask | The size of the array pointed by mask should be equal to the number of faces of the attached geometry. Set (*mask)[i] to 1 to enable face i in intersection, otherwise it will be ignored. Set mask to nullptr to disable masking. |
|
inline |
Attach both the positions and indices buffer. These buffers are mapped directly by the RayTracer so their lifetime should outlive the end of rendering. This class can only render one mesh at a time, so attaching another geometry will automatically release the previously attached geometry and all associated buffers.
Note
The user is responsible of padding the positions buffer with one more float for Embree's SSE instructions to work correctly.
positions | The geometry's positions buffer. |
indices | The geometry's indices buffer. |
|
inline |
The minimum depth value is mapped to 255 in image, and the maximum depth value is mapped to 0.
pixels | Output pixels. |
camera | Camera. |
width | Image width. |
height | Image height. |
|
inline |
The depth values are returned as they are, while the depth of the background is set to negative.
values | Output depth values. |
camera | Camera. |
width | Image width. |
height | Image height. |
|
inline |
Color each face base on its index, following
face_index = r + g << 8 + b << 16 - 1;
The background is set to 0, and the primitive index starts from 1. Due to bit width limitations, only 2^24 number of faces could be uniquely colored.
pixels | Output pixels. |
camera | Camera. |
width | Image width. |
height | Image height. |
interleaved | If true, pixels are stored like [RGBRGBRGB...], otherwise pixels are stored like [RRR...GGG...BBB...]. |
|
inline |
Each index is stored as a uint32_t value. The background is set to 0, and the primitive index starts from 1. Due to bit width limitations, the maximum number of indices supported is 2^32.
indices | The face indices of each pixel. |
camera | Camera. |
width | Image width. |
height | Image height. |
|
inline |
This function renders the mesh with simple lambertian shading, using a point light located at the camera position.
pixels | Output pixels |
camera | Camera. |
width | Image width. |
height | Image height. |
interleaved | If true, pixels are stored like [RGBRGBRGB...], otherwise pixels are stored like [RRR...GGG...BBB...]. |
|
inline |
This function renders the mesh with simple lambertian shading, using a point light located at the camera position. Random multisampling is enabled.
pixels | Output pixels |
camera | Camera. |
width | Image width. |
height | Image height. |
samples | Number of samples per pixel. |
interleaved | If true, pixels are stored like [RGBRGBRGB...], otherwise pixels are stored like [RRR...GGG...BBB...]. |
|
inline |
pixels | Output pixels. |
camera | Camera. |
width | Image width. |
height | Image height. |