Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 642 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
(WIP) Better Shadowmapping #450648
04/19/15 23:46
04/19/15 23:46
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline OP
Expert
Slin  Offline 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: Slin] #450652
04/20/15 07:24
04/20/15 07:24
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
hi Slin,

I found "shadow_stencil = 8;" mode very slow in real outdoor environments (no difference in small test levels), comparing to solutions when no stencil buffer used, I would really prefer an object shader based solution instead, with "shadow_stencil = -1;". It would eliminate some issues with 32b textures (it is really disturbing when an entity has both 32b and 24b textures).

As I remember txesmi had a contribution where he made it with pssm (combined with a deferred version)...


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: (WIP) Better Shadowmapping [Re: sivan] #450957
04/25/15 18:19
04/25/15 18:19
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Thanks slin!
But I got some problems with it, same as with standard pssm shadows frown
Actually the shadows overlap my ZNEAR weapons and the TRANSLUCENT entities overlap the shadows smirk

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 Offline OP
Expert
Slin  Offline 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
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Thanks for the answer! laugh
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 laugh

Last edited by Ch40zzC0d3r; 04/26/15 19:16.
Re: (WIP) Better Shadowmapping [Re: Ch40zzC0d3r] #451012
04/27/15 02:19
04/27/15 02:19
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Neat!


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: (WIP) Better Shadowmapping [Re: Superku] #451017
04/27/15 07:07
04/27/15 07:07
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
I know its essence is the new split calculation, I use it already in MapBuilder, really nice and flicker-less. I just tried to convince you to not to use the stencil buffer in 3DGS. I think I will implement it and make a fork on github.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: (WIP) Better Shadowmapping [Re: sivan] #451020
04/27/15 08:26
04/27/15 08:26
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

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?

Code:
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 frown

Last edited by Ch40zzC0d3r; 04/27/15 08:52.
Re: (WIP) Better Shadowmapping [Re: Ch40zzC0d3r] #451026
04/27/15 14:37
04/27/15 14:37
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline OP
Expert
Slin  Offline OP
Expert

Joined: May 2005
Posts: 2,713
Lübeck
sivan, I know that you used that old snippet, but it had some issues I fixed in this version. And I know that the stencil buffer approach sucks, but it has the advantage of just working good enough for most people here. Everything else needs too much of a custom rendering approach for most people to handle.

Ch40zzC0d3r, in vp_depth.fx and also in vp_pssm.fx at the top is an uncommented #define BONES, just make sure that define in set in both shaders and it should work fine with bone animations. The difference is that the DoBone will apply the bone transformations in the vertex shader to each vertex, to actually make the model animate. So without it, it will generate depthmaps and shadows as if the models would not be animated.

Re: (WIP) Better Shadowmapping [Re: Slin] #451047
04/27/15 18:41
04/27/15 18:41
Joined: Mar 2015
Posts: 23
Frankfurt
JcI_the_second Offline
Newbie
JcI_the_second  Offline
Newbie

Joined: Mar 2015
Posts: 23
Frankfurt
Cool! Thank you Slin!

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1