Sign in to follow this  
_Lopez

Soft shadows using noise - anyone tried it?

Recommended Posts

I've recently been trying to implement soft shadows for a daylight system. I ideally want the shadows to be variable dependant on occlusion from clouds, so for example if the sky is overcast, then the shadows are really soft, or if the sky is clear the shadows are sharp. I came across a glsl noise function in these forums, and by sampling the shadow texture several times using a random uv offset obtained from the diffuse texture coords of the scene, i've managed to be able to get some seroiusly soft shadows. I render the scene into 3 render targets, diffuse, lighting/shadows, specular; and then recombine these to a screensized quad for the final render as (diffuse*lighting)+specular. The problem i've got is that due to using noise, the shadows are grainy. I've tried using a pcf filter in screenspace to soften them, which works pretty well, it doesn't account for sharp edges, so i'm getting light bleeding which gets worse the further from the camera the pixel is. Is it possible to do a pcf or some other type of filter in screen space, that will vary the pcf kernel dependant upon distance; and if so, how do I go about doing it?

Share this post


Link to post
Share on other sites
There is no way, how can be PCF computed in screen-space (as long as you dont want light bleeding around edges of the object) = this'd be same as screen space blur. You should try shadows maps with PCF and bilinear filter (bilinear filter has to be done after comparing shadows!), or variance shadow maps (to reduce light bleeding, use summed area variance shadow maps).

Anyway posting screenshot would be helpful to find where problem is.

Share this post


Link to post
Share on other sites
In terms of realism, I think that the clouds dont actually make the normal shadows softer, rather the clouds cast their own shadow on the area around the normal shadows, making them appear less dark.

But for the soft shadows, I think crysis does something like what you are doing. Have you read that paper they released that describes their shadows? they look ok, but they are still a little grainy if you really look at them. Have you looked into variance shadow mapping? you can perfrom gaussian blur on them and make them as soft as you want with no grain

What do you mean by sharp edges? if you are trying to sofen them, dont you want to get rid of sharp edges?
If the the problem is because the filter width is constant dependent on the camera distance from pixel, you could just vary the filter with based on distance as you suggested. It will probably require dynamic branching though
Im not sure exactly how this would be implemented, but i think thats the right idea

Share this post


Link to post
Share on other sites
In terms of realism, I think that the clouds dont actually make the normal shadows softer, rather the clouds cast their own shadow on the area around the normal shadows, making them appear less dark.

its a combination really, the clouds do cast their own shadow, but they also scatter the light alot making it as though there is an entire volume casting its own varying intensity of light. ever noticed when sky is completely overcast, everything is darker yes, but unless you look in cracks, or under a car its actually quite hard to find a descernable shadow, its as though everything has lost its shadow.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this