0
$\begingroup$

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?

$\endgroup$
1
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$ Oct 23 '20 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.