This code is designed for building previews of 3D models. So we aim at rendering many formats of 3D models robustly with acceptable quality.
- A light-weight offscreen renderer in C++.
- Fast to run.
- Run in command line.
- Support over 40+ common 3D formats such as OBJ, OFF and COLLADA.
- Support materials and textures.
First, install dependencies by apt-get:
sudo apt-get install libglew-dev libdevil-dev libassimp-dev freeglut3-dev libpng3 libsysfs-dev libudev-dev
Second, install Mesa3D (>=11.0.7):
wget ftp://ftp.freedesktop.org/pub/mesa/11.0.7/mesa-11.0.7.tar.gz
tar xvf mesa-11.0.7.tar.gz
cd mesa-11.0.7
./configure --enable-osmesa --disable-driglx-direct
make -j20
sudo make install
By default, this will install OSMesa to /usr/local
.
Note You may have other versions of Mesa3D installed before. Then you need to uninstall/remove/disable old versions, or set LD_LIBRARY_PATH
. Old versions of OSMesa might be found in /usr/lib/x86_64-linux-gnu
.
It is suggested that you set your LD_LIBRARY_PATH
as follows:
set LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Third, build the renderer by running
git clone [email protected]:ShapeNet/LightweightRenderer.git
cd LightweightRenderer
make
This will create an executable named render
Lastly, test your build by running
./render airplane.obj airplane.png
This should generate an image named airplane.png
as below:
run render
and help message appears.
Normal smoothing is not enabled. This is to avoid bad rendering when surface normals are incorrect.