3D Rendering Toolbox: Color image and depth map from mesh
Implementation of the computer graphics pipeline for triangulated meshes, in addition to a number of camera plotting functions. Handles both perspective and orthographic projection.
A notable use case is to simulate RGB or Kinect (depth) camera images for computer vision applications.
The codebase is compact, extensively documented, and uses only MATLAB built-in functions.
Name | Description |
---|---|
world2image |
Project world points, edges, and faces into image space. |
rasterize |
Rasterize projected mesh to form an image composed of pixels. |
raycast |
Compute rays from the camera's optical center to its pixels. |
clip |
Clip faces, edges, vertices in the clip space of the graphics pipeline. Used by world2image . |
edgefcn |
Test whether 2D points are within triangular faces. Used by rasterize . |
Camera |
Object for plotting a camera and storing its properties.
|
ProjectionMatrix |
Build and inspect a perspective or orthographic camera projection matrix.
|
For full documentation, please see the respective MATLAB file, or use the doc
command, e.g., doc world2image
.
Please see example.m
, which outputs the figure above.
-
The toolbox was designed to have only minimal internal dependencies. Therefore
Camera
,clip
,edgefcn
, etc. can largely be used independently of the rest of the toolbox. The toolbox's individual functions and classes could be useful for different rendering pipelines, for example, to rasterize 2D vector graphics, or beyond the computer graphics pipeline, for example, to simply plot the location of a camera within a scene. -
As the renderer runs on the CPU and uses only MATLAB code, its speed is limited. On a standard laptop, for a scene with 8000 faces and at a resolution of 300x300, I get around 12 fps. Nevertheless, for applications which don't need a high speed, having everything within MATLAB is handy.
-
Does not currently implement interpolated face colors (from colored vertices) or lighting.
-
If the user has a camera intrinsic matrix, rather than a projection matrix, e.g., when simulating a camera calibrated in MATLAB, the ProjectionMatrix class can be used to convert this to the necessary format.
Created in 2022b. All files are compatible with MATLAB release 2022a and later, but see the documentation of individual files for their specific compatability. Compatible with all platforms. No external dependencies.
Published under MIT License (see LICENSE.txt).
Please cite George Abrahams (https://github.com/WD40andTape/MatlabRenderer, https://www.linkedin.com/in/georgeabrahams).
引用格式
George Abrahams (https://www.linkedin.com/in/georgeabrahams) (2024). 3D Rendering Toolbox: Color image and depth map from mesh, GitHub. https://github.com/WD40andTape/MatlabRenderer.
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
2.1.0 | See release notes for this release on GitHub: https://github.com/WD40andTape/MatlabRenderer/releases/tag/2.1.0 |
||
1.2.0 | See release notes for this release on GitHub: https://github.com/WD40andTape/MatlabRenderer/releases/tag/1.2.0 |
||
1.1.0 | See release notes for this release on GitHub: https://github.com/WD40andTape/MatlabRenderer/releases/tag/1.1.0 |
||
1.0.0 |