Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / What is the secret of getting good looking shadows?

Author
Message
MikeHart
AGK Bronze Backer
21
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 23rd Aug 2017 19:45
I am puzzled with the newly build in shadows. The help file mentions that you will get good results with maps sizes 512x512 or 1024x1024. But what I see doesn't please me. All fuzzy or zickzacky at the edges, even with the most simple geometry. You need to use 2048x2048 or higher to remove the artifacts.
Any secrets or do you need such huge shadow maps?
Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200. Using AGK2 Tier 1.
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 24th Aug 2017 00:54 Edited at: 24th Aug 2017 00:55
Well except of changing the mode to 3 for cascaded shadow maps and smoothing modes 1 or 2 for multisampling which also doesn't please me very much we don't get more variety...

SetShadowSmoothing
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 24th Aug 2017 09:41
This worked for me:

SetShadowRange( 30 )
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 3rd Sep 2017 01:31
@Basicfanatic: Yea, better for close quarters work, but even going up to 64 or so has a visible negative effect.

I'm not that impressed with shadows to be honest.

I have to set 8K shadow map to get it looking decent, then even with my 4Gb x 2 (yea, I know SLI isn't supported but still !) I get the attached error after a random time.

I've tried all kinds of variations and all pretty poor. The map size seems to be the key, but 8K doesn't even work with my massive cards, let alone average Joe.

If there was some better guidance on the bias, which seems to be the other critical factor with self shadowing, then maybe we could get some results.

Until then, shadows are like, meh, and I'll probably consign them to the "nearly but not quite" pile, which is annoying.

What should I do? Scale my world down to a tiny size - would that help?


Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 3rd Sep 2017 02:07 Edited at: 3rd Sep 2017 02:07
These are my settings


Most of all i found the shadows to be way too dark so i SetAmbientColor( 150,150,150 ). This softens the shadows and makes the artifacts a little less obvious.

Attachments

Login to view attachments
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 3rd Sep 2017 02:37
Quote: "What should I do? Scale my world down to a tiny size - would that help?"

Nope you would need to change the camera range bias and everything with it and ending up with the same result...
The shadow map fits the camera range by default so if you have a short range you have a higher shadow resolution per object
So you can either make a larger map or shorter view range besides the shadow mode and smoothing.
The bias is a little hack we use to get rid of moire pattern we get instead...you need to change that depending on your world/camera size.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 3rd Sep 2017 02:37
The ambient color change does help. Nice one.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 3rd Sep 2017 02:41
@blink0k I have to say, every time I see a screenshot of your game, I am impressed; I love everything about it, the design and the style is lovely.

even the name is awesome
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 3rd Sep 2017 02:50
Quote: "@blink0k I have to say, every time I see a screenshot of your game, I am impressed; I love everything about it, the design and the style is lovely."


yeah I second that, its nice to see it progressing.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 3rd Sep 2017 02:58
Quote: "The shadow map fits the camera range by default so if you have a short range you have a higher shadow resolution per object
"

@Janbo Do you mean that the shadow map is related to the distance from the shadowed object?
What reference is the shadow map size for then?

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 3rd Sep 2017 03:33
Haha. Thanks guys. Glad the ambient thing helps
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 3rd Sep 2017 12:06 Edited at: 3rd Sep 2017 12:14
Quote: "Do you mean that the shadow map is related to the distance from the shadowed object?"

If you don't use SetShadowRange it fits the camera near to far range.
The shadow map is projectet over the world(not the whole world... only the visible part ie from the near to far plane) so objects further away get "larger shadow pixels"
Quote: "but drawing shadows all the way to the far plane may take some quality away from those shadows closer to the camera.
Therefore setting the shadow range lower than the camera far range may improve shadow quality at the expense of distant objects not having shadows"
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 6th Sep 2017 00:13
Well, I finally found some compatible settings with what I learned here, so good job all.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 1st Oct 2017 22:21
Still can't eradicate this crappy banding effect on faces sort of in line with global light.
It seems to be the self shadowing bias which doesn't really work?

Anyone have some luck with this?

MikeHart
AGK Bronze Backer
21
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 3rd Oct 2017 09:15
Nope, no luck. Only using a shadowmap of 2048x2048 or better 4096x4096 gives me decent results.
Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200. Using AGK2 Tier 1.
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 3rd Oct 2017 22:01 Edited at: 3rd Oct 2017 22:03
nz0 wrote: "crappy banding effect on faces"

Do you mean the moire like pattern which is called "shadow acne" ?
It looks like this:
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 3rd Oct 2017 22:57
Oddly, I'm not getting any issues at all, even on a complex model. I've got the shadow map size set to 4096x4096 though. That banding and such though, I don't get that issue.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 4th Oct 2017 00:49
Janbo, yes, thats it.

I only get it on (flat) faces which seem to be <nearly> in line with the global light.
Some adjustments to the setting seem to help a little, but not completely. I've gotten quite close, but no cigars yet.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 4th Oct 2017 08:23
@BlinkOk : the style for this game is great
AGK2 tier1 - http://www.dracaena-studio.com
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 4th Oct 2017 17:47
Quote: "It seems to be the self shadowing bias"

Actually SetShadowBias should do the trick if it is shadow acne... but ->
Quote: "in line with the global light"

Do you mean the faces parallel to the direct light rays have moire pattern also ?
If yes I can't explain that...
If no and it only flickers from lit to unlit if you move the camera then ...well I can explain it but there might be no good solution to it except of tinkering with the settings
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 4th Oct 2017 19:11
Here's an example.

The camera is still, but the light source is moving.

Attachments

Login to view attachments
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 5th Oct 2017 16:12 Edited at: 5th Oct 2017 16:36
You could try make the bias smaller, but i doubt you can get rid of this effect with SetShadowBias completely.
It looks a bit like paul don't change the bias according to the slope... I'll take a look at pauls shadow code...
[Edit]
But he does...Well not like I would do it but he made "some" calculations to change the bias according to the slope
He did: highp float bias = agk_ShadowParams.y*10.0*(1.0-dot(-agk_DLightDir, normal))^3+ agk_ShadowParams.y; where agk_ShadowParams.y is the shadow bias I guess.
I'd do: highp float bias = agk_ShadowParams.y*tan(acos(clamp(dot(agk_DLightDir, normal), 0.0, 1.0)));
[/Edit]
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 5th Oct 2017 22:16
If shadows are going to get any improvements, then would it not be too much to ask to have the alpha values of the shadowed object taken into account?

I wanted to have some leaves shadowed for instance, and I only get squares from the billboard object.

Also, we will sometimes need the back face to be able to make shadows.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 5th Oct 2017 23:30
@blendo : Thanks for the props mate

@nz0 : Build 2017.09.04 - Objects with alpha masking enabled will now cast an alpha masked shadow
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 6th Oct 2017 20:57 Edited at: 6th Oct 2017 21:07
Quote: "@nz0 : Build 2017.09.04 - Objects with alpha masking enabled will now cast an alpha masked shadow
"

I have the very latest version - didn't work. Check the leaves in the screenshot.
[edit] I didn't try the 09.04 version for alpha shadows, but maybe it's broke? Can you verify it works for you in the current version?

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 6th Oct 2017 23:29
i only remembered seeing it in the changes list. the description could mean a couple things.
Maybe post a question/bug report here
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 7th Oct 2017 17:26 Edited at: 7th Oct 2017 17:30
Quote: "Can you verify it works for you in the current version?"

Yes, they work

GodRay Effect with shadow using SetObjectAlphaMask:

Attachments

Login to view attachments
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 7th Oct 2017 17:33 Edited at: 7th Oct 2017 17:36
That tree looks like a model - I mean a textured plane.

[edit] oh, yea. Just tried alphamask instead of alpha transparency and it works
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 10th Oct 2017 01:04
It would be nice if the slope bias was sorted out, the lack of back face shadowing is somewhat more of an issue in a fully immersed scene with 360 degree movement.
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 21st Oct 2017 13:30 Edited at: 21st Oct 2017 22:27
You mainly see this on low poly object , where the sides are 100% flat , but they are still interpolated so you get these weird shadows.
Just doing the slope bias , will not fix this ( but make it a bit better ) , you also need to fade the shadow slowly away on the dark side of the objects.

Shader fix:


Where lightFactor is the shadow.

Screenshot:
You can see how its fixed in this low poly project.

Video of fixed shadow.
https://www.youtube.com/watch?v=vYwyXMOXF7o

Not sure if Paul can use this , but this fixed it for me
Subscribe and checkout great AppGameKit video's here: Videos click here
Latest GameGuru Loader news: News click here
best regards Preben Eriksen,

Attachments

Login to view attachments
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 24th Oct 2017 20:25 Edited at: 24th Oct 2017 20:28
Something I haven't seen in this discussion is that appears to me that the size of objects in a world affects the shadows also, in the sense of resolution/quality/jagged edges.
This for instance gives nicer shadows:



Than something like this:



Most likely for the camera not being too close up on it? If you zoom in too much then basically just about anything will look weird.

Login to post a reply

Server time is: 2024-11-24 08:33:59
Your offset time is: 2024-11-24 08:33:59