<blockquote>
<p>How can we render the scene around the light by rendering it onto a sphere?</p>
</blockquote>
<p>Well, answer me this: how do you render a scene around a like by rendering a &quot;screen quad&quot;?</p>
<p>We're ultimately talking about deferred rendering, and what is being done is rendering the lighting pass. During the lighting pass, you read data from the gbuffers that tell you that pixel's position, normal, and any other information used by the lighting equation. The texel location you read this data from those gbuffers is just the fragment's location.</p>
<p>The point being made by the video is that the geometry you render to do a lighting pass <em>does not matter</em>. You are <em>only</em> using it to invoke the fragment shader over a region of the image. This is why rendering a full-screen quad works; you're executing the fragment shader over all of the pixels in the screen.</p>
<p>While that works, it does mean you're executing more fragment shader invocations than are strictly necessary for any particular light. Points that correspond to distances outside of the light's useful effect still have to have an FS executed on them.</p>
<p>A sphere is a useful way to pre-cull such fragments. The sphere's radius represents the useful range of effect for a light. Any fragments horizontally or vertically outside of this range don't get produced, since fragments are only produced by rasterizing the sphere. And because the sphere's vertices will be transformed by the same transformation matrix as the scene, and because you will turn on depth tests, you <em>also</em> can cull out cases that are outside of the light's useful range in depth (or at least, if they're closer to the camera than the light's effect).</p>
<p>But there are downsides of this approach. Spheres are complex objects, so there will typically be some overlap in terms of the number of helper fragment shader invocations being executed for a particular pixel. Of greater concern is using relatively high resolution spheres that appear very small on the screen.</p>
<p>Also, you can only execute a single light per FS invocation, instead of being able to bundle lots of lights together. This is especially important for deferred rendering on tile-based renderers.</p>

CC BY-SA 4.0
2020-10-23T01:00:59.250Z
Thanks! I see the purpose of using a bounding sphere in this case. But if we map the scene onto the three-dimensional sphere. Wouldn't it be like wrapping the paper with the image of our scene onto a globe? Maybe my issue is that I don't completely understand what is meant by mapping an image to sphere in this case and how it is done.
Lenny White
CC BY-SA 4.0
2020-10-23T00:31:46.323Z
2020-10-23T00:31:46.323Z
Nicol Bolas
<p>In this video <a href="https://youtu.be/0ckE-CZpXAo?t=445" rel="nofollow noreferrer">https://youtu.be/0ckE-CZpXAo?t=445</a>, it's suggested to render onto a sphere instead of screen quad to save computation time on lighting calculations. So you create a bounding sphere for each light and render onto it.</p>
<p>But I can't make sense of it. How can we render the scene around the light by rendering it onto a sphere?</p>

<opengl><rendering>
Rendering part of the scene inside bounding sphere
Lenny White
# Rendering part of the scene inside bounding sphere

(Asked by: username_0 on 2020-10-22)

In this video <https://youtu.be/0ckE-CZpXAo?t=445>, it's suggested to render onto a sphere instead of screen quad to save computation time on lighting calculations. So you create a bounding sphere for each light and render onto it.

But I can't make sense of it. How can we render the scene around the light by rendering it onto a sphere?

**Tags:** opengl, rendering


---

## 1 answers

### Answer by username_1 on 2020-10-23. Score: 1

> How can we render the scene around the light by rendering it onto a sphere?

Well, answer me this: how do you render a scene around a like by rendering a "screen quad"?

We're ultimately talking about deferred rendering, and what is being done is rendering the lighting pass. During the lighting pass, you read data from the gbuffers that tell you that pixel's position, normal, and any other information used by the lighting equation. The texel location you read this data from those gbuffers is just the fragment's location.

The point being made by the video is that the geometry you render to do a lighting pass *does not matter*. You are *only* using it to invoke the fragment shader over a region of the image. This is why rendering a full-screen quad works; you're executing the fragment shader over all of the pixels in the screen.

While that works, it does mean you're executing more fragment shader invocations than are strictly necessary for any particular light. Points that correspond to distances outside of the light's useful effect still have to have an FS executed on them.

A sphere is a useful way to pre-cull such fragments. The sphere's radius represents the useful range of effect for a light. Any fragments horizontally or vertically outside of this range don't get produced, since fragments are only produced by rasterizing the sphere. And because the sphere's vertices will be transformed by the same transformation matrix as the scene, and because you will turn on depth tests, you *also* can cull out cases that are outside of the light's useful range in depth (or at least, if they're closer to the camera than the light's effect).

But there are downsides of this approach. Spheres are complex objects, so there will typically be some overlap in terms of the number of helper fragment shader invocations being executed for a particular pixel. Of greater concern is using relatively high resolution spheres that appear very small on the screen.

Also, you can only execute a single light per FS invocation, instead of being able to bundle lots of lights together. This is especially important for deferred rendering on tile-based renderers.

> **Comments:**
> **username_0**: Thanks! I see the purpose of using a bounding sphere in this case. But if we map the scene onto the three-dimensional sphere. Wouldn't it be like wrapping the paper with the image of our scene onto a globe? Maybe my issue is that I don't completely understand what is meant by mapping an image to sphere in this case and how it is done.  

---

