<p>It's useful to think of rays not as "tubes" or "cones" of vision, but as the units of bookkeeping of radiant power. This notion resembles that of photons: they also are emitted and detected as a whole, and, for a given frequency, light intensity is represented by density of these units, while the energy per unit doesn't change as the unit propagates.</p>

<p>Consider, for example, the well-known inverse-square law for intensity of light emitted by an isotropic source. Starting with $N$ rays emitted by a surface of area $A$, you'll see that these rays, propagating outwards, have more and more space between them – their density reduces, while number of them, $N$, remains the same (in empty space). Calculate average number of rays per unit surface at distance $r$, and you'll see that it's indeed proportional to $r^{-2}$.</p>

<p>Now, the above example was about forward ray tracing. Backward ray tracing is actually exactly the same, but the question of each ray is not "what object might absorb me?" – instead, it's "where could this unit of light come from?".</p>

CC BY-SA 4.0
2018-07-11T18:37:33.133Z
2018-07-11T18:37:33.133Z
Ruslan
<blockquote>
  <p>But with ray tracing we normally cast cylinder-like rays instead of cones.</p>
</blockquote>

<p>Rays aren't really cylinders: they're infinitely thin. This infinitely thin ray can be an approximation to the cone just as much as it can be an approximation to the cylinder.</p>

<blockquote>
  <p>If we assume that the intensities of the light sources are the same, so that one of the pixels would "see" white average color, the other must necessarily have a color tint ... Am I right in this?</p>
</blockquote>

<p>Sort of. Your left-hand diagram <em>doesn't</em> have a colour tint. Although it covers more of the red wall than the blue wall, both of them subtend the same solid angle from the camera's point of view. The same $\tfrac{1}{r^2}$ ratio between the amount of light included in the cone is exactly countered by the $\tfrac{1}{r^2}$ falloff of the light. If the world worked the way you describe, you could make anything brighter by moving it further away from your eye. The right-hand diagram would have a blue colour tint, because the blue light is closer, but this diagram is not how ray-tracing works.</p>

<p>There has been research in a few variants of <em>beam tracing</em>, where instead of tracing an infinitely thin ray, you trace a cylinder, or <em>cone tracing</em>, where you trace a cone or frustum as a simple approximation to the irregular solid that contributes to the pixel. The maths (and therefore the algorithm) are somewhat more complex (and therefore slower) than simple ray tracing, and then you have to deal with what happens when the cone partially intersects an object, and you have to use the same shape to approximate the continued path of the cone. These approaches never caught on.</p>

<p>Instead, supersampling with rays offers the same advantages as cone tracing but with the performance advantage of doing the same simple algorithm many times. You don't supersample by moving the origin of the rays, which would make a cylinder shape, but by varying the directions, which makes a cone shape. Instead of approximating that cone by a single ray along its axis, you're approximating it by (say) 32 rays spread throughout its volume.</p>

CC BY-SA 4.0
2018-07-10T09:14:22.217Z
*" but with the performance advantage of doing the same simple algorithm many times."* ... and the performance *disadvantage* of doing more rays ;-)
Simon F
CC BY-SA 4.0
2018-07-10T09:16:24.013Z
@SimonF I'd rather do four simple rays with no edge cases than one complex cone with special handling for partial occlusion; more if I have a GPU to do them on.
Dan Hulme
CC BY-SA 4.0
2018-07-10T10:39:28.787Z
No worries :-) It was a tongue-in-cheek remark. FWIW 30 years(!) ago I was developing an Amantides-style cone ray tracer (https://dl.acm.org/citation.cfm?id=808589).  There are certainly pros and cons to it compared to simple rays.
Simon F
CC BY-SA 4.0
2018-07-10T11:55:14.243Z
@SimonF Oh yeah, that trade-off was a lot different before SIMD and then GPUs made it cheap to trace a zillion coherent supersampling rays.
Dan Hulme
CC BY-SA 4.0
2018-07-10T08:59:04.867Z
2018-07-10T08:59:04.867Z
Dan Hulme
<p>Perspective projection (or at least non-orthogonal) is by far the most common in photo-realistic graphics. When we use perspective projection, the (equally thick) slices of volume visualized by each pixel get larger with the distance. But with ray tracing we normally cast cylinder-like rays instead of cones. It seems to me that this must make quite a difference to the results: consider the two fields of view of pixels: cone-like one at the LHS, and cylinder-like one at the RHS, the pixels are at the bottom:</p>

<p><a href="https://i.sstatic.net/X8rGB.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/X8rGB.jpg" alt="pixels"></a></p>

<p>The colored lines here represent walls of randomly-distributed light sources with the same density in each wall. If we assume that the intensities of the light sources are the same, so that one of the pixels would "see" white average color, the other must necessarily have a color tint, because the left one samples more red compared to blue than the right one.</p>

<p>Am I right in this? If so, why does then <em>ray</em> tracing work? Why don't we do "frustum tracing" or "cone tracing" to get the colors/illuminances right? And if I'm wrong, then what is my mistake?</p>

CC BY-SA 4.0
2018-07-10T02:17:40.093Z
Keep in mind that light intensity falls off with the square of distance, so neither of them would generate white, unless the intensities were set appropriately.
user1118321
CC BY-SA 4.0
2018-07-10T02:25:43.300Z
I wouldn't call the cylinder rays, more like infinitely thin rays that either fully hit or fully miss geometry.
PaulHK
<raytracing><color>
Why does _ray_ tracing work?
Ruslan
# Why does _ray_ tracing work?

(Asked by: username_0 on 2018-07-09)

Perspective projection (or at least non-orthogonal) is by far the most common in photo-realistic graphics. When we use perspective projection, the (equally thick) slices of volume visualized by each pixel get larger with the distance. But with ray tracing we normally cast cylinder-like rays instead of cones. It seems to me that this must make quite a difference to the results: consider the two fields of view of pixels: cone-like one at the LHS, and cylinder-like one at the RHS, the pixels are at the bottom:

[![pixels](https://i.sstatic.net/X8rGB.jpg)](https://i.sstatic.net/X8rGB.jpg)

The colored lines here represent walls of randomly-distributed light sources with the same density in each wall. If we assume that the intensities of the light sources are the same, so that one of the pixels would "see" white average color, the other must necessarily have a color tint, because the left one samples more red compared to blue than the right one.

Am I right in this? If so, why does then *ray* tracing work? Why don't we do "frustum tracing" or "cone tracing" to get the colors/illuminances right? And if I'm wrong, then what is my mistake?

**Tags:** raytracing, color

> **Comments:**
> **username_1**: Keep in mind that light intensity falls off with the square of distance, so neither of them would generate white, unless the intensities were set appropriately.  
> **username_2**: I wouldn't call the cylinder rays, more like infinitely thin rays that either fully hit or fully miss geometry.  

---

## 2 answers

### Answer by username_0 on 2018-07-11. Score: 1 | Accepted answer

It's useful to think of rays not as "tubes" or "cones" of vision, but as the units of bookkeeping of radiant power. This notion resembles that of photons: they also are emitted and detected as a whole, and, for a given frequency, light intensity is represented by density of these units, while the energy per unit doesn't change as the unit propagates.

Consider, for example, the well-known inverse-square law for intensity of light emitted by an isotropic source. Starting with $N$ rays emitted by a surface of area $A$, you'll see that these rays, propagating outwards, have more and more space between them – their density reduces, while number of them, $N$, remains the same (in empty space). Calculate average number of rays per unit surface at distance $r$, and you'll see that it's indeed proportional to $r^{-2}$.

Now, the above example was about forward ray tracing. Backward ray tracing is actually exactly the same, but the question of each ray is not "what object might absorb me?" – instead, it's "where could this unit of light come from?".


---

### Answer by username_3 on 2018-07-10. Score: 4

> But with ray tracing we normally cast cylinder-like rays instead of cones.

Rays aren't really cylinders: they're infinitely thin. This infinitely thin ray can be an approximation to the cone just as much as it can be an approximation to the cylinder.

> If we assume that the intensities of the light sources are the same, so that one of the pixels would "see" white average color, the other must necessarily have a color tint ... Am I right in this?

Sort of. Your left-hand diagram *doesn't* have a colour tint. Although it covers more of the red wall than the blue wall, both of them subtend the same solid angle from the camera's point of view. The same $\tfrac{1}{r^2}$ ratio between the amount of light included in the cone is exactly countered by the $\tfrac{1}{r^2}$ falloff of the light. If the world worked the way you describe, you could make anything brighter by moving it further away from your eye. The right-hand diagram would have a blue colour tint, because the blue light is closer, but this diagram is not how ray-tracing works.

There has been research in a few variants of *beam tracing*, where instead of tracing an infinitely thin ray, you trace a cylinder, or *cone tracing*, where you trace a cone or frustum as a simple approximation to the irregular solid that contributes to the pixel. The maths (and therefore the algorithm) are somewhat more complex (and therefore slower) than simple ray tracing, and then you have to deal with what happens when the cone partially intersects an object, and you have to use the same shape to approximate the continued path of the cone. These approaches never caught on.

Instead, supersampling with rays offers the same advantages as cone tracing but with the performance advantage of doing the same simple algorithm many times. You don't supersample by moving the origin of the rays, which would make a cylinder shape, but by varying the directions, which makes a cone shape. Instead of approximating that cone by a single ray along its axis, you're approximating it by (say) 32 rays spread throughout its volume.

> **Comments:**
> **username_4**: *" but with the performance advantage of doing the same simple algorithm many times."* ... and the performance *disadvantage* of doing more rays ;-)  
> **username_3**: @username_4 I'd rather do four simple rays with no edge cases than one complex cone with special handling for partial occlusion; more if I have a GPU to do them on.  
> **username_4**: No worries :-) It was a tongue-in-cheek remark. FWIW 30 years(!) ago I was developing an Amantides-style cone ray tracer (https://dl.acm.org/citation.cfm?id=808589).  There are certainly pros and cons to it compared to simple rays.  
> **username_3**: @username_4 Oh yeah, that trade-off was a lot different before SIMD and then GPUs made it cheap to trace a zillion coherent supersampling rays.  

---

