PDA

View Full Version : Soft shadows, part II



Ysaneya
09-26-2002, 03:55 AM
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: http://www.fl-tw.com/opengl/SoftShadows/

Any feedback is welcome :)

Y.

LaBasX2
09-26-2002, 05:28 AM
Just one word: amazing! http://www.opengl.org/discussion_boards/ubb/smile.gif

I hope to see the demo in action soon and to read a description of your technique. http://www.opengl.org/discussion_boards/ubb/smile.gif

Great work, continue like that!

LaBasX2

zwaffle
09-26-2002, 08:34 AM
Are these actually soft shadows or blurred shadows?
Means that a true soft shadow is sharp near the occluder but get softer further away.

Zeno
09-26-2002, 09:38 AM
Wow, beautiful!

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

-- Zeno

Ysaneya
09-26-2002, 12:27 PM
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 http://www.opengl.org/discussion_boards/ubb/smile.gif

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.. http://www.opengl.org/discussion_boards/ubb/tongue.gif)

Y.


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

V-man
09-26-2002, 06:18 PM
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?

V-man

Ysaneya
09-27-2002, 12:04 AM
With standard "sharp" stencil shadows, it's around 20 fps. I don't have an option to completely disable the shadows, though :)

Y.

Madoc
09-27-2002, 02:30 AM
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.

Cheers,
Madoc

V-man
09-27-2002, 10:07 AM
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?

V-man

Nakoruru
09-27-2002, 10:44 AM
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).]

jwatte
09-28-2002, 09:54 AM
Nakoruru,

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.

Nakoruru
09-28-2002, 02:21 PM
jwatte,

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 ^_^


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

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

davepermen
09-28-2002, 03:14 PM
i would prefer tons of small lightsources somehow.. as the chances that they move are more than for the normal sun http://www.opengl.org/discussion_boards/ubb/biggrin.gif so we could see the shadows more "in action" http://www.opengl.org/discussion_boards/ubb/biggrin.gif

or is there a day-night-circle in the demo? with about 10 secs for a day? http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Ysaneya
09-29-2002, 04:04 AM
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.

Y.

davepermen
09-29-2002, 04:27 AM
yeah, one light is much simpler to optimize..

no problems with such a light, can't wait for it http://www.opengl.org/discussion_boards/ubb/biggrin.gif

LaBasX2
10-02-2002, 09:28 AM
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

Ysaneya
10-02-2002, 10:31 AM
If you find a way, tell me :)

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.

Y.

LaBasX2
10-03-2002, 04:11 AM
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?

Thanks!

Ysaneya
10-03-2002, 04:37 AM
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.

Y.

davepermen
10-03-2002, 05:30 AM
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...

LaBasX2
10-03-2002, 05:36 AM
Ah, that's great! http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanks for your answers!

LaBasX2

pocketmoon
10-03-2002, 05:52 AM
Ysaneya - are you doing pixel->occluder distance calcs ?

If so, what do you do if a point is occluder by more than one object ? One closer to the light and one closer to the pixel ?

http://www.opengl.org/discussion_boards/ubb/smile.gif)

Ysaneya
10-04-2002, 03:05 AM
Nope, i already stated that i'm using the plain pixel to light source distance. Unfortunately i didn't find a (fast) way to do correct pixel / occluder distance calculations..

Y.

V-man
10-04-2002, 04:20 PM
Originally posted by Nakoruru:
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).]

From what I remember, if you have a meter stick, and have it standing verticly up in the soil, you can tell time, just like a sun dial. The shadow appears quite sharp. Try the same thing inside your house with a light bulb.

The shadow will be very blurry looking, inside.

Maybe Jwatte was stating this in his post.

V-man

Nakoruru
10-06-2002, 08:14 PM
V-Man,

This is a fairly subjective thing, but when I am outside my shadow is a little blurrier than it is in my living room.

I have little lights with clear bulbs (not frosted) so the lights are itty bitty filaments. I seen five distinct sharp shadows in my living room because the lights are so small.

It is blurry outside because the sun is bigger relative to me than the lights in my living room.

In my kitchen it is a different story, because the lights are in the big white globes and are quite large relative to me. My shadows are very blurry in the kitchen.

Shadow softness is a matter of relative size and distance. However, it is not an absolute function of these. By that I mean that you have to consider the shape of the light and the object. The only way to properly do this is multisampling. Any method which is not roughly equivalent to solving the light equation multiple times and summing/averaging the results is fake soft shadows. In otherwords, any method which only considers relative distance and does a single calculation to soften shadows is simply wrong (maybe 'wrong' is too strong, since it may look good enough, maybe I should just say 'inaccurate').

EDIT: I thought I would offer MY definition of fake vs. accurate so that nobody's feelings get hurt ^_^

Fake is when you do something that looks good but is only based loosely on physics, if at all. An example would be 2d flares around light sources or spot shadows under characters.

Accurate is when you use a model derived from physics. The degree to which you hold to this model determines how accurate you will be.

There is no guarantee that accuracy will look good on a computer monitor or that fake methods will look bad.




[This message has been edited by Nakoruru (edited 10-06-2002).]

davepermen
10-06-2002, 10:36 PM
i got hurt, i got hurt!
you hurt me! don't define that! ahh...

...

well, i agree with this. just one thing: the shadow of the sun can be damn sharp, and very soften. depends much on the weather..

btw, how's the demo going on, ysaneya?

Ysaneya
10-07-2002, 12:40 AM
The code's pretty much done. I don't think i'll finish implementing the vertex shaders, because i keep getting weird errors and freezes, talk about driver bugs. So most likely the framerate will not be as good as expected, i currently get a 15 fps average on an Athlon 1.4 + R8500. Yesterday i finished the water effect (env bump mapping), so now i'm waiting for the artist to finish texturing the scene. It's not as easy as it sounds, because there's a lot of stretched tex coords, which indirectly result in invalid lighting, plus flipped normals that he still has to fix. I don't think he will be done before one week, at least. I can still post some screenshots if you want?

Y.

davepermen
10-07-2002, 12:52 AM
yeah, i want http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Ysaneya
10-07-2002, 03:49 AM
Ok, done (same URL) :)

Y.

V-man
10-07-2002, 11:14 AM
Nakoruru,

yes, relative sizes should give similar looking results, but where you position your occluder, light and the ground matters.

I said that it's better to do the demonstration with a local light source with a cylinder. The only thing that I didnt say was what dimensions to use for the cylinder and light source and where exactly to place everything, but I'm sure everyone understood.

Anyways, if you had frosted light bulbs you could see that shadows (of you standing up perhaps) would look blurrier than your own shadow outside. The reflections from the environment counts as well, but on a sunny day you wont notice the shadows they cause.

Hope all wounds are healed!

V-man

dorbie
10-07-2002, 11:27 AM
The Sun does not appear infinitely small in the sky. When you look at it it describes a solid angle in the sky. For all intents and purposes it is infinitely distant, but it's the apparent size of the source that creates soft shadows (ignoring diffusion effects).

Even on a clear day with a clear orb the Sun will cast a soft shadow. The softness will be determined by the distance from the occulter to the penumbra on the surface.

It's just like any other light source casting a soft shadow. The distance to shadowed objects determines the solid angle of the source (in the case of the Sun we can assume it's constant) then the spatial relationship of the objects determines the sharpness of the shadow (just one way to visualize it).

Nakoruru
10-07-2002, 06:51 PM
dorbie,

I dunno if you are disagreeing with me or not ^_^

I agree with what you said, except when you say that relative position -determines- the sharpness of the shadow. If you by determine you mean that it is all you need to know then I do not agree. The shape of the occulter also matters.

I am just saying that any method which ONLY considers the relative positions of the objects (light, occulter, occulted) to modulate the darkness of the shadow calculation are a shortcut. fake. They assume something about the shape of the occulter.

I am saying that such shortcuts cannot be as good as multi-sampling. You have to do the basic point-sampled lighting calculation multiple times and average the results. The relative positions of the objects only enter into choosing your samples, not into the light/shadow calculation itself (which remains identical to a point light shadow determination).

I am thinking that none of us here have a serious misunderstanding of how soft shadows occur in nature. Maybe the big disagreement is just over how to fake them (I mean, we disagree about how to get good results without doing the multi-sampling or multiple passes that would be require to do them accurately).

V-man
10-07-2002, 08:29 PM
>>>I am saying that such shortcuts cannot be as good as multi-sampling.<<<

What do you mean by multiple sampling here. Do you mean emulating a surface light by many point lights equaly distributed over the light surface?


V-man

davepermen
10-07-2002, 10:39 PM
thats what he means, yes.

and we all know that this is true but it is simply impossible to do fast, nako. still it does only depend on the relative distances, if you simplify the geometry. make the lightsource a sphere with some radius, make the occluder a simple line (on a paper ya know, 2d), and then draw your surface. you _can_ then integrate over the whole emiting sphere surface, and you get a function dependent on occluder edge, sphereradius, and the relative distances. about that at least. the whole point is now getting those correct components, and the function. that'll work perfectly for spherical lightsources (thought you can solve it for others as well, even triangles). but, in practice, finding the egde in space is something impossible. thats why you would need supersampling. but you can approx it anyways well with the same function.

oh, and don't ask me for the function. i tried several times but failed, i'm not good in math anymore. too long nothing done http://www.opengl.org/discussion_boards/ubb/biggrin.gif

but of course, you're right. this is more a heuristic/statistical approach, approximating that what we know is true. but this is done everywhere, so what? http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Nakoruru
10-07-2002, 10:40 PM
By multi-sampling I mean any method which is equivalent to doing the lighting/shadow calculation multiple times where the light parameters are different (over the extent of the light) and then averaging or summing the results.

You could shortcut this by only doing the shadow calculation multiple times, and using that to modulate a single diffuse/specular/bump lighting calculation.

I have a theory that one could get away with using only a single shadow map to do shadow determination (instead of rendering multiple shadow maps). It would not be as accurate, because it does not consider parallax, but it would be really close I think. Just gotta find time to test it.

pocketmoon
10-08-2002, 12:14 AM
Originally posted by Nakoruru:
I agree with what you said, except when you say that relative position -determines- the sharpness of the shadow. If you by determine you mean that it is all you need to know then I do not agree. The shape of the occulter also matters.

The shape doesn't matter much. Not nearly as much as the relative position of the occluder.

And lets remember here that ALL the methods we are employing are fake. Even raytracing the scene with all the knowledge of modern physics is still 'fake'.

The problem with multisamples is that you only get as many shadow levels as samples, i.e. steps in the shadow rather than a smooth transition. You have to do some sort of additional (post-processing?) belending.

Thats one of the reasons I wanted to try something different with my occluder distance shadows.

Rob