Author Topic: Shadows  (Read 474 times)

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Shadows
« on: August 14, 2017, 06:04:38 am »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Shadows
« Reply #1 on: August 14, 2017, 09:49:07 pm »
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?

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Shadows
« Reply #2 on: August 14, 2017, 10:31:43 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Shadows
« Reply #3 on: August 15, 2017, 07:54:42 am »
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.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Shadows
« Reply #4 on: August 16, 2017, 05:52:55 am »
I've emailed you one. But my forest is actually even bigger than that (regardless, the artifacts are plainly visible). Thanks in advance.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Shadows
« Reply #5 on: August 22, 2017, 12:36:59 am »
Have you had a look at it, Egon?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Shadows
« Reply #6 on: August 22, 2017, 08:55:32 am »
I've replied to your email yesterday.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Shadows
« Reply #7 on: August 22, 2017, 10:28:38 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Shadows
« Reply #8 on: August 22, 2017, 09:00:17 pm »
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?

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Shadows
« Reply #9 on: August 25, 2017, 05:11:51 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Shadows
« Reply #10 on: August 28, 2017, 11:54:56 am »
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.