[SUB] Deferred PSSM Shadows Workaround

Posted By: txesmi

[SUB] Deferred PSSM Shadows Workaround - 12/18/12 18:03

Hi friends!

I have been introducing myself into deferred rendering techniques and my first workaround comes around pssm shadows. First I thought on rendering that 'fDistance' value into a 32bit floating point bitmap, but finally I rendered the pixel world coordinates into a 4x32bits floating point bitmap, so the gates are opened to compute dynamic light rediance or dof blurring from those same values.

I built a scenery that fully remarks the rendering speed improvements because of its high density of overlapping polygons. I fit the shadow splits to four and deleted all the gpu bones computation stuff.
DOWNLOAD (SM3.0!)

Hope it helps grin
Salud!
Posted By: MMike

Re: [SUB] Deferred PSSM Shadows Workaround - 12/18/12 20:25

it looks weird for me!

My GPU is quite fast, and this runs with 4.5 FPS!?

Look to this artifact:




[img]https://skydrive.live.com/redir?resid=FD0C3A71DD42E9BC!586&authkey=!ALssaqjwvaBt3Ls[/img]
Posted By: txesmi

Re: [SUB] Deferred PSSM Shadows Workaround - 12/18/12 22:26

Yes, it look very weird for you. It should look like this:

I can't imagine what happens to be so dark...

That arfifact is a well known texture projection artifact, and should disapear increasing the pssm_bias value.

In my old NVidiaGTX285 deferred shadows runs over 60 fps, and object shader shadows below 20 fps.

It is not concibed to run smooth, but to remark the process timing difference. Ity renders more than 1 million polygons indeed!

Does your graphic card support sm3.0?
Posted By: Kartoffel

Re: [SUB] Deferred PSSM Shadows Workaround - 12/18/12 22:47

for me it works perfectly
got 120-140 fps when running the pp-shadows - which is around 4-5x faster than the object pssm shadows.
nice! laugh
Posted By: sivan

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 12:34

nice but slow here, pp is 20 fps on my ATI HD 7670M, obj is only 10.
Posted By: txesmi

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 14:40

2x faster, is not that good?
Posted By: sivan

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 14:53

the relative value is okay of course, but the absolute speed is not good for my hardware...
Posted By: Kartoffel

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 14:55

well I think he means the overall performance.
an ATI HD 7670M isn't that bad and should be faster than 20 fps.

I'm using an ATI HD 7850 and get ~7x more fps than sivan.
Posted By: Slin

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 14:55

Try this for both:
Code:
float DoPCF(sampler2D sMap,float4 vShadowTexCoord,int iSqrtSamples,float fBias)
{
	float fShadowTerm = 0.0f;  
	float fRadius = (iSqrtSamples - 1.0f) / 2;

	for (float y = -fRadius; y <= fRadius; y++)
	{
		for (float x = -fRadius; x <= fRadius; x++)
		{
			float2 vOffset = float2(x,y)/pssm_res_var;
			float fDepth = tex2Dlod(sMap, float4(vShadowTexCoord.xy + vOffset, 0.0f, 0.0f)).x;
			float fSample = (vShadowTexCoord.z < fDepth + fBias);
			
			float xWeight = 1, yWeight = 1;
			if (x == -fRadius) 
				xWeight = 1 - frac(vShadowTexCoord.x * pssm_res_var);
			else if (x == fRadius)
				xWeight = frac(vShadowTexCoord.x * pssm_res_var);
			
			if (y == -fRadius)
				yWeight = 1 - frac(vShadowTexCoord.y * pssm_res_var);
			else if (y == fRadius)
				yWeight = frac(vShadowTexCoord.y * pssm_res_var);
			
			fShadowTerm += fSample * xWeight * yWeight;
		}											
	}		
	
	return fShadowTerm / (iSqrtSamples * iSqrtSamples);
}

Posted By: Harry Potter

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 15:03


On my NVIDIA GeForce GTX 580 it runs with 81 fps (Object Shader Shadows: 25 fps).
Posted By: sivan

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 15:19

it's a laptop, and runs an intel hd4000 card by default, maybe the ATI can be switched on only on fullscreen mode. then I get 29 fps on 1024x768. Slin's code results in a further speed increase to 32 fps. I mean pp. the obj is about 12 now for both.
Posted By: txesmi

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 16:09

I used 4x16bits floating point textures to render the world position and a 1x16bits floating point texture for the depth maps. Maybe you can change them to 32 bits images (14444 and 14) and tell us how it went grin

But that is not the real clue...

Both render pipelines do same computations, but deferred one does once per screen pixel instead of once per polygon pixel.

You can complicate or simplify both pipelines that you will get nearly same proportional performance. I did not look into Slins PCF technique, but in native pssm shadows there is a faster one. I simply choose the slower one to emphatize the deferring technique benefits.

What I learned of this technique is that writing into a 4x32bits bitmap for the deferred lightening takes its time, and it has to be smaller than the time taken to direct render the overlapped polygons. If you render an nearly empty scenery, deferred techniques are slower.
Posted By: sivan

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 16:10

I just made a larger level with clip_far 8000 and with 2048 pssm resolution from own resources (large terrain with trees having lod), 2500 trees on a 20000x20000 area, everything looks fine, fps can go up sometimes to 39.
as I see it should use an own terrain shader, and the sky cube is also messed up. I hope you'll make additional stuff laugh
Posted By: txesmi

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 16:19

did you use the native pssm shadows with the slow pcf technique on same level?

---
Yes, all the objects in the scene should consider that the rendering is deferred.


edited_____
I forgot to mention that both object materials and depth shader have a double sided rendering
Posted By: Slin

Re: [SUB] Deferred PSSM Shadows Workaround - 12/19/12 17:03

the pcf function I posted is the same as yours, just using tex2Dlod instead of tex2D as the difference does not matter for the depthmap sampling, but tex2Dlod allows the graphics card to use dynamic branching, which in this case means a huge speed benefit, as without the PCF sampling is done for each depthmap for every pixel instead of just the one it needs to.
Posted By: txesmi

Re: [SUB] Deferred PSSM Shadows Workaround - 12/20/12 09:45

thank you for the info!

i should read more about samplers grin
but in native pssm sahdows...
Posted By: MMike

Re: [SUB] Deferred PSSM Shadows Workaround - 12/20/12 22:39

Hey, it was dark, because im using a different color space profile..
But i forgot one thing, "to turn of the powerhybrid technology" (modern stuff..) now , after putting the CPU on the normal performance.. i get 20FPS , but i tweaked the script to lower the tree density : now i dont know the original value :S BUT the shadoow artificat its very notorious.

Im using a laptop Core i7, GT650M :S

Shadermodel 5.0, Cuda, and physX :S
http://www.tiikoni.com/tis/view/?id=9f10b44
© 2024 lite-C Forums