Soft shadows using noise - anyone tried it?

Started by
2 comments, last by luca-deltodesco 16 years, 1 month ago
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?
Advertisement
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.

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

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
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.

This topic is closed to new replies.

Advertisement