<p>This is based on the formula for a sphere that expresses its surface $z$ as a function of $x, y$:
$$z(x, y) = \pm\sqrt{r^2 - x^2 - y^2}$$</p>

<p>So, if $x, y$ is the vector from the sphere's center to your sample point, the total length of the line segment (both occluded and unoccluded parts) is the distance between the top and bottom surfaces, which is $L = 2\sqrt{r^2 - x^2 - y^2}$. (This formula appears on slide 51 of that paper, BTW, although they've apparently scaled so that the radius is 1.)</p>

<p>Then, if you know the depth of the sample point relative to the sphere's center (call it $\Delta z$), you can calculate the fraction of the line that's occluded as
$$\frac{\tfrac{1}{2}L - \Delta z}{L}$$
or equivalently
$$\frac{1}{2} - \frac{\Delta z}{L}$$</p>

CC BY-SA 3.0
2017-01-08T20:27:29.750Z
2017-01-08T20:27:29.750Z
Nathan Reed
<p>I would like to compute volumetric obscurance with line integrals like described in <a href="http://advances.realtimerendering.com/s2010/Ownby,Hall%20and%20Hall%20-%20Toystory3%20(SIGGRAPH%202010%20Advanced%20RealTime%20Rendering%20Course).pdf" rel="nofollow noreferrer">this paper</a>.</p>

<p>For a 2D sample, it is possible to know the "depth in sphere". But I don't understand how they compute the occluded (in red on the following image) part and the unnoccluded (in yellow) part of the line in the sphere. </p>

<p>I think that they say that given the depth read through the sample and the "depth in sphere", we should be able to deduce each part of the lines.</p>

<p><a href="https://i.sstatic.net/eOLwt.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/eOLwt.png" alt="line sampling"></a></p>

<rendering><deferred-rendering>
Volumetric Obscurance : line integrals
user3596305
# Volumetric Obscurance : line integrals

(Asked by: username_0 on 2017-01-06)

I would like to compute volumetric obscurance with line integrals like described in [this paper](http://advances.realtimerendering.com/s2010/Ownby,Hall%20and%20Hall%20-%20Toystory3%20(SIGGRAPH%202010%20Advanced%20RealTime%20Rendering%20Course).pdf).

For a 2D sample, it is possible to know the "depth in sphere". But I don't understand how they compute the occluded (in red on the following image) part and the unnoccluded (in yellow) part of the line in the sphere.

I think that they say that given the depth read through the sample and the "depth in sphere", we should be able to deduce each part of the lines.

[![line sampling](https://i.sstatic.net/eOLwt.png)](https://i.sstatic.net/eOLwt.png)

**Tags:** rendering, deferred-rendering


---

## 1 answers

### Answer by username_1 on 2017-01-08. Score: 1 | Accepted answer

This is based on the formula for a sphere that expresses its surface $z$ as a function of $x, y$:
$$z(x, y) = \pm\sqrt{r^2 - x^2 - y^2}$$

So, if $x, y$ is the vector from the sphere's center to your sample point, the total length of the line segment (both occluded and unoccluded parts) is the distance between the top and bottom surfaces, which is $L = 2\sqrt{r^2 - x^2 - y^2}$. (This formula appears on slide 51 of that paper, BTW, although they've apparently scaled so that the radius is 1.)

Then, if you know the depth of the sample point relative to the sphere's center (call it $\Delta z$), you can calculate the fraction of the line that's occluded as
$$\frac{\tfrac{1}{2}L - \Delta z}{L}$$
or equivalently
$$\frac{1}{2} - \frac{\Delta z}{L}$$


---

