Jump to content
The Dark Mod Forums

[2.11] Stencil shadows optimizations


stgatilov

Recommended Posts

  • 1 month later...

This improvement is only for stencil shadows correct? I believe I used shadow maps previously... likely because they were faster at the time, and I think they're the only mode that allowed shadows to grow softer with distance from the caster rather than having a constant softness? If stencil supports the same features as maps now and are expected to be faster or as fast, I may use it with this optimization! I'll likely test at least if it helps, probably not tonight as I'm first getting re-accustomed with the 2.10 release.

Link to comment
Share on other sites

44 minutes ago, datiswous said:

should be added to [feature discussion threads]

I think not, because it is not a feature, it is optimization.
Neither players nor mappers really have to know about its existence.

The reason for this thread was to check what beta-testing players would say about performance: it is better/worse and how much.

25 minutes ago, MirceaKitsune said:

This improvement is only for stencil shadows correct? I believe I used shadow maps previously... likely because they were faster at the time, and I think they're the only mode that allowed shadows to grow softer with distance from the caster rather than having a constant softness? If stencil supports the same features as maps now and are expected to be faster or as fast, I may use it with this optimization! I'll likely test at least if it helps, probably not tonight as I'm first getting re-accustomed with the 2.10 release.

This is for stencil shadows only, not applicable to shadow maps.

Stencil shadows do have larger penumbra at larger distance from light: it is distance to obstacle which is ignored by stencil shadows but used by shadow maps. This technical limitation is hard to workaround without shadow maps.

Link to comment
Share on other sites

I upgraded to latest dev earlier due to what I wrongly perceived as a bug with 2.10. Decided to test this and I'm glad I did: Enabling r_softShadowsMipmaps breaks stencil shadows and causes them to stop working! Stencil shadows work once setting the cvar to 0, whereas map shadows always work fine. I'm on Linux (Manjaro / KDE) using the default amdgpu driver, I know some issues are specific to it so it may be why.

Here's two comparison screenshots, first being normal and the other broken. Note that when I pressed F12 to take it, I was in reality seeing the the scene just with no shadows... only now noticed everything came out black with only the HUD and entities showing! Will share it here anyway in case it helps.

1194143737_deadeye(2022-10-2405-37-13)(202.08-2085.9-203.75).thumb.jpg.8f44d9fbf571189d8cc7d2543a33ff72.jpg

2041227603_deadeye(2022-10-2405-37-16)(202.08-2085.9-203.75).thumb.jpg.e615a9b6239db05d3eeee5d5685828cd.jpg

Link to comment
Share on other sites

9 minutes ago, nbohr1more said:

Did you reloadModels after changing shadow modes? Did you restart TDM after the change?

Just set the option to stencil and did a full restart: Same issue, no shadows with stencil and the new setting turned on.

Link to comment
Share on other sites

Did you re-run tdm_installer ?

Did you try deleting tdm_base01.pk4 and re-running tdm_installer to ensure you have the latest glprogs?

Did you make sure there is no glprogs folder in your darkmod root directory?

What GPU driver do you have installed ?

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

16 minutes ago, nbohr1more said:

Did you re-run tdm_installer ?

Did you try deleting tdm_base01.pk4 and re-running tdm_installer to ensure you have the latest glprogs?

Did you make sure there is no glprogs folder in your darkmod root directory?

What GPU driver do you have installed ?

A forgotten glprogs directory was causing colors to go crazy, removed that before I started testing. The update went well but just to be extra safe I did that cleaning as well, same issue after reinstalling.

GPU driver is amdgpu, the default installed and used by the OS (not pro version). This is my system info from the KDE panel, Mesa is 22.1.7 with Amdgpu 22.0.0:

Operating System: Manjaro Linux
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kernel Version: 6.0.2-2-MANJARO (64-bit)
Graphics Platform: X11
Processors: 16 × AMD Ryzen 7 3700X 8-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: AMD Radeon RX 570 Series
Link to comment
Share on other sites

10 hours ago, MirceaKitsune said:

This improvement is only for stencil shadows correct? I believe I used shadow maps previously... likely because they were faster at the time, and I think they're the only mode that allowed shadows to grow softer with distance from the caster rather than having a constant softness? If stencil supports the same features as maps now and are expected to be faster or as fast, I may use it with this optimization! I'll likely test at least if it helps, probably not tonight as I'm first getting re-accustomed with the 2.10 release.

Im always confused which one is better. Stencil or mapped shadows. I can't even tell which I chose right now in the game. Could this be renamed for 2.11 to just shadow quality high and low maybe? :D

"Einen giftigen Trank aus Kräutern und Wurzeln für die närrischen Städter wollen wir brauen." - Text aus einem verlassenen Heidenlager

Link to comment
Share on other sites

1 hour ago, SeriousToni said:

shadow quality high and low maybe?

Which one is high and which one is low? I like stencil shadows more visually, but Volumetric Lights usually don't work with them.

For me performance with Stencil shadows is faster, but for others it is (or was) shadow maps.

Link to comment
Share on other sites

6 hours ago, MirceaKitsune said:

Note that when I pressed F12 to take it, I was in reality seeing the the scene just with no shadows... only now noticed everything came out black with only the HUD and entities showing! Will share it here anyway in case it helps.

This happens when you have set fullscreen to Borderless. Typically after an update you forget to change this setting to Fullscreen.

Maybe the other problem is related to this as well?

I think this should be set to Fullscreen by default on Linux systems (and maybe not have the borderless option at all?). I don't know if that's possible. In the description for this setting it should say it is a Windows-only setting.

Btw. what does the borderless functionality under Windows do better? I just tested this on a Windows 10 computer and I didn't see a difference in functionality, so I think it should be Fullscreen by default on both systems.

Edited by datiswous
Link to comment
Share on other sites

5 hours ago, SeriousToni said:

Im always confused which one is better. Stencil or mapped shadows. I can't even tell which I chose right now in the game. Could this be renamed for 2.11 to just shadow quality high and low maybe? :D

I don't think one is better than the other. As far as I understand it, but I haven't really dived into the materia, it's just two different approaches to calculating the shadows. Depending on your hardware and the specific mission one might gain you better performance than the other.

But if you don't notice any difference both visually and performance wise, it doesn't play a role which one you've choosen anyway. So I would suggest: Forget about it :D

  • Thanks 1

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

7 hours ago, stgatilov said:

Post darkmod.cfg and condump then.

Darkmod.cfg

con.txt

As my config is ancient I went for a fresh one only changing some menu settings: Same issue by default.

6 hours ago, SeriousToni said:

Im always confused which one is better. Stencil or mapped shadows. I can't even tell which I chose right now in the game. Could this be renamed for 2.11 to just shadow quality high and low maybe? :D

They're two different implementations I believe: One isn't necessarily better than the other, it's whichever renders fastest and / or looks best, which until now changed with each release. Yesterday I got the impression stencil feels smoother in terms of FPS, but I don't get realistic shadows that soften with distance over surfaces so I wanted maps to defeat that limitation.

Also I use fullscreen not borderless. Borderless helps with some issues... but IIRC it means the OS still renders the desktop and wastes resources, I use fullscreen to ensure maximum FPS.

Edited by MirceaKitsune
  • Thanks 1
Link to comment
Share on other sites

Yep. It seems that the associated shader won't compile via your GPU driver:

Quote

WARNING:Compiling shader file tiled_custom_mipmap.frag.glsl failed:             
0:46(2): error: `return' with wrong type uvec4, in function `sample' returning  
vec4                                                                            
                                                                                                                                                
File indexes:                                                                   
  0 - tiled_custom_mipmap.frag.glsl                                             
                                                                                
WARNING:Failed to attach shader tiled_custom_mipmap.frag.glsl to program        
tiled_mipmap_first. 

  You could try replacing all vec4 references with uvec4 in tiled_custom_mipmap.frag.glsl ?

 

 

 

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

1 hour ago, MirceaKitsune said:

Also I use fullscreen not borderless. Borderless helps with some issues... but IIRC it means the OS still renders the desktop and wastes resources, I use fullscreen to ensure maximum FPS.

Ah sorry. Last time I had this issue I had it set on borderless by accident, changing it to fullscreen fixed it for me. I use almost the same os as you.

Link to comment
Share on other sites

2 hours ago, nbohr1more said:

Yep. It seems that the associated shader won't compile via your GPU driver:

  You could try replacing all vec4 references with uvec4 in tiled_custom_mipmap.frag.glsl ?

Replaced every vec4 with uvec4 (left ivec4 untouched) in tdm_base01.pk4/glprogs/tiled_custom_mipmap.frag.glsl: Still would not work. Here is another condump with this change included:

con.txt

Quote

Checking for changed model files...
Linking GLSL program tiled_mipmap_first ...
WARNING:Compiling shader file tiled_custom_mipmap.frag.glsl failed:
0:53(2): error: `return' with wrong type vec4, in function `sample' returning  uvec4

File indexes:
  0 - tiled_custom_mipmap.frag.glsl

WARNING:Failed to attach shader tiled_custom_mipmap.frag.glsl to program
tiled_mipmap_subsequent.

Linking GLSL program tiled_mipmap_subsequent ...

 

Edited by MirceaKitsune
Link to comment
Share on other sites

Yes, the shader does not compile:

    uniform usampler2D u_sourceTexture;
    vec4 sample(ivec2 pixelCoords) {
        // fetch from base LOD level
        return texelFetch(u_sourceTexture, clampPixelCoords(pixelCoords), 0);
    }

Since texture is usampler2D, texelFetch returns uvec4, i.e. vector unsigned, while the function should return vec4, i.e. vector of floats.

However, according to official docs , it should work:

Quote

Certain values can be implicitly converted to certain types. This means that an explicit construction operation is not necessary.

Signed integers can be implicitly converted to unsigned integers, but the reverse is not true. Either integer type can be converted into floats, and integers and floats can be converted into doubles.

Vector and matrix values are implicitly converted if the basic type they contain is implicitly convertible.

So it looks like an issue in the driver.

Try to put the attached file into glprogs directory in TDM root.
It will override the file you have in pk4 archive.

I added an explicit cast to vec4 there.

 

tiled_custom_mipmap.frag.glsl

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

20 minutes ago, stgatilov said:

Yes, the shader does not compile:

    uniform usampler2D u_sourceTexture;
    vec4 sample(ivec2 pixelCoords) {
        // fetch from base LOD level
        return texelFetch(u_sourceTexture, clampPixelCoords(pixelCoords), 0);
    }

Since texture is usampler2D, texelFetch returns uvec4, i.e. vector unsigned, while the function should return vec4, i.e. vector of floats.

However, according to official docs , it should work:

So it looks like an issue in the driver.

Try to put the attached file into glprogs directory in TDM root.
It will override the file you have in pk4 archive.

I added an explicit cast to vec4 there.

 

tiled_custom_mipmap.frag.glsl 4.77 kB · 0 downloads

Wonderful, that seems to be working: I can now switch to stencil shadows with r_softShadowsMipmaps and see them just fine. If that doesn't break anything on other platforms it's good on my end.

  • Thanks 1
Link to comment
Share on other sites

11 hours ago, SeriousToni said:

Im always confused which one is better. Stencil or mapped shadows. I can't even tell which I chose right now in the game. Could this be renamed for 2.11 to just shadow quality high and low maybe? :D

IMO that is not a good idea, stencil shadows and shadow maps, are two totally different things, technically and visually, putting them both under a single shadow quality option, IMO is not correct and may lead to way more confusion by mission makers.

Spoiler

Stencil shadows and shadow maps, have visual diferences and IMO you cannot say one, is higher quality than the other, depends on preference and implementation.

Stencil shadows look very sharp (if you disable soft shadows), no matter the quality level, maps can look very pixelated if you use lower shadow map sizes.

Stencil shadows is extruded geometry (triangle mesh's).

Shadow maps is textures simulating shadows (there its perfect support for alpha mapped materials). 

The only reason some may think, stencil and maps are the same, is because afaik, in TDM the team is forced to limit shadow maps to what stencil shadows can do. What I mean by this is, for example, transparent textures, grass, tree branches and other stuff using alpha maps, shadow maps support those perfectly, stencil shadows don't, so because TDM started historically with stencil shadows alone, afaik no "perforated" materials (alpha mapped materials) in TDM cast shadows.

This is a historical limitation and one that TDM may never be able to change, because has the potencial to break shadows on many older missions, also saves performance...

 

  • Thanks 1
Link to comment
Share on other sites

Right, that's another limitation: Stencil shadows can't produce shadows from alpha textures, alongside shadows not softening with length. So if you want maximum quality and realism you need maps, stencil may be faster in some cases though.

Speaking of shadow maps: Is there a reason why "r_shadowMapSinglePass" and "r_shadowMapCullFront" aren't defaulted to 1? I almost lost them from my config and when I turned them on I noticed a significant performance boost, at least +10 FPS.

Link to comment
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.

  • Recent Status Updates

    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
    • The Black Arrow

      Hope everyone has the blessing of undying motivation for "The Dark Mod 15th Anniversary Contest". Can't wait to see the many magnificent missions you all may have planned. Good luck, with an Ace!
      · 0 replies
×
×
  • Create New...