<p>I just looked at Wikipedia articles about Bilinear interpolation.
A tent filter is a kind of Bilinear interpolation.
A Bilinear interpolation interpolates on 2 dimensions.
It first linearly interpolates on one dimension and then the other.</p>

<p><a href="https://i.sstatic.net/8I67g.png" rel="noreferrer"><img src="https://i.sstatic.net/8I67g.png" alt="enter image description here"></a></p>

<p>When you look at this picture, it first does it on the column and then the row for example.</p>

<p>The reason why this could be better than averaging colors, is that when one of the points gets closer to the center than another one, it contributes more to the final color.
With averaging the colors, all the points contributes equally, even when one point is closer to the center than another point.</p>

<p>If all the 4 points are on fixed positions on a equal distance from the center, then you get exactly 25% contribution on all points, that's the same as averaging.</p>

<p>This means that when you implement anti aliasing by just rendering at 4 times higher resolution, and then down sampling it. The output between the 2 ways should be the same, as far as I understand it.</p>

<p>So, which filter should you use? Well, it depends on what you want and your situation. If you pick random sub pixel locations for your samples, then it might be better to use a Bilinear interpolation.
If all the points are fixed and you just render out at a higher resolution, then averaging could be useful.
In the end this is all just some sub pixel things that normally you don't or barely notice, so if there is some kind if AA, then it's good enough. But that's just my opinion and probably that of the average viewer of 3D animation or something like that.</p>

<p>A Bicubic interpolation gives you a smoother look.
Bicubic:
<a href="https://i.sstatic.net/iIlKX.png" rel="noreferrer"><img src="https://i.sstatic.net/iIlKX.png" alt="enter image description here"></a></p>

<p>Bilinear:
<a href="https://i.sstatic.net/HQDup.png" rel="noreferrer"><img src="https://i.sstatic.net/HQDup.png" alt="enter image description here"></a></p>

<p>Which is better? Well, it depends on what you like, and I don't think that there will be a huge difference.</p>

<p>My sources:
<a href="https://en.wikipedia.org/wiki/Reconstruction_filter#Image_processing" rel="noreferrer">https://en.wikipedia.org/wiki/Reconstruction_filter#Image_processing</a></p>

<p><a href="https://en.wikipedia.org/wiki/Bilinear_interpolation" rel="noreferrer">https://en.wikipedia.org/wiki/Bilinear_interpolation</a></p>

<p><a href="https://en.wikipedia.org/wiki/Bicubic_interpolation" rel="noreferrer">https://en.wikipedia.org/wiki/Bicubic_interpolation</a></p>

<p>(Images are from Wikipedia and are public domain)</p>

<p>I hope this helps, I just want to say that I am not a professional on this, I'm just somebody that just likes computer graphics stuff. It could be that I made some mistakes. If so, just say it and I change it!</p>

CC BY-SA 3.0
2016-08-18T22:49:47.863Z
2016-08-18T22:49:47.863Z
bram0101
<p>The theoretical ideal antialiasing filter for discretely sampled data is a <a href="https://en.wikipedia.org/wiki/Sinc_filter" rel="noreferrer">sinc filter</a>, because it perfectly removes all frequencies higher than the Nyquist frequency, while leaving alone all the lower ones. So, to some extent, we can expect antialiasing filters that more closely resemble the sinc filter to produce better-quality images.</p>

<p>The tent filter (triangle filter) certainly resembles the central peak of the sinc filter more closely than does the box filter:</p>

<p><img src="https://i.sstatic.net/PVdbP.png" alt="sinc, triangle, and box filters"></p>

<p>A bicubic filter (e.g. Mitchell-Netravali) could capture the shape of the sinc even more precisely, including its first two negative lobes.</p>

<p>The reality of filter selection is a bit more subtle than "approximate sinc as well as possible", since there are different kinds of artifacts that can be generated by "non-ideal" antialiasing filters, such as aliasing, overblurring, and ringing. Also, different filters may be more or less computationally expensive. So it's a game of trying to trade off the different artifacts against each other and against performance. Different scenes/images may favor one choice or another, and it's also partly an aesthetic judgement.</p>

<p>As for why smallpt uses a tent filter in particular, I would guess for a combination of performance (it's a quick filter to evaluate) and brevity—it can be done in a couple lines of code, while a bicubic filter would take a bunch more code.</p>

<p>Incidentally, smallpt actually uses a 2x2 subpixel grid and places a tent filter <em>at each subpixel</em>, then averages together the results of the four subpixels. So the overall effect is, curiously, that of the sum of four tents, which ends up looking like a pyramid with a flat top:</p>

<p><img src="https://i.sstatic.net/sU59F.png" alt="subpixel tent filters"></p>

<p>I'm not sure if this was intentional, or just happened to be the way it worked out. My guess is this results in a somewhat sharper image than if a single tent filter per pixel were used (because of the narrower support), but probably also more visible aliasing.</p>

CC BY-SA 3.0
2018-05-01T15:48:04.977Z
I can't help saying thanks! Acturally, I first understand this as stratified sampling with 4 strata. And I make the number of "strata" customizable, like 9, 16... Now, I know it is a "trapezoid" filter(not so common in other renderers). And as the number of my "strata" tends to be infinity, the filter becomes a box filter, where I'm painting the lily... Interesting!
chaosink
CC BY-SA 4.0
2023-01-12T20:38:17.330Z
Hi Nathan, in the first graph, the box filter should have a range [-0.5, 0.5] along the X axis.
chaosink
CC BY-SA 3.0
2016-08-20T02:08:19.910Z
2016-08-20T02:08:19.910Z
Nathan Reed
<p>The 99 lines of C path tracer <a href="http://www.kevinbeason.com/smallpt/">Smallpt</a> renders a 2x2 subpixel grid for each pixel it intends to render and then does a tent filter to combine them.</p>

<p>There is an interesting presentation explaining the code <a href="https://drive.google.com/file/d/0B8g97JkuSSBwUENiWTJXeGtTOHFmSm51UC01YWtCZw/view">here</a>, and it mentions the tent filter but doesn't explain why it's there.</p>

<p>Can anyone explain why a tent filter would be preferable in this case over a box blur (just averaging the samples)?</p>

<p>Would it be higher quality to go with something better than a tent filter, such as bicubic hermite interpolation?</p>

<pathtracing><filtering>
Why use a tent filter in path tracing?
Alan Wolfe
# Why use a tent filter in path tracing?

(Asked by: username_0 on 2016-08-18)

The 99 lines of C path tracer [Smallpt](http://www.kevinbeason.com/smallpt/) renders a 2x2 subpixel grid for each pixel it intends to render and then does a tent filter to combine them.

There is an interesting presentation explaining the code [here](https://drive.google.com/file/d/0B8g97JkuSSBwUENiWTJXeGtTOHFmSm51UC01YWtCZw/view), and it mentions the tent filter but doesn't explain why it's there.

Can anyone explain why a tent filter would be preferable in this case over a box blur (just averaging the samples)?

Would it be higher quality to go with something better than a tent filter, such as bicubic hermite interpolation?

**Tags:** pathtracing, filtering


---

## 2 answers

### Answer by username_2 on 2016-08-20. Score: 19 | Accepted answer

The theoretical ideal antialiasing filter for discretely sampled data is a [sinc filter](https://en.wikipedia.org/wiki/Sinc_filter), because it perfectly removes all frequencies higher than the Nyquist frequency, while leaving alone all the lower ones. So, to some extent, we can expect antialiasing filters that more closely resemble the sinc filter to produce better-quality images.

The tent filter (triangle filter) certainly resembles the central peak of the sinc filter more closely than does the box filter:

![sinc, triangle, and box filters](https://i.sstatic.net/PVdbP.png)

A bicubic filter (e.g. Mitchell-Netravali) could capture the shape of the sinc even more precisely, including its first two negative lobes.

The reality of filter selection is a bit more subtle than "approximate sinc as well as possible", since there are different kinds of artifacts that can be generated by "non-ideal" antialiasing filters, such as aliasing, overblurring, and ringing. Also, different filters may be more or less computationally expensive. So it's a game of trying to trade off the different artifacts against each other and against performance. Different scenes/images may favor one choice or another, and it's also partly an aesthetic judgement.

As for why smallpt uses a tent filter in particular, I would guess for a combination of performance (it's a quick filter to evaluate) and brevity—it can be done in a couple lines of code, while a bicubic filter would take a bunch more code.

Incidentally, smallpt actually uses a 2x2 subpixel grid and places a tent filter *at each subpixel*, then averages together the results of the four subpixels. So the overall effect is, curiously, that of the sum of four tents, which ends up looking like a pyramid with a flat top:

![subpixel tent filters](https://i.sstatic.net/sU59F.png)

I'm not sure if this was intentional, or just happened to be the way it worked out. My guess is this results in a somewhat sharper image than if a single tent filter per pixel were used (because of the narrower support), but probably also more visible aliasing.

> **Comments:**
> **username_3**: I can't help saying thanks! Acturally, I first understand this as stratified sampling with 4 strata. And I make the number of "strata" customizable, like 9, 16... Now, I know it is a "trapezoid" filter(not so common in other renderers). And as the number of my "strata" tends to be infinity, the filter becomes a box filter, where I'm painting the lily... Interesting!  
> **username_3**: Hi username_2, in the first graph, the box filter should have a range [-0.5, 0.5] along the X axis.  

---

### Answer by username_1 on 2016-08-18. Score: 5

I just looked at Wikipedia articles about Bilinear interpolation.
A tent filter is a kind of Bilinear interpolation.
A Bilinear interpolation interpolates on 2 dimensions.
It first linearly interpolates on one dimension and then the other.

[![enter image description here](https://i.sstatic.net/8I67g.png)](https://i.sstatic.net/8I67g.png)

When you look at this picture, it first does it on the column and then the row for example.

The reason why this could be better than averaging colors, is that when one of the points gets closer to the center than another one, it contributes more to the final color.
With averaging the colors, all the points contributes equally, even when one point is closer to the center than another point.

If all the 4 points are on fixed positions on a equal distance from the center, then you get exactly 25% contribution on all points, that's the same as averaging.

This means that when you implement anti aliasing by just rendering at 4 times higher resolution, and then down sampling it. The output between the 2 ways should be the same, as far as I understand it.

So, which filter should you use? Well, it depends on what you want and your situation. If you pick random sub pixel locations for your samples, then it might be better to use a Bilinear interpolation.
If all the points are fixed and you just render out at a higher resolution, then averaging could be useful.
In the end this is all just some sub pixel things that normally you don't or barely notice, so if there is some kind if AA, then it's good enough. But that's just my opinion and probably that of the average viewer of 3D animation or something like that.

A Bicubic interpolation gives you a smoother look.
Bicubic:
[![enter image description here](https://i.sstatic.net/iIlKX.png)](https://i.sstatic.net/iIlKX.png)

Bilinear:
[![enter image description here](https://i.sstatic.net/HQDup.png)](https://i.sstatic.net/HQDup.png)

Which is better? Well, it depends on what you like, and I don't think that there will be a huge difference.

My sources:
<https://en.wikipedia.org/wiki/Reconstruction_filter#Image_processing>

<https://en.wikipedia.org/wiki/Bilinear_interpolation>

<https://en.wikipedia.org/wiki/Bicubic_interpolation>

(Images are from Wikipedia and are public domain)

I hope this helps, I just want to say that I am not a professional on this, I'm just somebody that just likes computer graphics stuff. It could be that I made some mistakes. If so, just say it and I change it!


---

