Properly support PSSM/CSM
- ahmedismaiel
- OGRE Contributor

- Posts: 217
- Joined: Wed Jan 25, 2006 11:16 pm
- Location: Redmond,WA
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
It's committed to the v1-6 branch now. I tweaked a few things, and created a slightly more flexible version of the PSSMShadowCameraSetup which can work with a flexible number of splits and can also cope with more varied camera near / far setups (there's a tunable 'pad' factor to deal with the cracks between splits now rather than it being hardcoded). I also don't require UserDefinedObject use etc.
So far I've just demoed it in PlayPen::testTextureShadowsIntegratedPSSM since I don't have time to revise the main shadows demo just yet. It works
Thanks to lf3thn4d for the patch.
So far I've just demoed it in PlayPen::testTextureShadowsIntegratedPSSM since I don't have time to revise the main shadows demo just yet. It works
Thanks to lf3thn4d for the patch.
- cdleonard
- Goblin
- Posts: 266
- Joined: Thu May 31, 2007 9:45 am
It's really great this got squeezed into 1.6
I tried the PlayPen demo and the shadows seem to swim a lot; whenever I translate or rotate the camera. The debug overlays also seem to "jump" a lot on very small camera rotations; then come back. Is this expected? The effects decreases if I increase shadow texture resolution (default is 512).
I tried the PlayPen demo and the shadows seem to swim a lot; whenever I translate or rotate the camera. The debug overlays also seem to "jump" a lot on very small camera rotations; then come back. Is this expected? The effects decreases if I increase shadow texture resolution (default is 512).
- lf3thn4d
- Orc
- Posts: 478
- Joined: Mon Apr 10, 2006 9:12 pm
- x 12
That is the typical behavior for any PSM type shadow maps. LiSPSM has it pretty bad but it's the side effect of wanting to make full use of the shadow texture in all situation. 
In a typical game, we use 1024 - 512 - 512 (6mb video ram)or 1024 - 1024 - 512(9mb video ram). However, if you are on high end machines, 1024 - 1024 - 1024(12mb video ram) fits perfectly. It's a bit taxing but way better than doing a single 2048.
But let's face it. If you have good textures and graphics for your game, nobody is going to talk about how much the shadow swims.
In a typical game, we use 1024 - 512 - 512 (6mb video ram)or 1024 - 1024 - 512(9mb video ram). However, if you are on high end machines, 1024 - 1024 - 1024(12mb video ram) fits perfectly. It's a bit taxing but way better than doing a single 2048.
But let's face it. If you have good textures and graphics for your game, nobody is going to talk about how much the shadow swims.
- lf3thn4d
- Orc
- Posts: 478
- Joined: Mon Apr 10, 2006 9:12 pm
- x 12
No. there's no such thing yet. Right now you have to manually inject them into your material. Or you can do it the hacky way I did.
At any rate, the current PSSM shadow camera setup in ogre has a limitation. That is it's designed only for one camera. If there ever come to a case where you have multiple camera of different clip range, it will break.
From what I've experienced, different view clip range requires a lil tweaking to get optimum shadow. The Ideal way is to have them set inside Ogre::Camera itself. However, being that PSSM is more of an optional thing, it would be nuts to do that.
Right now, the best thing I could come out with is to make it application specific. See my Demo for more example.
At any rate, the current PSSM shadow camera setup in ogre has a limitation. That is it's designed only for one camera. If there ever come to a case where you have multiple camera of different clip range, it will break.
From what I've experienced, different view clip range requires a lil tweaking to get optimum shadow. The Ideal way is to have them set inside Ogre::Camera itself. However, being that PSSM is more of an optional thing, it would be nuts to do that.
Right now, the best thing I could come out with is to make it application specific. See my Demo for more example.
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
Personally I considered it extremely unlikely that you'd want the expense of 3x shadow renders for multiple cameras - scalability becomes a major issue. Plus, if your cameras are in the same world, they're likely to have the same clip distances to my mind.
Basically because the shadow camera classes are pluggable there's no way to guarantee that we can add autoparams to do this kind of thing for you. As it happens, it's really not that difficult to organise since you're really not likely to have lots of these with all different settings, all dynamically changing, it's just not remotely a normal use. I've used the new PSSM class and hooked it up to my materials easily with a single manual shader value assignment at init time. I think talk of auto params and subclassed cameras is way overkill.
Basically because the shadow camera classes are pluggable there's no way to guarantee that we can add autoparams to do this kind of thing for you. As it happens, it's really not that difficult to organise since you're really not likely to have lots of these with all different settings, all dynamically changing, it's just not remotely a normal use. I've used the new PSSM class and hooked it up to my materials easily with a single manual shader value assignment at init time. I think talk of auto params and subclassed cameras is way overkill.
- lf3thn4d
- Orc
- Posts: 478
- Joined: Mon Apr 10, 2006 9:12 pm
- x 12
sinbad: I'm thinking more along the lines of camera switching. This is especially useful for cut scenes or zooming based cameras. Usually cut scene cameras have different view distance. I dunno, i'm no artist here. I'm only just looking at some other working examples like heavenly sword. 
At least that's the impression I got from this post: http://forum.beyond3d.com/showthread.php?t=41092#3
At least that's the impression I got from this post: http://forum.beyond3d.com/showthread.php?t=41092#3
- ahmedismaiel
- OGRE Contributor

- Posts: 217
- Joined: Wed Jan 25, 2006 11:16 pm
- Location: Redmond,WA
- haffax
- OGRE Retired Moderator

- Posts: 4823
- Joined: Fri Jun 18, 2004 1:40 pm
- Location: Berlin, Germany
- x 8
- Contact:
It will be available in the trunk when the branch is merged into trunk the next time.ahmedismaiel wrote:i was wondering why this in the 1-6 branch and not in the trunck!
When managing a repository, you need some kind of merging procedure that avoids all the pitfalls of having to work on several versions of your software. One is to apply the change on the oldest applicable branch and let it trickle down to the trunk. This is how it is done in Ogre.
-
iigor
- Gnome
- Posts: 387
- Joined: Thu May 08, 2008 3:46 pm
- Location: Russia, Moscow
- lf3thn4d
- Orc
- Posts: 478
- Joined: Mon Apr 10, 2006 9:12 pm
- x 12
- lf3thn4d
- Orc
- Posts: 478
- Joined: Mon Apr 10, 2006 9:12 pm
- x 12
yes. definately. PSSM just means multiple shadow map per light. Internally, it's still using Ogre's shadow system. All that is needed to take care of is to make sure your material has alpha rejection set. Then in the shadow casting fragment shader, sample your detail map while applying the detail's alpha channel into the colour's alpha channel output.
-
Caphalor
- Greenskin
- Posts: 116
- Joined: Tue Feb 06, 2007 8:54 pm
- Location: Berlin, Germany
- x 25
- ahmedismaiel
- OGRE Contributor

- Posts: 217
- Joined: Wed Jan 25, 2006 11:16 pm
- Location: Redmond,WA
i have some trouble trying integrating this in ps3.0 shader (2.0 work great)
i get this error
btw here is a generalized PCF to define soft shadows with any number of samples.
i searched for a fix but i cann't say i understand how to do it using ddx,ddy
http://www.ogre3d.org/phpBB2/viewtopic. ... 6f4e2718c6
http://www.ogre3d.org/phpBB2/viewtopic. ... 6f4e2718c6
help!
i get this error
Code: Select all
error X6077: texld/texldb/texldp/dsx/dsy instructions with r# as source cannot be used inside dynamic conditional 'if' blocks, dynamic conditional subroutine calls, or loop/rep with break*. Code: Select all
#define PCF_SAMPS 7
#define PCFH ((PCF_SAMPS-1)/2)
#define PCFT (PCF_SAMPS*PCF_SAMPS)
#define PCFSize 5
float shadowPCF(sampler2D shadowMap, float4 shadowMapPos, float2 offset)
{
shadowMapPos = shadowMapPos / shadowMapPos.w;
float2 uv = shadowMapPos.xy;
float3 o = float3(offset, -offset.x) * 0.3f;//* 0.5f;
float c=0;
int i, j;
for (i = -PCFH; i<= PCFH; i += 1) {
for (j = -PCFH; j<= PCFH; j += 1) {
float2 sample=float2(o.z*i,o.y*j);
c += (shadowMapPos.z <= tex2D(shadowMap, uv.xy - sample).r) ? 1 : 0; // top right
}
}
return (c / PCFT)* 0.5+0.5;
}
http://www.ogre3d.org/phpBB2/viewtopic. ... 6f4e2718c6
http://www.ogre3d.org/phpBB2/viewtopic. ... 6f4e2718c6
help!
- ahmedismaiel
- OGRE Contributor

- Posts: 217
- Joined: Wed Jan 25, 2006 11:16 pm
- Location: Redmond,WA
-
Vectrex
- Ogre Magi
- Posts: 1266
- Joined: Tue Aug 12, 2003 1:53 am
- Location: Melbourne, Australia
- x 1
- Contact:
- sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
- Contact:
