Shadows #17

Closed
opened 2024-06-12 18:14:58 -04:00 by SeanOMik · 4 comments
Owner
Resources: * https://learnopengl.com/Advanced-Lighting/Shadows/Shadow-Mapping
SeanOMik added the
Kind/Feature
Priority
Medium
labels 2024-06-12 18:14:58 -04:00
Author
Owner

Was able to get directional shadows working!
image

Whats left to do:

  • Shadow map atlas (DOOM 2016)
  • Point light shadows
  • Spot light shadows
  • Cascaded shadow maps (1, 2)
  • Aliasing
    • PCF (simple aliasing, not very realistic)
    • PCSS (much more realistic, but more expensive) (1, 2, NVIDIA paper)
Was able to get directional shadows working! ![image](/attachments/1b2bb04f-b9d0-4cb3-8146-d8e07bac94fd) Whats left to do: - [x] Shadow map atlas ([DOOM 2016](http://www.adriancourreges.com/blog/2016/09/09/doom-2016-graphics-study/#shadow-map-atlas)) - [x] Point light shadows - [x] Spot light shadows - [ ] Cascaded shadow maps ([1](https://learnopengl.com/Guest-Articles/2021/CSM), [2](https://ogldev.org/www/tutorial49/tutorial49.html)) - [x] Aliasing - [x] PCF (simple aliasing, not very realistic) - [x] PCSS (much more realistic, but more expensive) ([1](https://github.com/pboechat/PCSS), [2](https://github.com/proskur1n/vwa-code), [NVIDIA paper](https://developer.download.nvidia.com/shaderlibrary/docs/shadow_PCSS.pdf))
683 KiB
SeanOMik added reference feat/shadow-maps 2024-07-04 15:50:20 -04:00
Author
Owner

Got point light shadows (mostly) working!
image
The green light is above the grid cubes, the blue one is above the closest top right corner of the right cube. The scene also has directional shadows.

I think there is an issue with the green shadow not having any ambient light for a portion of the shadow, I will have to dig into that. This is of course using a shadow map atlas. There is currently a bug with the atlas packer that makes the far right column unused, and no texture will be packed there; probably something simple.

Got point light shadows (mostly) working! ![image](/attachments/d0121cdf-345e-43b8-85e7-d6a9379938e2) The green light is above the grid cubes, the blue one is above the closest top right corner of the right cube. The scene also has directional shadows. I think there is an issue with the green shadow not having any ambient light for a portion of the shadow, I will have to dig into that. This is of course using a shadow map atlas. There is currently a bug with the atlas packer that makes the far right column unused, and no texture will be packed there; probably something simple.
607 KiB
Author
Owner

PCF and PCSS have been implemented!! This ForgeJo instance went down for a week when I was working on PCF and PCSS, so I wasn't able to update this issue. Anyway, here's a picture without ambient lighting on the point light:
image

Here's an image showing PCSS on the directional light:
image
Notice how the shadows get fuzzier at the tip of the shadow due to how far away the blocker is, but they're still sharp near the blocker.

Shadows for spotlights are still not implemented at all. PCSS is also not implemented for point lights. I'm wondering if its worth doing so since its expensive and may not make much sense for them since they're usually small lights.

I want to make some improvements to the shadow bias by doing more than just a constant depth bias. I was thinking of Adaptive Depth Bias, normal-offset bias (GDC poster, dead blog), or Receiver Plane Depth Bias (slide 36).

The issue with receiver plane depth bias is that I'm using such an old version of wgpu and winit that it doesn't support dpdx and dpdy, so I would have to update those which could be a big pain. It looks like receiver plane depth bias is used by unity, so it may be the best option. Doing a quick google, it looks like implementations of normal-offset bias also use dpdx and dpdy, so I may be out of luck there too. Seems like the best option is to complete the tasks for this issue and create more issues for improving bias that will get done after updating wgpu and winit.

PCF and PCSS have been implemented!! This ForgeJo instance went down for a week when I was working on PCF and PCSS, so I wasn't able to update this issue. Anyway, here's a picture without ambient lighting on the point light: ![image](/attachments/43ae2ddc-efc9-4264-a868-054d42b7c727) Here's an image showing PCSS on the directional light: ![image](/attachments/1e4822fa-6513-4ab1-90d1-840d124e2b32) Notice how the shadows get fuzzier at the tip of the shadow due to how far away the blocker is, but they're still sharp near the blocker. Shadows for spotlights are still not implemented at all. PCSS is also not implemented for point lights. I'm wondering if its worth doing so since its expensive and may not make much sense for them since they're usually small lights. I want to make some improvements to the shadow bias by doing more than just a constant depth bias. I was thinking of [Adaptive Depth Bias](https://w3-o.cs.hm.edu/users/nischwit/public_html/AdaptiveDepthBias_WSCG.pdf), normal-offset bias ([GDC poster](https://web.archive.org/web/20180524211931/https://www.dissidentlogic.com/old/images/NormalOffsetShadows/GDC_Poster_NormalOffset.png), [dead blog](https://web.archive.org/web/20171101113525/http://www.dissidentlogic.com/old/)), or [Receiver Plane Depth Bias](https://web.archive.org/web/20230309054654/http://developer.amd.com/wordpress/media/2012/10/Isidoro-ShadowMapping.pdf) (slide 36). The issue with receiver plane depth bias is that I'm using such an old version of wgpu and winit that it doesn't support dpdx and dpdy, so I would have to update those which could be a big pain. It looks like receiver plane depth bias is used by unity, so it may be the best option. Doing a quick google, it looks like implementations of normal-offset bias also use dpdx and dpdy, so I may be out of luck there too. Seems like the best option is to complete the tasks for this issue and create more issues for improving bias that will get done after updating wgpu and winit.
349 KiB
380 KiB
Author
Owner

I got spot lights working a couple of weeks ago, but in the process kind of broke PCSS on directional lights. Due to burn out I took a short break by writing a shader preprocessor, and just fixed the issue. Here's a screenshot PCSS directional light and PCF spot light shadows:
image

I still need to do cascading shadow maps, but need a break from rendering so I created another issue for it: #22

I got spot lights working a couple of weeks ago, but in the process kind of broke PCSS on directional lights. Due to burn out I took a short break by writing a shader preprocessor, and just fixed the issue. Here's a screenshot PCSS directional light and PCF spot light shadows: ![image](/attachments/fb1c13e8-2712-4c11-ac24-f257ea8c670e) I still need to do cascading shadow maps, but need a break from rendering so I created another issue for it: #22
280 KiB
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SeanOMik/lyra-engine#17
No description provided.