Soft shadows, part II

My artists is still working on the scene’s modelling and textures, but i thought i might as well post a little update.

I’ve uploaded three screenshots here:

Any feedback is welcome :slight_smile:


Just one word: amazing!

I hope to see the demo in action soon and to read a description of your technique.

Great work, continue like that!


Are these actually soft shadows or blurred shadows?
Means that a true soft shadow is sharp near the occluder but get softer further away.

Wow, beautiful!

Mind if I ask if it’s the shadows or something else that’s causing the low framerate?

– Zeno

You can already read the description of my technic in one of the previous threads, 2 or 3 weeks ago… browse the forum to see it, it’s called “dynamic soft shadows” or something like that

As for the framerate: well, the bottlenecks so far are CPU and fillrate. CPU, because i’m extending the shadow volume vertices on the CPU, and i also calculate a sharpness coefficient for each vertex (see descr). This should be fixed when using vertex shaders, which i don’t yet.

The fillrate issue is more delicate. Shadow volumes cost a lot of fillrate for lights with a big radius, and my light is always moving, and very big (wanted to simulate the sun). Hence the scissor trick wouldn’t work well, and there’s very little i can do. I searched on the net how people save fillrate for lights with big radiuses, but i came up with an artical from Carmack saying that shadow volumes can, in some occasions, be pathetically fillrate intensive. I guess i found one. This could be fixed by using small lights, like in an indoor environment (so i guess Doom3 doesn’t have that pb… )


[This message has been edited by Ysaneya (edited 09-26-2002).]

You should post something with simple scene (no textures with glucylinder or something). Also use a lamp shining on the cylinder. The sun would be too far away and the shadow edge effect that was discussed would not be noticeable.

BTW, what’s the FPS with shadows turned off?


With standard “sharp” stencil shadows, it’s around 20 fps. I don’t have an option to completely disable the shadows, though :slight_smile:


For sunlight on the earth you should be seeing soft shadows with about half a degree penumbrae. If you want sunlight you should use a directional light and jitter the vector by half a degree in evenly distributed directions.


But for seeing the sharp to non-sharp effect of shadows (sharp near surface to object contact, non sharp elsewhere), the sun won’t demonstrate that. Maybe this wasn’t the goal?


Why would the sun not demonstrate this effect? It does not matter how far way the light source is, only how big it is relative to the occluder (from the point of view of the surface where the shadow is being cast).

You can skew a directional light the same as a point light.

[This message has been edited by Nakoruru (edited 09-27-2002).]


It does matter how far from the shadow recipient the shadow caster is, as the distance that the half-degree spread translates into is directly proportional to the distance between occluder and shadow recipient.


I was not talking about distance between the caster and recepient (and if I was, it was hidden inside my mention of relative size of light source and shadow caster).

I was refering to the fact that it does not matter how far away the LIGHT SOURCE is. It simply does not matter except that far away things tend to be smaller, but the sun is really huge and is less of a point light source than the small light bulbs I use in my living room i.e., the shadows in my living room are sharper than those outside.

It only matters how big the light source appears from the place where the shadow falls, and therefore how likely it is that that the light source will be partially occluded by the shadow caster.

But, you know this, because you thought you were correcting me…

Him, are we defining our terms that say way? A shadow caster is the object that is casting the shadow, not the light source. The shadow recepient is where the shadow falls.

My original question was retorical, I probably should have just stated directly that a sun can be used to demonstrate soft shadows quite well, it just depends on how big the sun is in the sky. A red giant would cast extremely soft shadows if it took up half the sky :slight_smile:

[This message has been edited by Nakoruru (edited 09-28-2002).]

[This message has been edited by Nakoruru (edited 09-28-2002).]

i would prefer tons of small lightsources somehow… as the chances that they move are more than for the normal sun so we could see the shadows more “in action”

or is there a day-night-circle in the demo? with about 10 secs for a day?

Well, i maybe said a mistake when my light was intended to simulate the sun. To be more precise, i wanted to have a sun-like lit scene. The light itself has a big radius compared to “indoors” lights, but it’s definately not infinite… something like 200 meters. In addition, it’s moving a lot randomly, so you very well see the shadows “in action”. But i’ll think about adding a few smaller lights. I’m not sure if it will be possible performance-wise, because so far, the scene is one single big object, so i cannot perform any optimization based on the object-is-outside-light-radius thing… snif.


yeah, one light is much simpler to optimize…

no problems with such a light, can’t wait for it

I have found the description of your technique and the principle sounds pretty easy and cool…I’m thinking about that but can’t see the way at the moment…how can you render to a 3d texture?

Thanks LaBasX2

If you find a way, tell me :slight_smile:

Seriously, i just render to the framebuffer and copy it to a fixed level of the 3D texture. It’s very fast with the latest drivers.


Ok, thanks, I see…

One more thing, how are you getting the blurred texures in hardware? My guess would be your’re generating mipmaps but wouldn’t that be slow?


That’s not too hard, i think there’s some PDFs on NVidia’s web site (maybe on ATI’s too). You just apply a filter to the texture. In my case i’m just doing an average of the 4 texel neighboors, which is done in one pass with 4 TMUs. Basically, you bind the same source texture to the 4 TMUs, but on each one, you tweak the texture coordinates to sample from the center of each neighbooring texel… it’s very fast.


and don’t forget to sample in the middle of 4 texels to get a sample of 4 pixels automagially due billinear filtering…
so you can take 16 samples per pass…