Main Menu

Shadows

Started by AGP, August 14, 2017, 06:04:38 AM

Previous topic - Next topic

AGP

Egon, I'd really like to solve the shadow-map movement issue in jpct. I've put out finishing a nice little RPG game for a couple of years because of it. The following shows the problem I get when I move the sun:

https://www.youtube.com/watch?v=Z3KdV7mqEHY

EgonOlsen

I'm not sure what's going on there, because the video compression makes it very difficult to spot the actual problem. At first glance, I would say that this is normal behaviour and caused by the resolution of the shadow map and/or how much it's streched across the surface. It could be an accuracy issue related to the latter, but again...it's hard to tell anything from that video. Do you have a test case for this?

AGP

The movement is terrible, Egon, even with the shadow map at the size of 8192 pixels. There's no compression problem on the video: what you think is a codec issue is the shadow issue.

EgonOlsen

I really can't see what's going on in this video...it can still be an accuracy issue due to problems in handling very scretched texture coordinates and it's impossible to tell this from this video...but anyway, the shadow mapping in desktop jPCT is based on the fixed function pipeline. What this pipeline does is, well, fixed and there's no way to change its behaviour.
A test case would be nice though...everything else is wild guessing on my side.

AGP

I've emailed you one. But my forest is actually even bigger than that (regardless, the artifacts are plainly visible). Thanks in advance.

AGP

Have you had a look at it, Egon?

EgonOlsen

I've replied to your email yesterday.

AGP

Sorry, I got a lot of emails yesterday. If some filter could be applied to the shadows it would already help a good deal (is there no way, to access the shadow map and, thus, for instance, apply java.awt.Image filters?). Thanks for having a look.

EgonOlsen

No, you can't filter a depth map on the GPU with some Java2D means. You can filter it in a shader. The fixed function pipeline that desktop jPCT uses for shadow mapping doesn't support this. You can enable a kind of filtering in the ShadowHelper, but it might cause some artifacts and usually doesn't really help much anyway.

Apart from that, your shadows in that example look really low res for a 8192*8192 depth map. Have you tried to play around with the fov setting?

AGP

I'm sure that I did in the past, but what's a reasonable value? And, since you have the scene, are the scales and distances reasonable?

EgonOlsen

Scales and distances doesn't really matter as long as they are consistent and not too small/large for being represented by floats.

Reasonable values...hard to tell. Just try smaller values (remember to adjust the min/max fov settings as well) and see if that helps. If it gets too small, the shadows will be limited to only a small part of the scene.