Skip to content
A differentiable, 3D mesh renderer using TensorFlow.
Python C++ Shell
Branch: master
Clone or download

Latest commit

fcole Merge pull request #1 from TerisGH/master
extended rasterize_clip_space to handle dynamic batch size of clip_space_vertices
Latest commit 4dbf294 Jun 11, 2019


Type Name Latest commit message Commit time
Failed to load latest commit information.
third_party Updating renderer to the latest version. Dec 20, 2017
.gitignore Updating renderer to the latest version. Dec 20, 2017 Initializing repo with boilerplate files. Aug 11, 2017
LICENSE Initializing repo with boilerplate files. Aug 11, 2017 Updating the rasterization algorithm. Jan 9, 2019
WORKSPACE Updating and actually staging the changes. Jan 3, 2019 Fixing the BUILD files to work with a binary tensorflow. Jan 3, 2019

This is a differentiable, 3D mesh renderer using TensorFlow.

This is not an official Google product.

The interface to the renderer is provided by and, which provide TensorFlow Ops that can be added to a TensorFlow graph. The internals of the renderer are handled by a C++ kernel.

The input to the C++ rendering kernel is a list of 3D vertices and a list of triangles, where a triangle consists of a list of three vertex ids. The output of the renderer is a pair of images containing triangle ids and barycentric weights. Pixel values in the barycentric weight image are the weights of the pixel center point with respect to the triangle at that pixel (identified by the triangle id). The renderer provides derivatives of the barycentric weights of the pixel centers with respect to the vertex positions.

Any approximation error stems from the assumption that the triangle id at a pixel does not change as the vertices are moved. This is a reasonable approximation for small changes in vertex position. Even when the triangle id does change, the derivatives will be computed by extrapolating the barycentric weights of a neighboring triangle, which will produce a good approximation if the mesh is smooth. The main source of error occurs at occlusion boundaries, and particularly at the edge of an open mesh, where the background appears opposite the triangle's edge.

The algorithm implemented is described by Olano and Greer, "Triangle Scan Conversion using 2D Homogeneous Coordinates," HWWS 1997.

How to Build

Follow the instructions to install TensorFlow using virtualenv.

Build and run tests using Bazel from inside the (tensorflow) virtualenv:

(tensorflow)$ ./

The script calls the Bazel rules using the Python interpreter at $VIRTUAL_ENV/bin/python. If you aren't using virtualenv, bazel test ... may be sufficient.


If you use this renderer in your research, please cite this paper:

Unsupervised Training for 3D Morphable Model Regression. Kyle Genova, Forrester Cole, Aaron Maschinot, Aaron Sarna, Daniel Vlasic, and William T. Freeman. CVPR 2018, pp. 8377-8386.

  author = {Genova, Kyle and Cole, Forrester and Maschinot, Aaron and Sarna, Aaron and Vlasic, Daniel and Freeman, William T.},
  title = {Unsupervised Training for 3D Morphable Model Regression},
  booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  month = {June},
  year = {2018}
You can’t perform that action at this time.