<p>Ambient occlusion is basically shooting out a large number of rays diffusely from a surface point. In a pipe some of the rays will intersect with the pipe itself, which means that this surface point will not receive as much ambience as points that don't have intersecting rays. The inside of the pipe vs the outside of the pipe will be different.</p>

CC BY-SA 4.0
2018-08-29T08:02:06.750Z
2018-08-29T08:02:06.750Z
beyond
<p>When you compute ambient occlusion (AO) for a point on an object's surface, you sample multiple directions and measure what fraction of them escape. That is, you're trying to approximate what fraction of the unit hemisphere is visible to that point on the surface. (Note that it's a unit <em>hemisphere</em> because half of the unit sphere is on the wrong side of the surface to start with.)</p>

<p>So in your pipe example, the outside of the pipe is not at all occluded. From every point on the outside, any ray fired in that hemisphere will escape without intersecting the object. All of the outside would be lit with 100% of the ambient light.</p>

<p>The inside is another matter. The inside of the end cap can only see a small circle of that hemisphere, through the other end of the pipe. The exact fraction depends on the radius and length of the pipe, but call it 10% for the example. 90% of rays fired from a point on the end cap will hit the inside of the cap, and the other 10% will escape along the length of the pipe and out of the other end. These points are 90% occluded, so they'll be lit with 10% of the ambient light.</p>

<p>Consider a point at the open end of the pipe, but on the inside. This point is 50% occluded. Half of the rays fired from it go into the pipe and intersect with it at some point. The other half go straight out and escape to the unit hemisphere. This point will be lit with 50% of the ambient light, and it's easy to see that the 50% will smoothly decrease to the 10% (or however much is the minimum) as you travel down the inside of the pipe towards the end cap, as less of that hole is visible.</p>

<p>The important point I think you misunderstood is that you measure or estimate what <em>fraction</em> of the unit hemisphere is visible from the point you're shading, not whether it's visible at all. Casting many rays and counting what fraction escape is one way of estimating this.</p>

CC BY-SA 4.0
2018-08-29T10:13:55.343Z
With "hemisphere on the wrong side of the surface" do you mean the bottom hemisphere? Why is it on the wrong side when in this scene there's no such thing like a ground?
yot
CC BY-SA 4.0
2018-08-29T10:35:57.877Z
@yot No, I mean the hemisphere that is back-facing with respect to the surface; the opposite side from the surface normal. Just like in direct lighting, each point can only be lit from half of space.
Dan Hulme
CC BY-SA 4.0
2018-08-29T13:37:16.987Z
Objects are made up of flat surfaces and flat surfaces have surface normals on both side, I think. Is the "front-facing" side of the surface the one the 'sees' the sky and not the interior of the object it belongs to?
yot
CC BY-SA 4.0
2018-08-29T14:13:31.167Z
If you consider a polygon mesh, it's usual for surfaces to have only one side and one surface normal: the back face is typically not drawn at all. This is because the inside of the surface isn't visible. What you said is possible too, but even then, you still have to light each side of the surface separately, otherwise surfaces could be illuminated by lights that are actually behind them. This is a much bigger discussion than just AO though.
Dan Hulme
CC BY-SA 4.0
2018-08-29T08:05:56.890Z
2018-08-29T08:05:56.890Z
Dan Hulme
<p>So, the german wikipedia states about ambient occlusion:<br><blockquote>The ambient occlusion method is based on the assumption that an object, a set of objects or an entire scene is surrounded by a unit sphere of light.</blockquote></p>

<p>Now, let's suppose we've got a scene in which the only object is a pipe, closed at one end, at the center of the scene. If I got this right, then to get the ambient occlusion this object would now be evenly light from every direction.</p>

<p>But wouldn't lighting the object evenly from everywhere mean that for every point in the pipe there would also be a ray of light that would directly reach it, leading to no ambient occlusion at all (no shadows inside the pipe)?</p>

<p>What did I get wrong here?</p>

<ambient-occlusion>
Ambient occlusion of a sole object in a scene
yot
# Ambient occlusion of a sole object in a scene

(Asked by: username_0 on 2018-08-29)

So, the german wikipedia states about ambient occlusion:

> The ambient occlusion method is based on the assumption that an object, a set of objects or an entire scene is surrounded by a unit sphere of light.

Now, let's suppose we've got a scene in which the only object is a pipe, closed at one end, at the center of the scene. If I got this right, then to get the ambient occlusion this object would now be evenly light from every direction.

But wouldn't lighting the object evenly from everywhere mean that for every point in the pipe there would also be a ray of light that would directly reach it, leading to no ambient occlusion at all (no shadows inside the pipe)?

What did I get wrong here?

**Tags:** ambient-occlusion


---

## 2 answers

### Answer by username_2 on 2018-08-29. Score: 4 | Accepted answer

When you compute ambient occlusion (AO) for a point on an object's surface, you sample multiple directions and measure what fraction of them escape. That is, you're trying to approximate what fraction of the unit hemisphere is visible to that point on the surface. (Note that it's a unit *hemisphere* because half of the unit sphere is on the wrong side of the surface to start with.)

So in your pipe example, the outside of the pipe is not at all occluded. From every point on the outside, any ray fired in that hemisphere will escape without intersecting the object. All of the outside would be lit with 100% of the ambient light.

The inside is another matter. The inside of the end cap can only see a small circle of that hemisphere, through the other end of the pipe. The exact fraction depends on the radius and length of the pipe, but call it 10% for the example. 90% of rays fired from a point on the end cap will hit the inside of the cap, and the other 10% will escape along the length of the pipe and out of the other end. These points are 90% occluded, so they'll be lit with 10% of the ambient light.

Consider a point at the open end of the pipe, but on the inside. This point is 50% occluded. Half of the rays fired from it go into the pipe and intersect with it at some point. The other half go straight out and escape to the unit hemisphere. This point will be lit with 50% of the ambient light, and it's easy to see that the 50% will smoothly decrease to the 10% (or however much is the minimum) as you travel down the inside of the pipe towards the end cap, as less of that hole is visible.

The important point I think you misunderstood is that you measure or estimate what *fraction* of the unit hemisphere is visible from the point you're shading, not whether it's visible at all. Casting many rays and counting what fraction escape is one way of estimating this.

> **Comments:**
> **username_0**: With "hemisphere on the wrong side of the surface" do you mean the bottom hemisphere? Why is it on the wrong side when in this scene there's no such thing like a ground?  
> **username_2**: @username_0 No, I mean the hemisphere that is back-facing with respect to the surface; the opposite side from the surface normal. Just like in direct lighting, each point can only be lit from half of space.  
> **username_0**: Objects are made up of flat surfaces and flat surfaces have surface normals on both side, I think. Is the "front-facing" side of the surface the one the 'sees' the sky and not the interior of the object it belongs to?  
> **username_2**: If you consider a polygon mesh, it's usual for surfaces to have only one side and one surface normal: the back face is typically not drawn at all. This is because the inside of the surface isn't visible. What you said is possible too, but even then, you still have to light each side of the surface separately, otherwise surfaces could be illuminated by lights that are actually behind them. This is a much bigger discussion than just AO though.  

---

### Answer by username_1 on 2018-08-29. Score: 3

Ambient occlusion is basically shooting out a large number of rays diffusely from a surface point. In a pipe some of the rays will intersect with the pipe itself, which means that this surface point will not receive as much ambience as points that don't have intersecting rays. The inside of the pipe vs the outside of the pipe will be different.


---

