Page MenuHome

Realtime PCF soft shadows support
Closed, ArchivedPublicPATCH


This patch adds support for pcf filtering on realtime shadows using the spotlights Samples and Soft settings.

What you get is soft realtime spotlight shadows in the viewport and GE that closely matching the internal renderer's.

It's been tested with both nvidia and ati cards on the BA forums.

Event Timeline

can you attach a .blend file showing the effect?

a few comments:

1) shouldn't you set result as 0 or whatever before start adding values to it? (inp != 0.0 and shadowkernel > 1.0)
2) Why not replace all this hardcoded (if shadowkernel == ....) tests by:
if(shadowkernel == 1.0)
result = shadow2DProj(shadowmap, co).x;
else {
for(i=0;i<shadowkernel; i++) {
result += shadow2DProj(shadowmap, co+vec4(((j * sstep)-soffs)/co.w, (y-soffs)/co.w, 0.0, 0.0)).x;
y+= sstep;
void test_shadowbuf would be like:
3) nice patch !

softshadow.blend attached. From what I got from Sebastian's patch it's only a matter of changing Samples and Softness in the GUI.

It looks like the lighting already supports softness. Do you know if the light method is the same method as the shadow?

Nice patch. However the settings don't really match the internal renderer that well in my tests? In particular the softness is much stronger in GLSL. In the test softshadow.blend file, compare the GLSL result with a shift+P preview render.

One problem if this gets committed is how to handle backwards compatibility. Right now games using shadows will have samples set quite high and so they will get a big performance degradation. If this gets committed as part of 2.5 with other compatibility changes it may not be a problem though.

Brecht ("how to handle backwards compatibility"):
How about an option in the GLSL menu: enable soft shadows?
Then in 2.5 we leave it enabled by default (or even remove from the menu).

Dalai Felinto, the reason is compatibility. Older PS 2.0/ATI cards do not support dynamic sized and nested loops.

Brecht Van Lommel, I've attached an improved patch(pcfshadows2.txt & the test.blend I used) that attempts to more closely match the internal renderer, and a small optimization as well.

As for compatibility, no one raised this on the BA forums so I'm not sure it's a big deal? If so I agree with a GLSL menu option.

Personally Id not worry about compatibility, games should not use a huge number of spot lamps, when people run their games in a new version of blender they often need to update a few settings.

Adding more stuff for people to have to tweak should be avoided however I think in this case its acceptable.

This patch seemed to have gotten lost in the 2.49 pre-release madness. I've modified the patch to work with the latest trunk (23357) in hopes of getting discussion going again.

What needs to be done here to get this in trunk?

hi all
i tried to update this patch but no use :(
can you update this patch, it is very old and some need it, i wonder why it didn't got to trunk to now ????

Updated the patch to svn 41542.
attached by the file named <pcf_shadows_r41542.patch>
one question though, when it will go to trunk ?

can someone update please,as i can patch no after harmony's merge
and when it will go to trunk ?

Mitchell Stokes (moguri) changed the task status from Unknown Status to Unknown Status.May 28 2014, 6:27 AM
Mitchell Stokes (moguri) claimed this task.

We're using VSMs for soft shadows, so I don't think we really need PCF anymore.