The Softness Of Shadows

Reverend

Banned
Fixed global shadow techniques are unrealistic. You can't have hard-edged shadows (like stencils) everywhere. Type of lighting (sun, moon, heck fluorescent) says this isn't the case IRL. Distance-to-light, while depending on type of light source, also is a factor -- in certain conditions and environments, the sun can cast (close to) hard-edged shadows... but then this also depends on distance-to-shadow-from-eye.

I've made many closed-scene demos/benchmarks (for personal use) that never need to take this into consideration and I actually feel like a fool asking this... but how do/can we set different shadow "softness" depending on various factors/conditions/environments using the same render engine?
 
I'd say making the engine support point lights (produces sharp shadows) and area lights (soft shadows based on distance to the light) and some variations of both (spotlights and sun for example, but those could be faked with those two light types) is all one needs to create enough dynamic shadow magic to make people awe the lighting.

The softness of shadows come from the light source's relative size, couple of examples:

Sun is an area light, it's not just a dot on the sky but since it isn't very big light source either (relatively speaking of course) so the soft shadow effect with sun isn't very big, just a mild blur on the edges.

Car headlights are close to a point light since the actual bulb is usually really small and the light is just reflected towards. This results in fairly sharp shadows in all conditions even while the light's intensity changes.

Physically accurate lighting (simulating the actual wavelength of the light and its refraction in air mass) is of course a whole another issue to talk about but we're not there yet. I'd like to point out that I'm more of an artist than a coder thus I'm not very technical so some of my thoughts may seem a bit weird :)
 
Soft shadow is a similar effect to light sources what depth-of-field is to cameras.

Both are caused that because of the light source and the camera optics have finite size.
An infinately small light source would cast hard shadows whereas a camera with an infinitaly small optic would produce sharp image for all distances.

Some of the solutions of SS and DOF are also quite similar:

1. Brutal force

- For DOF render from multiple point of view (see Humus's second DOF demo).
- For SS render from multiple point light sources (or multiple directional sources for a very far away source such as the sun).

Pro: With sufficient samples it gives physically correct result.
Con: With to few samples you see multiple pictures (DOF), or multiple shadows (SS)
Con2: It's slow...

The variable parameter here is the size of the light source - that will determine how soft the shadow will be.

2. Adaptive blur (post process)

- For DOF render the scene & the scene depth and perform an adaptive blur based on the distance.
- For SS you can try to perform and adaptive blur based on the distance of the surface and the distance of the occluder - either when applying the shadow to the surface, or in post process.

Pro: Fast (scene is rendered only once)
Con: Non physically correct, so requires quite some tweeking and hacks to make it look ok.

The blur can be adjusted - altough the smoother the blur, the more samples you need to use in the blur filter to avoid visual errors.

---

There are other techniques for SS - but I leave that to others to mention.
 
Yeah, this is a really tough problem. A first approximation is to simply consider all lighting to be a combination of ambient + directional/spot lights. For example, a cloudy day would have lighting that is almost entirely ambient, whereas a cloudless day would have lighting (from the sun, at least) that is almost entirely directional. Indoors, soft lighting (such as in a supermarket, where you have many light sources) often results in little to no shadowing, and so would be primarily ambient as well.

A second approximation, then, would be to model many light sources for indoor soft lighting scenarios (since unlike the ideal "cloudy day" scenario you do see a hint of shadowing).

Beyond that, there may be some techniques for combining preprocessing with normal lighting to automate this balance between ambient and directional/spot lighting. One could have, for instance, a low-resolution 3D texture that gives information about ambient lighting in a region, and some sort of pre-computed shadow mask that gives shadowing information for static objects in a scene.

If you want to go further, you'd need to implement some sort of global illumination technique, probably utilizing ray tracing methods.
 
Chalnoth said:
If you want to go further, you'd need to implement some sort of global illumination technique, probably utilizing ray tracing methods.

Well you shouldn't do raytracing on 3D hardware - it's not very good at it.
You want to do a form of global illumination that's suitable for 3D hardware.
 
Hyp-X said:
Well you shouldn't do raytracing on 3D hardware - it's not very good at it.
You want to do a form of global illumination that's suitable for 3D hardware.
Care to either give us some more information about this, or post links to some relevant techniques?
 
Chalnoth said:
Hyp-X said:
Well you shouldn't do raytracing on 3D hardware - it's not very good at it.
You want to do a form of global illumination that's suitable for 3D hardware.
Care to either give us some more information about this, or post links to some relevant techniques?

PRT, Ambient Occlusion, those sorts of things.

Doom3 does a little bit of what you were talking about, but not for shadows. It uses a cube map (in hell I think) to do some better ambient lighting. It's very subtle.
 
You know, that's no clarification at all.

But yes, I think Doom 3 doesn't just use it for Hell, but also for any light source that is partially-occluded by static world geometry. And saying it's for lighting and not shadows is kind of an oxymoron.
 
Chalnoth said:
You know, that's no clarification at all.

But yes, I think Doom 3 doesn't just use it for Hell, but also for any light source that is partially-occluded by static world geometry. And saying it's for lighting and not shadows is kind of an oxymoron.

I'm talking about the ambient cube map lookup. Pretty sure it's used for "outside" too.

Not talking about projected shadows or anything like that.

"ambientLight.vfp"
 
Eh, I was talking about the "light projection texture" in the interaction shader, though now that I look at it does not use a cube map. I still assume it handles the same task, however, and is the reason why you will see in the game some alpha-test grates in front of light sources that project soft shadows quite nicely.
 
How does Pixar approach this for their movies? I ask because Carmack told me he'd approach this the way Pixar does (without too much elaboration by him).
 
Reverend said:
How does Pixar approach this for their movies? I ask because Carmack told me he'd approach this the way Pixar does (without too much elaboration by him).

They use shadow maps...the artists just manually set the bluriness of the shadows cast by specific lights. Not as realistic as ray-tracing, but it's good enough and renders much faster.
 
Hmm...

With performance being the THE limiting factor, would you guys agree that shadow buffers, with separate and discreet X-sampling for shadow blur/softness for separate scenes, is THE feature for now and the foreseeable feature? It's relatively cheap right now (and will become cheaper). Yes, we'd still need to do some hacks, if we use it "globally", in specific instances... but it really is [edit : is it really) THE shadow technique to use taking into account the reason I started this thread. [edit : left out the question mark...?].

PS. I emailed John with this thought of mine (shadow buffer being The One for the now and the near future) before I made this post and he concurred with me, again without the elaboration I was hoping for... I'm hoping for more input for [edit : from) the geniuses here.
 
XxStratoMasterXx said:
So he admits stencils weren't the right way or what?
Do you know how silly your question is?

I asked a question with my previous post. You didn't answer it. You only wanted to know what JC thinks/says/dreams.
 
Apologies Reverend! I didn't mean to sidetrack this thread.

In regards to the shadow maps, I think that if we were to use them globally now, I don't think it would be performance attractive, assuming we had to think about older DX9-class cards. But in limited instances (e.g. FarCry's shadowmaps) it can yield some nice results.
 
XxStratoMasterXx said:
So he admits stencils weren't the right way or what?

He admits that he built a stencil engine in order to make Doom 3 because that's what he envisioned for the look.
 
Back
Top