<p>Instead of using a perspective projection you would use a <a href="https://en.wikipedia.org/wiki/Orthographic_projection">orthographic projection</a>.</p>

<p>Then the trick is to position the bounding box to in front of the normal camera.</p>

<p>An additional option is to add a <a href="https://en.wikipedia.org/wiki/Shear_mapping">skew/shear operation</a> so it maps the light direction to the vertical and keeps the horizontal ground plane horizontal.</p>

<p>This avoids leaving a large dead zone underground near the light source.</p>

CC BY-SA 3.0
2016-01-10T22:54:46.133Z
2016-01-10T22:54:46.133Z
ratchet freak
<p>I'm working on implementing <a href="http://www-ljk.imag.fr/Publications/Basilic/com.lmc.publi.PUBLI_Inproceedings@117681e94b6_1e9c7f4/clouds.pdf">Bruneton's cloud rendering paper</a>, which requires one to render a pair of depth maps, similar to how shadow mapping works. In this case, my light source is the sun (or possibly the moon), which I represent in my rendering engine as a normalized vector pointing in the direction of the sun or moon, which is essentially located at infinity from the current camera position.</p>

<p>Since the light source doesn't have a traditional "position," I'm having a little trouble determining how best to create the viewpoint transformations for the source. </p>

<p>Since I would also essentially use the same transformation for sun/moon shadowing, it'd kill two birds with one stone.</p>

<p>So my question is thus:
<strong>How can I generate a view transform for generating depth maps of area light sources located at infinity?</strong></p>

<c++><shadow-mapping><depth-map>
How should I generate the view position for a light at infinity when creating depth maps?
stix
# How should I generate the view position for a light at infinity when creating depth maps?

(Asked by: username_0 on 2016-01-10)

I'm working on implementing [Bruneton's cloud rendering paper](http://www-ljk.imag.fr/Publications/Basilic/com.lmc.publi.PUBLI_Inproceedings@117681e94b6_1e9c7f4/clouds.pdf), which requires one to render a pair of depth maps, similar to how shadow mapping works. In this case, my light source is the sun (or possibly the moon), which I represent in my rendering engine as a normalized vector pointing in the direction of the sun or moon, which is essentially located at infinity from the current camera position.

Since the light source doesn't have a traditional "position," I'm having a little trouble determining how best to create the viewpoint transformations for the source.

Since I would also essentially use the same transformation for sun/moon shadowing, it'd kill two birds with one stone.

So my question is thus:
**How can I generate a view transform for generating depth maps of area light sources located at infinity?**

**Tags:** c++, shadow-mapping, depth-map


---

## 1 answers

### Answer by username_1 on 2016-01-10. Score: 5 | Accepted answer

Instead of using a perspective projection you would use a [orthographic projection](https://en.wikipedia.org/wiki/Orthographic_projection).

Then the trick is to position the bounding box to in front of the normal camera.

An additional option is to add a [skew/shear operation](https://en.wikipedia.org/wiki/Shear_mapping) so it maps the light direction to the vertical and keeps the horizontal ground plane horizontal.

This avoids leaving a large dead zone underground near the light source.


---

