View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0006120 | Spring engine | General | public | 2019-01-21 22:20 | 2019-01-28 13:53 |
| Reporter | lhog | Assigned To | |||
| Priority | low | Severity | feature | Reproducibility | N/A |
| Status | closed | Resolution | suspended | ||
| Product Version | 104.0 +git | ||||
| Summary | 0006120: Add shadow evaluation result to then produce softer shadows | ||||
| Description | Hi. I was looking into the ways we can improve shadows in spring to get closer to what commercial games like Ashes of Singularity produce in this regard. I have came to nothing better, than to render the shadow evaluation result in the form of depth difference between the depth value stored during the shadow pass and factual depth value during the rendering of the object. The result (stored in texture) is then blurred with respect to the stored value (the bigger the depth difference - the stronger the blur will be) and blur result is stored to yet another texture, that is just mixed with diffuse (or whatever) color channel in the respective shader. So I wanted to prototype this idea and found that I don't quite understand how this can be done from the user (Lua) space or with minimal engine changes. Would you be able to assess if this is doable at all and perhaps provide some guidance how to implement it most efficiently? | ||||
| Additional Information | https://megagames.com/sites/default/files/game-images/ashesotSingularity.jpg | ||||
| Tags | No tags attached. | ||||
| Checked infolog.txt for Errors | |||||
|
|
That Ashes screenshot looks like PCSS to me which generates variable-sized (the interesting part) penumbras, although tall vertical structures in combination with an oblique sun angle would give a better impression. IIRC this technique requires no engine changes (just fragment shader work), but there may be hidden subtleties wrt shadowmap filtering. I'll see if I can find some time to experiment. |
|
|
I was under impression that PCSS was very heavy on pixel shader performance, but yeah, worth trying. I'll try to port over one of existing implementation floating around. |
|
|
Faced first hiccup. I define two samplers for shadows. uniform sampler2DShadow shadowTex; uniform sampler2D shadowTexDepth; This is done in order to be able to work efficiently with traditional PCF shadows (for which it's preferable to use sampler2DShadow) and PCSS (which needs exact shadow map Z value, so sampler2D must be used). Both are bound to the same texture unit. Here's the thing. I actually do $shadow texture binding either in gadget:DrawGroundPreForward() or gadget:DrawGenesis(). Funny (not so) thing is that: * if $shadow is bound in DrawGroundPreForward() then sampler2D shadowTexDepth has non-sense values (1.0 for each pixel in the texture), but shadow mapping through sampler2DShadow shadowTex works perfectly fine. * other way around if $shadow is bound in DrawGroundPreForward() then sampler2D shadowTexDepth has sane values, but sampler2DShadow shadowTex returns 0.0 as a comparison result always, so everything is in shadow. Bounding $shadow in both aforementioned callins makes sampler2D shadowTexDepth invalid. Is there anything I can do on the Lua side to keep both samplers operational in the same time or is there anything can be done engine side? P.S. PMed you an invitation to spring discord server. |
|
|
Derp: "other way around if $shadow is bound in DrawGroundPreForward()" should be read "other way around if $shadow is bound in DrawGenesis()" |
|
|
While possible in D3D, for backward compatibility reasons the GL spec disallows associating two samplers (of different texture types) with the same texture unit, which requires an extension (ARB_sampler_objects) and at least one engine patch to get around. Until then you have to make a copy of the shadowmap each frame. Thanks for the invite, will join later this evening. |
|
|
Hmm, thanks. I think I saw online guides where both samplers were used simultaneously. Anyway I also thought about this reason yesterday and specifically removed another sampler from the shader and uniform binding table. Still one sampler type only worked in DrawGroundPreForward() and another one - in DrawGenesis(). Even if they were specified in GLSL and Lua alone. |
|
|
I'm not alone to step up on this: https://www.opengl.org/discussion_boards/showthread.php/200048-Can-you-use-sampler2D-and-sampler2DShadow-on-the-same-texture |
|
|
alfonse's reply is basically what I had in mind, glBindSampler is part of ARB_sampler_objects. idk if all (especially AMD) drivers will appreciate the texelFetch approach but it works on mine. |
|
|
Yep, texelFetch works for me as well (NV/Win10). At the movement terrain PBR has zero users, except myself, therefore I guess I'll continue with this hacky way. We will figure something out later on, if hacky way doesn't work for someone else. Please close. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2019-01-21 22:20 | lhog | New Issue | |
| 2019-01-22 03:00 | Kloot | Note Added: 0019676 | |
| 2019-01-22 12:57 | lhog | Note Added: 0019677 | |
| 2019-01-25 14:07 | lhog | Note Added: 0019685 | |
| 2019-01-25 16:19 | lhog | Note Added: 0019686 | |
| 2019-01-25 18:33 | Kloot | Note Added: 0019687 | |
| 2019-01-25 18:37 | Kloot | Note Edited: 0019687 | |
| 2019-01-25 19:08 | lhog | Note Added: 0019688 | |
| 2019-01-25 19:57 | lhog | Note Added: 0019689 | |
| 2019-01-25 21:15 | Kloot | Note Added: 0019691 | |
| 2019-01-28 08:33 | lhog | Note Added: 0019693 | |
| 2019-01-28 13:53 | Kloot | Status | new => closed |
| 2019-01-28 13:53 | Kloot | Resolution | open => suspended |