Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
DIRT: a fast differentiable renderer for TensorFlow
| Date | Stars |
|---|---|
| 2026-07-24 | 314 |
| 2026-07-25 | 314 |
| 2026-07-28 | 314 |
| 2026-07-30 | 314 |
| 2026-08-06 | 314 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# DIRT: a fast Differentiable Renderer for TensorFlow
DIRT is a library for TensorFlow, that provides operations for rendering 3D meshes.
It supports computing derivatives through geometry, lighting, and other parameters.
DIRT is very fast: it uses OpenGL for rasterisation, running on the GPU, which allows
lightweight interoperation with CUDA.
The following images illustrate the capabilities of DIRT; see
[`samples`](https://github.com/pmh47/dirt/tree/master/samples) for source
code. The first uses simple monochromatic diffuse lighting calculated per-vertex and
interpolated with Gouraud shading; the others use per-pixel (deferred) lighting and
texture calculations.
In all cases, we can calculate gradients with respect to all inputs, including the geometry
(vertex locations and normals), lighting parameters (e.g. colour and direction), and texture
(the vertex UVs and the pixel values in the texture itself).

## Citation
If you use DIRT in your research, please cite: [*Learning Single-Image 3D Reconstruction by Generative Modelling of Shape, Pose and Shading*](https://doi.org/10.1007/s11263-019-01219-8) (P. Henderson and V. Ferrari, IJCV 2019).
The appropriate bibtex entry is:
```
@article{henderson19ijcv,
title={Learning Single-Image {3D} Reconstruction by Generative Modelling of Shape, Pose and Shading},
author={Paul Henderson and Vittorio Ferrari},
journal={International Journal of Computer Vision},
year={2019},
doi={10.1007/s11263-019-01219-8},
url={https://doi.org/10.1007/s11263-019-01219-8}
}
```
There is a brief description of how DIRT calculates gradients in Section 3.4 of my [PhD thesis](http://calvin.inf.ed.ac.uk/wp-content/uploads/Publications/theses/Henderson2019.pdf), for the case of per-face Lambertian shading without textures.
## Why is DIRT useful?
Drawing 3D (or 2D) shapes *differentiably* is challenging in TensorFlow. For example, you could create a tensor containing a white square on a black background using the following:
```python
import tensorflow as tf
canvas_width, canvas_height = 128, 128
centre_x, centre_y = 32, 64
square_size = 16
xs, ys = tf.meshgrid(tf.range(canvas_width), tf.range(canvas_height))
x_in_range = tf.less_equal(tf.abs(xs - centre_x), square_size / 2)
y_in_range = tf.less_equal(tf.abs(ys - centre_y), square_size / 2)
pixels = tf.cast(tf.logical_and(x_in_range, y_in_range), tf.float32)
```
However, if you calculate gradients of the pixels with respect to `centre_x` and `centre_y`, they will always be zero -- whereas for most use-cases, they should be non-zero at the boundary of the shape.
DIRT provides a single TensorFlow operation, `rasterise`, that renders shapes differentiably. Moreover, it includes helper code that supports 3D projection, lighting, etc.
This allows full 2D or 3D scenes to be assembled directly in TensorFlow, with gradients flowing through the geometry, lighting and surface parameters.
Using DIRT, the above example becomes:
```python
import tensorflow as tf
import dirt
canvas_width, canvas_height = 128, 128
centre_x, centre_y = 32, 64
square_size = 16
# Build square in screen space
square_vertices = tf.constant([[0, 0], [0, 1], [1, 1], [1, 0]], dtype=tf.float32) * square_size - square_size / 2.
square_vertices += [centre_x, centre_y]
# Transform to homogeneous coordinates in clip space
square_vertices = square_vertices * 2. / [canvas_width, canvas_height] - 1.
square_vertices = tf.concat([square_vertices, tf.zeros([4, 1]), tf.ones([4, 1])], axis=1)
pixels = dirt.rasterise(
vertices=square_vertices,
faces=[[0, 1, 2], [0, 2, 3]],
vertex_colors=tf.ones([4, 1]),
background=tf.zeros([canvas_height, canvas_width, 1]),
height=canvas_height, width=canvas_width, channels=1
)[:, :, 0]
```
## Requirements
- an Nvidia GPU; the earliest drivers we have tested with are v367
- Linux; we have only tested on Ubuntu, but other distributions should work
- a GPExcerpt of 12,120 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:4719171231c1de4b, topic:tensorflow