<p>Hard shadows are simple that only needs a point light. </p>

<p>How it's done is by rendering the scene from the point of view of the light and only keep only the depth information. This is the shadow map.</p>

<p>Then when doing the actual rendering you calculate the point on the triangle in world space and find where it would be on the shadow map. Then you sample the depth from the shadowmap at that point and compare it to the distance to the light.</p>

<p>Soft shadows are harder. They require figuring out how close you are to the edge of what would be a hard shadow and adjusting the light value based on that. There are several techniques for that. One of which is simply sampling multiple times. </p>

CC BY-SA 3.0
2016-05-03T04:43:22.337Z
A image might do wonders.
joojaa
CC BY-SA 3.0
2016-05-02T20:16:32.843Z
2016-05-02T20:16:32.843Z
ratchet freak
<p>@ratchetfreak's answer describes shadow mapping, however, there's another not so difficult to implement way of drawing hard shadows. The <a href="https://en.wikipedia.org/wiki/Shadow_volume" rel="nofollow noreferrer"><em>shadow volume</em></a> technique uses extruded geometry plus some <a href="https://computergraphics.stackexchange.com/q/12/54">stencil buffer</a> tricks to simulate the area occluded by an object. The idea behind it is to generate a volume from the light source's perspective and then render it as you would render other geometry. The resulting shadow geometry will be as accurate as your graphics hardware is capable of rendering it, so the shadows will be very clear cut. There's no simple way of producing soft shadow edges with this technique though.</p>

<p><a href="https://i.sstatic.net/sRO84.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/sRO84.png" alt="shadow volume"></a></p>

CC BY-SA 3.0
2016-05-03T14:56:57.397Z
I'd upvote if there was also an example of a (possibly unrelated) soft shadow technique for contrast, as part of the question was what is the difference between them.
trichoplax is on Codidact now
CC BY-SA 3.0
2016-05-03T03:27:35.803Z
2016-05-03T03:27:35.803Z
2017-04-13T13:00:43.660Z
glampert
<p>I have been studying computer graphics, from the book <a href="http://rads.stackoverflow.com/amzn/click/1482229390" rel="nofollow">Fundamentals of Computer Graphic</a> (but the third edition), and I lastly read about texture mapping and shadow maps. Though, I didn't exactly understand how they function. I know there is also another type of texture map called projective texture map which allows to cast hard shadows, but how they function? On the other hand, how are soft shadows cast? And what's exactly the difference between hard and soft shadows?</p>

<texture><3d><shadow><shadow-mapping>
How are hard and soft shadows cast?
phong
# How are hard and soft shadows cast?

(Asked by: username_0 on 2016-05-02)

I have been studying computer graphics, from the book [Fundamentals of Computer Graphic](http://rads.stackoverflow.com/amzn/click/1482229390) (but the third edition), and I lastly read about texture mapping and shadow maps. Though, I didn't exactly understand how they function. I know there is also another type of texture map called projective texture map which allows to cast hard shadows, but how they function? On the other hand, how are soft shadows cast? And what's exactly the difference between hard and soft shadows?

**Tags:** texture, 3d, shadow, shadow-mapping


---

## 2 answers

### Answer by username_1 on 2016-05-02. Score: 3 | Accepted answer

Hard shadows are simple that only needs a point light.

How it's done is by rendering the scene from the point of view of the light and only keep only the depth information. This is the shadow map.

Then when doing the actual rendering you calculate the point on the triangle in world space and find where it would be on the shadow map. Then you sample the depth from the shadowmap at that point and compare it to the distance to the light.

Soft shadows are harder. They require figuring out how close you are to the edge of what would be a hard shadow and adjusting the light value based on that. There are several techniques for that. One of which is simply sampling multiple times.

> **Comments:**
> **username_2**: A image might do wonders.  

---

### Answer by username_3 on 2016-05-03. Score: 1

@username_1's answer describes shadow mapping, however, there's another not so difficult to implement way of drawing hard shadows. The [*shadow volume*](https://en.wikipedia.org/wiki/Shadow_volume) technique uses extruded geometry plus some [stencil buffer](https://computergraphics.stackexchange.com/q/12/54) tricks to simulate the area occluded by an object. The idea behind it is to generate a volume from the light source's perspective and then render it as you would render other geometry. The resulting shadow geometry will be as accurate as your graphics hardware is capable of rendering it, so the shadows will be very clear cut. There's no simple way of producing soft shadow edges with this technique though.

[![shadow volume](https://i.sstatic.net/sRO84.png)](https://i.sstatic.net/sRO84.png)

> **Comments:**
> **username_4**: I'd upvote if there was also an example of a (possibly unrelated) soft shadow technique for contrast, as part of the question was what is the difference between them.  

---

