Improved PSSM shadows (exponential shadowmapping)

Posted By: sivan

Improved PSSM shadows (exponential shadowmapping) - 10/03/13 13:19

Hi,

I added a new feature to my earlier PSSM demo, namely exponential shadowmapping, that can be used instead of PCF smoothing, and now it is enough to use 1 or 2 splits for even large areas thanks to its higher precision. It is not desirable to use more splits, because in that case blurring the depth maps makes things slower. Together with stencil blur, nice shadows can be produced. It has a debug mode to check split areas having different colours. Shadows now fade out with distance fog (beside border fade-out).

To be honest, I'm not totally satisfied with its implementation, I made a better one without using the stencil buffer, but it works fine too. I had problems with the depth maps, and the exponential scale factor has to have a much higher value comparing my original implementation (and what is suggested in an NVidia artice) to get proper results.

There are some new terrain and object shaders included, you can choose what to use, Shader Model 3 or 2. You can select per pixel light support in the shaders (on by default).

The Shade-C 0.91 water package now consists of only 3 files, so you can include it in your game easily. Now it supports SM3.0 object shaders too (underwater artifacts eliminated). Also features per pixel light support.

There is an option to cover the terrain with grass, which can be animated or non-animated. Eats up some FPS.

An exe is included for Free/Extra users to enable them to check these possibilities of Gamestudio.

Download link (updated at 22-11-2013):
http://www.mediafire.com/download/s4qsgzvm77qfi7g/improved%20PSSM%20shadows.zip

A few screenshots:







See other details in the readme file.

It's free, please use it laugh

Regards,

Ivan
Posted By: 3run

Re: Improved PSSM shadows (exponential shadowmapping) - 10/03/13 14:18

Thank you man! It's awesome, as always! laugh
I'll be waiting for new shade-c shadows as well laugh
Posted By: PadMalcom

Re: Improved PSSM shadows (exponential shadowmapping) - 10/03/13 15:19

Nice, does it work with transparencies?
Posted By: rojart

Re: Improved PSSM shadows (exponential shadowmapping) - 10/03/13 15:53

Thank you sivan, very nice shadows.

By the way, d3d_anisotropy function doesn't really work, check here my workaround.
Posted By: sivan

Re: Improved PSSM shadows (exponential shadowmapping) - 10/03/13 18:32

transparency works in the same bad way as before, it is an engine related issue to be fixed nobody knows when. later I will make another exponential shadowmapping demo based on what I've already implemented in next MapBuilder by modifying Shade-C variance shadowmapping, that features correct self shadows on alpha textures (but only a one split system).

thanks Rojart, I will test it.
Posted By: sivan

Re: Improved PSSM shadows (exponential shadowmapping) - 10/04/13 10:10

I found 2 funny (probably) engine bugs:
- if stencil_blur in main.c is commented out, and #define USE_SM30 is used (enabling shader model 3 object shaders), then the shadows become sharp and have fog colour. but it also results in fog coloured artifacts in case of shader model 2, near water surfaces (probably because the water shader always uses shader model 3). the same happens if I replace FOG with TEXCOORD7 in shaders. but if you press T to create the test character, in some camera angles shadows become perfect...
- another issue can happen if only the terrain is visible, then without stencil_blur applied, sometimes the 1st terrain texture is rendered on the screen...

thus stencil_blur must be at least 0.1. always.
I have again a little list of engine bugs to present to Jcl...
Posted By: oliver2s

Re: Improved PSSM shadows (exponential shadowmapping) - 10/04/13 11:06

Originally Posted By: sivan
I found 2 funny (probably) engine bugs:
- if stencil_blur in main.c is commented out, and #define USE_SM30 is used (enabling shader model 3 object shaders), then the shadows become sharp and have fog colour. but it also results in fog coloured artifacts in case of shader model 2, near water surfaces (probably because the water shader always uses shader model 3). the same happens if I replace FOG with TEXCOORD7 in shaders. but if you press T to create the test character, in some camera angles shadows become perfect...
- another issue can happen if only the terrain is visible, then without stencil_blur applied, sometimes the 1st terrain texture is rendered on the screen...

thus stencil_blur must be at least 0.1. always.
I have again a little list of engine bugs to present to Jcl...


Maybe they are all related to that PSSM bug which was fixed in beta A8.45? Are you a beta tester?
Posted By: rojart

Re: Improved PSSM shadows (exponential shadowmapping) - 10/04/13 11:25

Hi sivan, I've the beta and works by me.

What exactly you meant by "then the shadows become sharp and have fog colour", some screenshots?
Posted By: sivan

Re: Improved PSSM shadows (exponential shadowmapping) - 10/04/13 11:33

ahh great, Jcl once told me when I mentioned the 2nd problem that it is probably solved in the beta. but I have no access to the betas... maybe when I finally recieve my pro licence I can have.

the 1st problem looks like this:

Posted By: rojart

Re: Improved PSSM shadows (exponential shadowmapping) - 10/04/13 12:40

Yes this works with beta, you don't need pro to beta access, afaik just pm jcl.

Posted By: sivan

Re: Improved PSSM shadows (exponential shadowmapping) - 10/04/13 14:04

maybe your are right, once he offered me to open the beta thread for me...
Posted By: rojart

Re: Improved PSSM shadows (exponential shadowmapping) - 10/04/13 15:33

Maybe just try wink
Second issue?
Posted By: sivan

Re: Improved PSSM shadows (exponential shadowmapping) - 10/04/13 17:05

here you can find the 2nd issue description and screenshots (I forgot I reported it earlier): http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=427927#Post427927 It also happens only when no stencil blur applied.
Posted By: rojart

Re: Improved PSSM shadows (exponential shadowmapping) - 10/05/13 09:16

Yes, it works with beta, too.

Merely shadows on water are static, i think that the water&pssm shader should be adjusted.

Posted By: sivan

Re: Improved PSSM shadows (exponential shadowmapping) - 10/05/13 15:02

great news, thanks.
I could not solve this static shadows on water problem (but as I remember with some settings change they can be underwater), tree animation also results in static shadows behind... it can be eliminated when all entities have a shaders that do shadowmapping (like in shade-c I put into MapBuilder). moreover, I don't know which is the more realistic: shadows on water, or on underwater ground, or on both...
Posted By: Rackscha

Re: Improved PSSM shadows (exponential shadowmapping) - 10/05/13 18:00

@sivan:
On both. Howver if its possible try to make them more subtle.
Posted By: sivan

Re: Improved PSSM shadows (exponential shadowmapping) - 11/22/13 12:58

hi,

I made a little update (download link modified in 1st post):

- added some pp shaders (my pseudo bloom and bloom-blur, and Kartoffel's pp shader pack - requires commenting/uncommenting some lines)
- pssm shader correction for alpha textures
- the included exe applies terrain cache (pro only feature)

it can be slow if camera looks from a high position at a large forest area, but okay when e.g. a 1st or 3rd person camera is used.
Posted By: oliver2s

Re: Improved PSSM shadows (exponential shadowmapping) - 11/22/13 13:11

Originally Posted By: sivan
- pssm shader correction for alpha textures


What does this exactly mean? And does this update include the corretion of the tree normals?
Posted By: sivan

Re: Improved PSSM shadows (exponential shadowmapping) - 11/22/13 14:04

no, only that line containing clip(..); that you wrote earlier (or Slin?) in a pssm thread somewhere in the bugs or in the ask the devs section. self shadows don't work for overlay trees (overlay needed by the mirror view of the water shader). but if you put 32b ent_decals e.g. on the ground, then they recieve shadows properly (without this line decals surpress pssm shadows).
© 2024 lite-C Forums