# Shadow map - how to properly create a render target? (SOLVED)

**URL:** <https://forum.defold.com/t/shadow-map-how-to-properly-create-a-render-target-solved/77816>\
**Category:** Questions\
**Created:** [August 19, 2024, 9:57am UTC](https://forum.defold.com/t/shadow-map-how-to-properly-create-a-render-target-solved/77816 "2024-08-19T09:57:27Z")\
**Posts on this page:** 3\
**Page:** 3

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [August 21, 2024, 12:07pm UTC](https://forum.defold.com/t/shadow-map-how-to-properly-create-a-render-target-solved/77816/41 "2024-08-21T12:07:06Z")

</div>

> [@Pawel](#):
>
> So it’s not only me that sees spotlight as “camera

A spotlight is generally specified using a cone (angle), and doesn’t have a ”near” plane.

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [August 21, 2024, 12:09pm UTC](https://forum.defold.com/t/shadow-map-how-to-properly-create-a-render-target-solved/77816/42 "2024-08-21T12:09:00Z")

</div>

> [@Mathias\_Westerdahl](#):
>
> A spotlight is generally specified using a cone (angle)

Ah, true, didn’t imagined it correctly 😕

But well, if it’s used to create a depth buffer, you generally want to render a bit more than what is visible (but as small as possible to utilise available resolution for the details the most).

In another video depth buffer is anyway slighlty larger than needed area, because it helps to solve issue regarding PCF, where penumbras are changing/flowing with every camera move (a shimmering effect):

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/b/7/b7a6e1309af2d5d040170f093faffbecd3d51c79.png)

(also PCF is nicely explained here):

[![](https://img.youtube.com/vi/uueB2kVvbHo/maxresdefault.jpg "How I Implemented Shadows in my Game Engine") ](https://www.youtube.com/watch?v=uueB2kVvbHo)

So that in it, the developer trick solved it by creating bigger depth buffer than main camera’s frustum:

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/9/c/9ca47579044c26e1af71cac86d1b5539c7a20b20.jpeg)

I just imagine in such a case, whether a frustum used for depth buffer is a cone or “truncated pyramid base” (or is there a proper mathematical name for this figure in English? xD)

(I’m bookmarking this topic, it became a cave of knowledge on shadows :D)

---

<div class="post-metadata">

**Author:** ![jhonny.goransson](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/jhonny.goransson/32/3864_2.png) [@jhonny.goransson](https://forum.defold.com/u/jhonny.goransson)\
**Post date:** [August 21, 2024, 12:26pm UTC](https://forum.defold.com/t/shadow-map-how-to-properly-create-a-render-target-solved/77816/43 "2024-08-21T12:26:15Z")

</div>

> [@Pawel](#):
>
> And when we `render.draw()` we should pass a frustum for culling, right? Uhm, but we can calculate it from `proj*view` from that camera, right? So yeah, no question 😃

Not necessary if you use the render.set\_camera function:

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/e/2/e2591dc9484e79a76742e274d3abf9060d1c168f.png)

[Previous page](https://forum.defold.com/t/shadow-map-how-to-properly-create-a-render-target-solved/77816.md?page=2)
