|
(WIP) Better Shadowmapping
#450648
04/19/15 23:46
04/19/15 23:46
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
OP
Expert
|
OP
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
A while ago I already posted a couple of snippets improving the quality of the existing PSSM shadows within the gamestudio templates. Looking at that code again I found a couple of issues and things to improve. I also plan to include point and spot lights at some point. PSSM Improvements (so far): - No flickering if the camera moves. - Slightly tighter frustums resulting in slightly improved shadow resolution. - Kinda hacky, but still a lot better biassing using depth derivatives. The biggest still existing issue is the way the shadows are mixed with the scenes shading, which is just totally wrong, but this should be handled in custom shaders for the scene objects and is not really part of this. You can get the code on github. Here is an ugly screenshot of my testlevel (the worst way to present shadows is on untextured cubes...):
|
|
|
Re: (WIP) Better Shadowmapping
[Re: sivan]
#450957
04/25/15 18:19
04/25/15 18:19
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
Thanks slin! But I got some problems with it, same as with standard pssm shadows Actually the shadows overlap my ZNEAR weapons and the TRANSLUCENT entities overlap the shadows
Last edited by Ch40zzC0d3r; 04/25/15 20:08.
|
|
|
Re: (WIP) Better Shadowmapping
[Re: Ch40zzC0d3r]
#450969
04/26/15 00:29
04/26/15 00:29
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
OP
Expert
|
OP
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
sivan, it is mostly about the improved split calculation and nobody stops you from using the exact same shadow code in your object shaders. A depth prepass might also be a good idea, or just render depth, normals and textures and everything else you need into multiple render targets and do some deferred shading. There are pros and cons to everything, a deferred approach (or maybe even light prepass) might be the most performant with gamestudio though (with newer DirectX and OpenGL versions you can do some really nice stuff with reusing depth buffers and providing lots of data to shaders in a fast and comfortable way).
Ch40zzC0d3r, those issues are not really related to the shadow. ZNEAR renders an object in front of things while it really is behind. The only solution for that is to not use znear and solve the issue with weapons inside walls by not allowing the player to get that close to the wall, at least not in a way the weapon could pass through it. Transparent things in general are problematic in real time rendering due to the way sorting is solved with a depth buffer. So if you happen to have some translucent entities that need to cast shadows, there are solution for it, but they tend to have some restrictions. Receiving shadows should be fine though?
|
|
|
Re: (WIP) Better Shadowmapping
[Re: Slin]
#450974
04/26/15 08:57
04/26/15 08:57
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
Thanks for the answer! I nearly fixed the bugs, only one is left. I have a normalmapping object shader and when I apply the material then the shadows overlap my weapon. They dont overlap with default object shader. Any ideas? I can also post the code of it if you need it
Last edited by Ch40zzC0d3r; 04/26/15 19:16.
|
|
|
Re: (WIP) Better Shadowmapping
[Re: sivan]
#451020
04/27/15 08:26
04/27/15 08:26
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
I took a deeper look at my object shader and came to the conclusion that the bone animation shader is the one which puts the shadows infront of my models. But why those 2 lines change the depth of the zbuffer?
float4 Pos = DoBones(InPos, inBoneIndices, inBoneWeights);
OutPos = mul(Pos, matWorldViewProj);
//intsead of
OutPos = mul(InPos, matWorldViewProj);
EDIT: Also the shadows created by those GPU bone animated models are wrong. The shadows dont have any animation
Last edited by Ch40zzC0d3r; 04/27/15 08:52.
|
|
|
|