Jump to content
The Dark Mod Forums
Sign in to follow this  
vorob

Thank you for soft shadows :)

Recommended Posts

Guys, this really looks magnificent! I think 10 minutes of my 2 hours stream I was playing with light and checking shadows https://youtu.be/gMAvaK2zqxo?t=5360

Soft shadows add volume to the scene it looks more natural and believable. 

Where can I read about stencil shadows and maps? From what i've seen map looks much better. Then why stencil exists? 

Now my tiny dream to see a daylight mission with the fast-moving sun that will cast shadows from every building and character. 

Edited by vorob
  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
8 hours ago, vorob said:

Where can I read about stencil shadows and maps?

 

Quote

From what i've seen map looks much better. Then why stencil exists? 

Shadow maps require much more video memory. Also, they are less tested and have both general and TDM-compatibility issues.

Quote

Now my tiny dream to see a daylight mission with the fast-moving sun that will cast shadows from every building and character. 

Then open world, online multiplayer, PBR\RTX, etc, LOL

  • Like 1

Share this post


Link to post
Share on other sites

Sorry, we can't show this content because you do not have permission to see it.

First part not working.

6 minutes ago, duzenko said:

Then open world, online multiplayer, PBR\RTX, etc, LOL

Only PBR/RTX please :)

Share this post


Link to post
Share on other sites
2 hours ago, duzenko said:

Then open world, online multiplayer, PBR\RTX, etc, LOL

Don't forget to port it to Unreal engine. ;)

  • Like 1

Share this post


Link to post
Share on other sites
On 1/10/2020 at 4:09 PM, vorob said:

Sorry, we can't show this content because you do not have permission to see it.

First part not working.

Only PBR/RTX please :)

Like in all things where people are working for free and on their spare time be glad work is done at all. The things you really want to be implemented may never be, unless people with the knowledge and the free time do it, want to do it. But it never hurts to ask. 

 

If you don't mind the opinion of a random internet person, see the hidden content below to know more about stencil shadows and shadow maps. 


 

Spoiler

 

stencil shadows versus shadow maps, like already said, stencil shadows was the original shadowing system of the engine/game, is a very old technique where the silhouette of the objects is calculated, each frame then real geometry (geometry is made of triangles) is extruded till it intersects with a surface, like a floor or wall , etc. Stencil shadows are very nice looking, very fast to calculate and they make very crisp shadows out of the box, but they have some serious disadvantages, one you can not make soft shadows out of the box, not without resorting to tricks that will make performance worse, second because you are extruding objects silhouettes they do not support transparent textures, so if you have, for example a tree ingame the shadows for the leafs/branches, will be the invisible squares and not the visible leaf shape. 

Pros of stencil shadows: 

   Make very nice looking and crisp shadows out of the gate

   Based on geometry can work in very old GPUs with 1GB or less of VRAM

   Is possible to make then have soft edges today (but not as soft as shadow maps)

Cons of stencil shadows:

    Do not support transparency/translucency or similar, btw for that Doom 3 used projected textures (akin to shadow maps but you add to place the shadows by hand).

    You can't make them soft if the game needs to support very old GPUs, like mobile GPUs in older phones.  

Stencil shadow technique (the green lines are representations of the extrusion of the silhouette) 

shadow-vol04.gif

 

IMO they look very nice and clean

realtime-shadowing-techniques-shadow-vol

 

 

Shadow mapping is a relatively more modern technique, not to say is really new, is not, I think the first game I saw with shadow maps was Splinter Cell 1 from 2002. About the technique itself, shadow maps are textures, not real geometry like stencil shadows, afaik they work by rendering the object to a texture from the point of view of the light, there's no extrusion of geometry.

Pros of shadow maps:

         They support transparency out the box.

          Compared to stencil shadows is very easy to make them very soft and more realistic, that is why all modern games use them exclusively. 

Cons of shadow maps:

        Like already said take more GPU memory (not that important for modern GPU's with 3GB or more of VRAM).

        GPUs are better at crunching triangles than pixels, so stencil shadows are much faster ( again not that important for modern GPUs).

        Are also very resolution dependent, low rez shadow maps look very pixelated and ugly (not prevalent in modern games was a problem on very old games). 

pcf.png  

 

large4.jpg

 

 

Edited by HMart
  • Like 1

Share this post


Link to post
Share on other sites

Actually, looking by the MSI Afterburner stats, current TDM soft shadow implementation eats up a lot of GPU performance, not only GPU memory. At this point stencil shadows with soft shadows option are more performance efficient than shadow maps with decent quality/resolution.

Share this post


Link to post
Share on other sites
3 hours ago, peter_spy said:

Actually, looking by the MSI Afterburner stats, current TDM soft shadow implementation eats up a lot of GPU performance, not only GPU memory. At this point stencil shadows with soft shadows option are more performance efficient than shadow maps with decent quality/resolution.

Do you think it will be optimized later on?

Share this post


Link to post
Share on other sites
20 hours ago, peter_spy said:

Actually, looking by the MSI Afterburner stats, current TDM soft shadow implementation eats up a lot of GPU performance, not only GPU memory. At this point stencil shadows with soft shadows option are more performance efficient than shadow maps with decent quality/resolution.

Agree but at least to me is playable enough.

Btw right now afaik TDM is not using the ability to cast shadows from alpha images, unless I've played the wrong missions... so there should be no difference between the two, in the amount of shadows being cast i mean. But Imagine when eventually they make maps cast shadows from alpha textures, then the game will have more shadows per scene than stencil shadows, if they don't get deeply optimized, performance will suffer even more, compared to stencil, not a easy task.

Btw i'm not sure but I imagine that totally removing stencil from the engine will not be easy, the engine code really being deeply connected to them and all, but I could be wrong. One thing is certain I don't envy the TDM coders "job". 

Share this post


Link to post
Share on other sites

Ye, my 2080 is loaded for 99% sometimes with shadow maps, but i'm okay with it since such shadows looks gorgeous! 

Edited by vorob

Share this post


Link to post
Share on other sites
On 1/11/2020 at 7:26 PM, HMart said:

If you don't mind the opinion of a random internet person, see the hidden content below to know more about stencil shadows and shadow maps. 

Thx! Though it looks like ancient info cause no one would say today that crisp stencil shadows look good. I think right after the first game with soft shadows, crisp shadows became awful thing. IMHO.

Share this post


Link to post
Share on other sites
1 hour ago, vorob said:

Ye, my 2080 is loaded for 99% sometimes with shadow maps, but i'm okay with it since such shadows looks gorgeous! 

I can only guess that's because we need more efficient method for cascading / splitting shadow maps, not sure how it's done now. To the end user the shadow type doesn't matter, as long as it looks good. It makes a difference for asset makers though, as stencil shadows are cast from the back faces, while shadow maps are cast from the front faces. That influences model building techniques and optimisation tricks.

Share this post


Link to post
Share on other sites
4 hours ago, vorob said:

Thx! Though it looks like ancient info cause no one would say today that crisp stencil shadows look good. I think right after the first game with soft shadows, crisp shadows became awful thing. IMHO.

What you want i'm old man!  :D  But I do think that stencil shadows still look good, specially when soft edges are also available. Btw you still can find relatively modern games (indie mostly) with PCF based shadow maps at max 1024 rez and those look worse than stencil shadows IMO, specially worse when badly implemented shadow maps can flicker or have what is called shadow acne. 

https://computergraphics.stackexchange.com/questions/2192/cause-of-shadow-acne

But yes modern AAA games pretty much stopped using Stencil shadows, and like I said before you can make maps look much more realistic, i'm aware of that. ;)

Share this post


Link to post
Share on other sites
On 1/21/2020 at 3:54 AM, Swiggy said:

I just want to say that while I also like soft shadows, I still stick with stencil shadows for multiple reasons: (1) it's still the fastest shadow implementation in the engine, (2) it's the most mature and has the least rendering issues of the shadow implementations, generally speaking, and (3) the look of the shadows reminds me of Doom 3 which I still look on fondly, plus it's unique looking and novel since no-one else uses them anymore.

Still progress and all that. I'll probably transition to shadow maps once it becomes the default and stencils are deprecated/removed.

Yes stencil are fast, the technique itself is fast, because in reality is just simple geometry and modern GPU's can render millions of triangles but this particular one was made by John Carmack so based on that, you can expect the best of the best.

Not to diminish the work of who implemented shadow maps in the engine tho, you need to have a really high knowledge on Opengl rendering and specially the engine itself, to know how everything is connected, i'm working on idtech 4 source code for some years now and I still don't know what a large portion of the engine is doing. So yes kudos to ever implemented shadow maps in TDM engine, you are a very good coder. 

Share this post


Link to post
Share on other sites

The performance comparison is not that simple. Yes, the GPU side is fairly cheap, but even there it has drawbacks. In particular, it requires to render each (shadow-casting) light separately, which is not ideal in modern rendering architectures and does not scale particularly well with many lights. And while the rendering itself is cheap, creating the necessary shadow geometry is not. That's traditionally done on the CPU, and it's one of several reasons why TDM is currently heavily CPU-bottlenecked.

There are a couple of reasons why it's currently not the case, but I'm willing to wager that shadow maps will eventually outperform stencil in TDM :)

  • Like 1

Share this post


Link to post
Share on other sites

I assume this "it requires to render each (shadow-casting) light separately" is true even for a forward+ renderer and a Deferred render?

And forgetting that stencil can't do alpha shadows and that is destined to the chopping block, if you really wanted to maintain Stencil and make them much faster, couldn't the silluet and geometry creation be done on the GPU? To free the CPU for better physics, AI and sound effects, using a geometry shader or a compute shader?

Of course this would require anyone with the necessary know-how willing to do it and also it would pretty much prevent TDM to run on older GPUs but truth be told, TDM 2.08 will break backwards compatibility anyway. 

Edited by HMart

Share this post


Link to post
Share on other sites

At least for classical stencil shadows, yes. You can't really implement a forward+ renderer with stencil shadows. Technically, TDM uses a trick for soft stencil shadows that would allow it, but it is detrimental to performance. And even then, stencil shadows would have the disadvantage that they need to be rerendered on every frame, whereas shadow maps can potentially be cached as long as the light itself or the shadow casters in its vicinity don't move.

As for putting shadow volume generation to the GPU: that's possible, in principle. However, my experience with geometry shaders has been poor, they usually tank GPU performance quite significantly if you use them for anything other than a few simple objects. I'm not sure it's a good trade-off, and personally at least I think the kind of effort needed to implement it is better spent on improving shadow mapping. But that's just my personal opinion :)

  • Like 1

Share this post


Link to post
Share on other sites

ok thanks for the info. Btw i'm not sure because i'm not a graphics coder but don't stencil shadows on idtech 4 also get cached when the light doesn't move? At least I remember seeing something to that end in the engine console, perhaps r_useOptimized shadows or r_useTurboShadows I really don't remember.

 

edit: it seems useOptimizedShadows is the one. :)

idCVar r_useOptimizedShadows( "r_useOptimizedShadows", "1", CVAR_RENDERER | CVAR_BOOL, "use the dmap generated static shadow volumes" );

 

Edited by HMart

Share this post


Link to post
Share on other sites

You're right, the shadow geometry can be cached. Rendering it to the stencil buffer, however, cannot, because it's done from the camera's point of view (unlike shadow maps), and that typically changes between frames. But of course, the geometry is the more significant cost :)

  • Like 2

Share this post


Link to post
Share on other sites

Not that I'm defending stencil shadows too much, but IMO alpha shadows are not as groundbreaking as they seem to, at least in TDM context. It's not like you'll be doing modern chain link fences with lights behind them. And for stuff like windows you can use actual geometry, the engine will take it just fine, as long as you don't go overboard with something (lights, materials, etc.).

Share this post


Link to post
Share on other sites

Don't agree, you can't really say alpha shadows are ground breaking in TDM context, but that is because TDM for the most part doesn't cast any shadow from alpha surfaces, not are the scenes made with that in mind. So in the case of current TDM, is not that important if alpha shadows are missing but if you made your scenes with maps in mind you would see that they make a huge difference. Maps in TDM have a huge potential that is not currently being explored and perhaps never will because that would mean breaking some old missions.

Also about "chain link fences" the problem is that those based in real geometry, can't be very complex, where's a alpha texture can have all the complexity on its pattern that it wants.

And don't tell me shadows cast by those are not cool looking, because I certainly don't agree, they certainly are, they can also make a flat scene have a totally different feeling to it. :)

 

I'm sure you know this but for those that don't, this is what shadow maps can do with alpha transparency that stencil cannot:

Cast shadows unto and from particles:  http://www.impressivetoast.com/content/image/VSFP/D.png 

Cast colored shadows from stained glass (possible to do in TDM with texture projectors but is a manual job)

https://docs.unrealengine.com/Images/Engine/Rendering/Materials/HowTo/ColoredTransluscentShadows/TCS_Lit_CO_Result.jpg

Cast shadows from plants using alpha, trees, grass, bushes, etc (massive potential)

Cast shadows made of very complex patterns:

(btw something a made fast in Modo and those are 2048 rez maps)

(Something also possible in TDM with texture projectors but again manual job and if low rez can look very different to the clean sharp stencil shadows around)

test_maps.JPG

Edited by HMart

Share this post


Link to post
Share on other sites

Nah, it's not the problem of TDM not having alpha planes; it's just that it won't or doesn't need to have too many of them, even with the shadow maps implemented. That's because for surfaces that are close to the player you will use geometry anyway. And you don't need super complex geometry either, as e.g. for iron fences you can fake details and soft edges with normalmaps.

As for grass and bushes on alpha planes, this is another dead end due to massive performance problems caused by overdraw. It's actually cheaper to make leaves on simple polygons than to have a whole area made of transparent cards; this is a thing known for many years now in realtime rendering.

I'd rather say that soft shadows, when done right with proper optimisation, will be just more beneficial in general for all the stuff that's already being done by stencil shadows, not because the added benefits are so important.

Edited by peter_spy

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...