Properly support PSSM/CSM

What it says on the tin: a place to discuss proposed new features.
User avatar
ahmedismaiel
OGRE Contributor
OGRE Contributor
Posts: 217
Joined: Wed Jan 25, 2006 11:16 pm
Location: Redmond,WA

Post by ahmedismaiel »

i'm not able to download it ,server it always busy
can you host it somewhere else or send it to me at ahmed_ismaiel [at] hotmail[dot] com ,i can test it for you on the latest version!
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Post by lf3thn4d »

sinbad is looking into the patch. so stay tuned. :D
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

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.
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Post by lf3thn4d »

Awsome! :) I'll switch to this from my hack once I get the time. Woo hoo~! Something to look forward to :P
User avatar
cdleonard
Goblin
Posts: 266
Joined: Thu May 31, 2007 9:45 am

Post by cdleonard »

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).
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Post by lf3thn4d »

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. :)
Caphalor
Greenskin
Posts: 116
Joined: Tue Feb 06, 2007 8:54 pm
Location: Berlin, Germany
x 25

Post by Caphalor »

Looks good, but it would be good if there was an auto param like:
param_named_auto pssmSplitPoints pssm_splitpoints
Or is this already implemented and I just don't see it?
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Post by lf3thn4d »

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. ;)
beaugard
OGRE Contributor
OGRE Contributor
Posts: 265
Joined: Sun Mar 25, 2007 1:48 pm
x 2

Post by beaugard »

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.
Can't you just have a PSSMCamera class which inherits from Ogre's camera?
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

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.
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Post by lf3thn4d »

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
User avatar
ahmedismaiel
OGRE Contributor
OGRE Contributor
Posts: 217
Joined: Wed Jan 25, 2006 11:16 pm
Location: Redmond,WA

Post by ahmedismaiel »

I just tried it and it works great with me except for some artifacts whe switching between the LOD's, i'll post and example later once i got a reliable connection.

i was wondering why this in the 1-6 branch and not in the trunck!
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

ahmedismaiel wrote:i was wondering why this in the 1-6 branch and not in the trunck!
It will be available in the trunk when the branch is merged into trunk the next time.
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.
team-pantheon programmer
creators of Rastullahs Lockenpracht
iigor
Gnome
Posts: 387
Joined: Thu May 08, 2008 3:46 pm
Location: Russia, Moscow

Post by iigor »

First of all thanks for excellent demo. :)
But i have compiled it with point lights, and spot lights, but shadow textures stayed empty, then i have red the paper of this method where was saying that it is only applyible for directional lighting, so what about other types, how to use it with them?.
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Post by lf3thn4d »

iggor: you don't. :) Use another pass for your other lights. The demo is forcing only directional light in the material as it's meant to be a PSSM only demo. PSSM only works with directional light. However, this new feature addition also means you can do point light shadow with cube shadow mapping. :)
User avatar
aguru
Goblin
Posts: 236
Joined: Tue Feb 26, 2008 5:48 pm
x 3

Post by aguru »

I was wondering if it is possible to use PSSM with Billboard Sets? If so, what would the material have to look like?

Thanks a bunch!
User avatar
lf3thn4d
Orc
Posts: 478
Joined: Mon Apr 10, 2006 9:12 pm
x 12

Post by lf3thn4d »

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.
User avatar
aguru
Goblin
Posts: 236
Joined: Tue Feb 26, 2008 5:48 pm
x 3

Post by aguru »

Thanks for the help, lf3thn4d. I can't seem to figure out the right modifications to the shader file, though. Maybe you can help me out?
Caphalor
Greenskin
Posts: 116
Joined: Tue Feb 06, 2007 8:54 pm
Location: Berlin, Germany
x 25

Post by Caphalor »

If you want that transparent materials cast shadows, you should have a look at grass.cg and Examples.material (Ogre samples, trunk) or search for "shadow_caster_material" in the forums.
@Topic: I am using pssm with Caelum now and it works very good. Thank you for this great feature. :)
User avatar
aguru
Goblin
Posts: 236
Joined: Tue Feb 26, 2008 5:48 pm
x 3

Post by aguru »

Thanks for the top, Caphalor. And thanks everyone who helped with the PSSM integrationn into Ogre.
User avatar
ahmedismaiel
OGRE Contributor
OGRE Contributor
Posts: 217
Joined: Wed Jan 25, 2006 11:16 pm
Location: Redmond,WA

Post by ahmedismaiel »

i have some trouble trying integrating this in ps3.0 shader (2.0 work great)
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*. 
btw here is a generalized PCF to define soft shadows with any number of samples.

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;

}
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!
User avatar
Injector
Gremlin
Posts: 174
Joined: Wed Jan 21, 2004 2:42 pm
Location: Frankfurt, Germany

Post by Injector »

I've seen errors like this prior to updating to the latest version of DirectX.
User avatar
ahmedismaiel
OGRE Contributor
OGRE Contributor
Posts: 217
Joined: Wed Jan 25, 2006 11:16 pm
Location: Redmond,WA

Post by ahmedismaiel »

I have the latest version ,it's a problem in PS3.0 design
i'll try to update to the latest cg version and see
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

Just to clarify something, from playpen it looks like you choose PSSM instead of something like LiSPSM? I got the impression that you still used things like LiSPSM or whatever, but PSSM just rendered multiple resolution versions of it.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

The PSSM class is actually derived from LiSPSM, it just changes the focus region for each of the sections. If later on we wanted it to be more pluggable, we would perhaps wrap another ShadowCameraSetup inside PSSM, rather than subclassing from LiSPSM. But right now it's fine like this.
Post Reply