Page 31 of 32

Re: Shadows

Posted: 07 Mar 2019, 18:15
by 4544fa8d
Hello AnyOldName3,

I'm currently trying to finish this task https://gitlab.com/OpenMW/openmw/issues/4858, and now I see that there is a problem on horizon.
I have shadow tab in settings window:
Spoiler: Show
I don't really know much about computer graphics, so I have some questions:
1. Is it possible for shadow settings to be changed without need of restarting game? I just discovered that there is no something like "applyShadowSettingsAndKeepPlaying()" method, but is it even possible to do it in future?
2. If task of dynamically reloading shadow settings is possible to implement, can I add 1 method to shadow.cpp in hope that all "TODO" in it will be implemented someday? This method looks like this https://github.com/4544fa8d/openmw/blob ... ow.cpp#L16
3. There are 2 settings: "number of shadow maps" and "shadow map resolution". What minimum and maximum values they can be set to?

Re: Shadows

Posted: 07 Mar 2019, 19:21
by AnyOldName3
You really should have started by asking questions before jumping right in. You can find documentation on the settings here https://openmw.readthedocs.io/en/master ... adows.html and it includes the ranges. For some settings, they'll be updateable at runtime already, and for others, they aren't. The ones I've added should be handled gracefully, but some of the OSG built-ins aren't.

ShadowManager::setupShadowSettings() should apply the settings in the settings manager to the shadow system, but not all shadow settings are there. Some need setting from the rendering manager (e.g. the rendering manager needs to ask the shadow manager for the new shadow defines and give them to the shader manager) and some are fields of the shadow manager that right now, get set by the rendering manager when constructing the shadow manager, but could also be changed by adding setter methods to the shadow manager.

Re: Shadows

Posted: 17 Mar 2019, 00:17
by Cammera
I realize this may be a thing already or difficult to implement, but is there any possibility of being able to control the FPS of shadows, particularly terrain/object shadows?
Actors move constantly, but in a lot of cases the lightsources of objects (The sun, for example) won't move fast enough for say, 10 FPS to make a noticeable impact in visual quality. Hell, sun shadows could as well move at 5 or even 1 FPS, and then it would make very little impact on performance.

Re: Shadows

Posted: 17 Mar 2019, 10:45
by Chris
Cammera wrote: 17 Mar 2019, 00:17 I realize this may be a thing already or difficult to implement, but is there any possibility of being able to control the FPS of shadows, particularly terrain/object shadows?
Actors move constantly, but in a lot of cases the lightsources of objects (The sun, for example) won't move fast enough for say, 10 FPS to make a noticeable impact in visual quality. Hell, sun shadows could as well move at 5 or even 1 FPS, and then it would make very little impact on performance.
It doesn't really work that way. Because actors are moving, the shadows have to be re-rendered to account for the objects' new positions regardless of the sun's position being the same or not. If shadows updated 10, 5, or 1 FPS, the actor shadows would appear jittery and laggy.

At best, it could render non-moving geometry shadows into a buffer that updates less frequently, and render only the moving objects into a separate buffer that updates every frame, which is then composited. But that could end up being more costly given it's double the amount of buffers with the need to combine them. It may also be difficult to determine which objects are not likely to change often.

Re: Shadows

Posted: 19 Mar 2019, 10:31
by wareya
So, uh, the fact that the effective shadow map resolution right next to/under the player character can change so much with the camera angle is kind of a horrible serious problem. At the absolute minimum the default settings should get changed so it's less obvious.

Re: Shadows

Posted: 27 Mar 2019, 01:27
by Sagacity
Chris wrote: 17 Mar 2019, 10:45 At best, it could render non-moving geometry shadows into a buffer that updates less frequently, and render only the moving objects into a separate buffer that updates every frame, which is then composited. But that could end up being more costly given it's double the amount of buffers with the need to combine them. It may also be difficult to determine which objects are not likely to change often.
The further issue is that such an implementation generates constant and frequent performance spikes, which is far less pleasant than just having a lower overall performance. Also; what usually determines the performance of shadows is the number of lights casting shadows, and the resolution of the shadow map, not the number of shadow casters. Though they do contribute, it's far far less.

Re: Shadows

Posted: 27 Mar 2019, 20:23
by AnyOldName3
We only have one shadow-casting light, so that's not a performance thing that needs worrying about. Also, from my testing, any decently performing modern-ish GPU shows a very small performance hit from increasing shadow map resolution. However, as Morrowind uses lots and lots of absolutely tiny drawables (e.g. loads of things with around 12 triangles), there's a significant amount of time spent on lots and lots of draw calls. The GPU spends a lot of time waiting to be told what to do, and the CPU is sending new commands as quickly as it can, and adding more drawables has a big performance hit.

We're planning some kind of batching system so that there are more big drawables and fewer hordes of tiny ones, which should make things faster, and there might be other potential optimisation opportunities, like using a geometry shader so that each object can be drawn into all shadow cascades from just one draw call (although this specific example would require some fanangaling to get working, as there's not a tidy way of getting it working immediately without sacrificing other features, and it's not going to work on all the hardware OpenMW supports, as not everything supports geometry shaders).

Re: Shadows

Posted: 28 Mar 2019, 00:47
by wareya
wareya wrote: 19 Mar 2019, 10:31 So, uh, the fact that the effective shadow map resolution right next to/under the player character can change so much with the camera angle is kind of a horrible serious problem. At the absolute minimum the default settings should get changed so it's less obvious.
Posting these to emphasize how horrible and serious of a problem this is. It pretty much makes using shadows with a high view distance (for distant terrain) a negative thing instead of a positive thing.

resolution 4096, tight scene bounds enabled, split point uniform logarithmic ratio 0.5:
https://streamable.com/yetop

resolution 1024, tight scene bounds enabled, split point uniform logarithmic ratio 1
https://streamable.com/0yhz4

At the bare minimum the defaults should be changed to values that hide whatever the shadow map sizing/placement system is doing.

EDIT: With the debugging things enabled:

https://streamable.com/stzey (4096, 0.5)

https://streamable.com/csvhl (1024, 1)

Re: Shadows

Posted: 30 Jun 2019, 14:29
by claudekennilol
I installed the latest nightly and am trying to get shadows working and can't figure out what I'm missing. I copied all of the shadow settings from settings-default.cfg to settings.cfg found in MyGames/OpenMW to settings.cfg in the openmw folder and set enable shadows to true.

Latest nightly installed from this link viewtopic.php?f=20&t=1808 the 2019-6-30 build. I have no mods installed. Even though I've been following OpenMW for literal years, this is the first time I've ever installed it and booted it up, so I'm definitely thinking I just missed something. If someone could fill me in on what I missed it'd be greatly appreciated.

Re: Shadows

Posted: 30 Jun 2019, 14:32
by AnyOldName3
Just enable shadows, or other settings like object shadows?