Euclid
Geometry Processing and Shape Analysis in C++
|
A simple rasterizer. More...
#include <Rasterizer.h>
Public Types | |
enum | SampleCount { SAMPLE_COUNT_1 = 0x00000001, SAMPLE_COUNT_2 = 0x00000002, SAMPLE_COUNT_4 = 0x00000004, SAMPLE_COUNT_8 = 0x00000008 } |
Public Member Functions | |
Rasterizer (uint32_t width=256, uint32_t height=256, SampleCount samples=SAMPLE_COUNT_1) | |
Create a rasterizer. More... | |
void | attach_position_buffer (const float *positions, size_t size) |
Attach a position buffer to the rasterizer. More... | |
void | attach_normal_buffer (const float *normals, size_t size) |
Attach a normal buffer to the rasterizer. More... | |
void | attach_color_buffer (const float *colors, size_t size) |
Attach a color buffer to the rasterizer. More... | |
void | attach_index_buffer (const unsigned *indices, size_t size) |
Attach an index buffer to the Rasterizer. More... | |
void | release_buffers () |
Release all associated buffers. | |
void | set_material (const Material &material) |
Change the material of the model. | |
void | set_light (const Light &light) |
Change the light settings. | |
void | set_background (const Eigen::Array3f &color) |
Change the color of background. | |
void | set_background (float r, float g, float b) |
Change the color of background. | |
void | set_image (uint32_t width, uint32_t height, SampleCount samples) |
Set the size and sampling of the resulting image. | |
void | render_shaded (const Eigen::Matrix4f &model, const RasCamera &camera, std::vector< uint8_t > &pixels, bool interleaved=true) |
Render the mesh into a shaded image. More... | |
void | render_unlit (const Eigen::Matrix4f &model, const RasCamera &camera, std::vector< uint8_t > &pixels, bool interleaved=true) |
Render the mesh into a unlit image. More... | |
void | render_depth (const Eigen::Matrix4f &model, const RasCamera &camera, std::vector< uint8_t > &pixels, bool interleaved=true, bool linear=true) |
Render the mesh into a depth image. More... | |
void | render_depth (const Eigen::Matrix4f &model, const RasCamera &camera, std::vector< float > &values, bool linear=true) |
Render the mesh into a depth image. More... | |
This rasterizer could render several types of images of a triangle mesh.
|
inline |
Essential vulkan setup goes here. There's no need for a window since all rendering happens offscreen. If your gpu is not suitable for rendering, an exception will be thrown.
|
inline |
If color buffer is provided, the rasterizer will use this buffer in the render_shaded and render_unlit functions. Otherwise, it will use the colors provided in the material.
colors | An array storing [r,g,b,r,g,b...] colors for each point. The values range in [0 1]. Set colors to nullptr to release the current buffer and fall back to the material. |
size | The size of the buffer. |
|
inline |
If index buffer is provided, the rasterizer will use indexed drawing mode. Otherwise, it will use plain drawing mode.
indices | An array storing [v1,v2,v3,v1,v2,v3...] indices for each triangle. Set indices to nullptr to release the current buffer and fall back to plain drawing mode. |
size | The size of the buffer. |
|
inline |
Normal buffer is requested in render_shaded.
normals | An array storing [x,y,z,x,y,z...] coordinates for each point. Set normal to nullptr to release the current buffer. |
size | The size of the buffer. |
|
inline |
User should at least provide this buffer for the rasterizer to render anything. The size of the position buffer determines how many vertices are drawn.
positions | An array storing [x,y,z,x,y,z...] coordinates for each point. Set position to nullptr to release the current buffer. |
size | The size of the buffer. |
|
inline |
The minimum depth value is mapped to 255 in image, and the maximum depth value is mapped to 0.
model | The model matrix. |
camera | Camera. |
pixels | Output pixels. |
interleaved | If true, pixels are stored like [RGBRGBRGB...], otherwise pixels are stored like [RRR...GGG...BBB...]. |
linear | If true, return linearized depth value, otherwise return z value as it is. |
|
inline |
The depth values are returned as they are, while the depth of the background is one.
model | The model matrix. |
camera | Camera. |
values | The depth values. |
linear | If true, return linearized depth value, otherwise return z value as it is. |
|
inline |
This function renders the mesh with simple lambertian shading, using a point light located at the camera position.
model | The model matrix. |
camera | Camera. |
pixels | Output pixels |
interleaved | If true, pixels are stored like [RGBRGBRGB...], otherwise pixels are stored like [RRR...GGG...BBB...]. |
|
inline |
Only show raw diffuse color or vertex color if provided.
model | The model matrix. |
camera | Camera. |
pixels | Output pixels. |
interleaved | If true, pixels are stored like [RGBRGBRGB...], otherwise pixels are stored like [RRR...GGG...BBB...]. |