Lyall / WukongTweak

An ASI plugin for Black Myth: Wukong that features expanded ultrawide support and graphical tweaks.
MIT License
401 stars 12 forks source link

Virtual shadows look grainy #21

Open DoomPenguin9 opened 2 months ago

DoomPenguin9 commented 2 months ago

Can we have the grainy effect on virtual shadows disabled and have them look sharp and solid like in every other game?

1725152619

DoomPenguin9 commented 2 months ago

r.Shadow.Virtual.SMRT.TexelDitherScale=1

Seems to do what I want. Can an option to tweak this value be added in the next release?

1725193671

Lyall commented 2 months ago

I think the CVAR that's probably responsible for it looking so grainy is the ray count one. If you look at the default scalability settings for UE5.0, the game is actually running at low settings for VSMs. In any kind of tracing of rays, a lower count is going to result in a noisier resolve.

What the game runs at:

[ShadowQuality@Cine]
r.Shadow.Virtual.MaxPhysicalPages=1024
r.Shadow.Virtual.RadiusThreshold=0.1
r.Shadow.Virtual.DynamicRes.MaxResolutionLodBias=2
r.Shadow.Virtual.DynamicRes.MaxPagePoolAllocation=0.85
r.Shadow.Virtual.DynamicRes.VisibleCountExtraAllocation=0
r.Shadow.Virtual.ResolutionLodBiasDirectional=-1.5
r.Shadow.Virtual.ResolutionLodBiasLocal=0.0
r.Shadow.Virtual.SMRT.RayCountDirectional=6
r.Shadow.Virtual.SMRT.SamplesPerRayDirectional=1
r.Shadow.Virtual.SMRT.RayCountLocal=1
r.Shadow.Virtual.SMRT.SamplesPerRayLocal=1
r.Shadow.Virtual.SMRT.SamplesPerRayLocal=0
r.Shadow.Virtual.SMRT.DirectionalSampleColumn=1
r.Shadow.Virtual.SMRT.RayLengthScaleDirectional=3.2
r.Shadow.Virtual.SMRT.TexelDitherScale=15.5
r.Shadow.Virtual.SMRT.DitherByDistance=1
r.Shadow.Virtual.SMRT.Contrast=16
r.Shadow.Virtual.Cache.MaxMaterialPositionInvalidationRange=5000
r.Shadow.Virtual.Cache.MaxInvalidationScreenSize=0.04
r.Shadow.Virtual.Cache.MaxFrameSeperateInvalidation=-1
r.Shadow.Virtual.NonNanite.IncludeInCoarsePages=0

UE5.0 default Scalability.ini

[ShadowQuality@3] 
r.Shadow.Virtual.MaxPhysicalPages=4096
r.Shadow.Virtual.ResolutionLodBiasDirectional=-1.5
r.Shadow.Virtual.ResolutionLodBiasLocal=0.0
r.Shadow.Virtual.SMRT.RayCountDirectional=8
r.Shadow.Virtual.SMRT.SamplesPerRayDirectional=4
r.Shadow.Virtual.SMRT.RayCountLocal=8
r.Shadow.Virtual.SMRT.SamplesPerRayLocal=4
r.Shadow.Virtual.NaniteShadowLODScaleBias=0

[ShadowQuality@Cine]
r.Shadow.Virtual.MaxPhysicalPages=8192
r.Shadow.Virtual.ResolutionLodBiasDirectional=-1.5
r.Shadow.Virtual.ResolutionLodBiasLocal=0.0
r.Shadow.Virtual.SMRT.RayCountDirectional=16
r.Shadow.Virtual.SMRT.SamplesPerRayDirectional=8
r.Shadow.Virtual.SMRT.RayCountLocal=16
r.Shadow.Virtual.SMRT.SamplesPerRayLocal=8
r.Shadow.Virtual.NaniteShadowLODScaleBias=0

Edit: Ah you're right, the texel dither scale option does make a large difference. 1 appears to be the UE5.0 default so I think what would make the most sense is to apply the high setting CVARs when VSMs are enabled.

Lyall commented 2 months ago

Added the high quality CVars when enabling virtual shadowmaps in v0.8.5

VintageGenetics commented 2 months ago

Added the high quality CVars when enabling virtual shadowmaps in v0.8.5

Thanks Lyall.

With the update to version 0.8.5, if I simply set Virtual Shadow Maps enabled = true in the WukongTweaks.ini file, does this take care of all necessary adjustments for achieving less grainy shadows, or are there other modifications required?

Lyall commented 2 months ago

Added the high quality CVars when enabling virtual shadowmaps in v0.8.5

Thanks Lyall.

With the update to version 0.8.5, if I simply set Virtual Shadow Maps enabled = true in the WukongTweaks.ini file, does this take care of all necessary adjustments for achieving less grainy shadows, or are there other modifications required?

Yes! No other modifications required.

VGeorge24 commented 2 months ago

Hey Lyall,

Really appreciate your mod!

Just wanted to ask if the above fix for the grainy shadows is enabled only when the in-game shadow quality is set to cinematic, cause that's what's happening in my case. For example, changing the value of r.Shadow.Virtual.SMRT.TexelDitherScale in the console doesn't seem to affect shadows at all, unless my shadow quality is set to cinematic. Is that the intended behavior or am I doing something wrong?

DaemonVosh commented 2 months ago

Is it working as intended? I'm using v0.8.5 with just Virtual Shadow Maps enabled = true and my shadows look more like the OP's top picture.

Black Myth  Wukong Screenshot 2024 09 03 - 05 30 11 26

VGeorge24 commented 2 months ago

Is it working as intended? I'm using v0.8.5 with just Virtual Shadow Maps enabled = true and my shadows look more like the OP's top picture.

Try changing the shadow quality to cinematic, that worked for me!

DaemonVosh commented 2 months ago

Is it working as intended? I'm using v0.8.5 with just Virtual Shadow Maps enabled = true and my shadows look more like the OP's top picture.

Try changing the shadow quality to cinematic, that worked for me!

Yup just saw your post after making mine. It does seem to only work if it's set to Cinematic.

02Leu commented 2 months ago

r.Shadow.Virtual.SMRT.TexelDitherScale=1

Seems to do what I want. Can an option to tweak this value be added in the next release?

1725193671

may I ask where did you put the r.Shadow.Virtual.SMRT.TexelDitherScale=1? the new one with CVAR is very taxing for me to use

DoomPenguin9 commented 2 months ago

r.Shadow.Virtual.SMRT.TexelDitherScale=1 Seems to do what I want. Can an option to tweak this value be added in the next release? 1725193671

may I ask where did you put the r.Shadow.Virtual.SMRT.TexelDitherScale=1? the new one with CVAR is very taxing for me to use

On Windows it should be c:\users\whatever your username is\appdata\local\b1\saved\config\windows\Engine.ini

At the top of the ini file add

[SystemSettings]
r.Shadow.Virtual.SMRT.TexelDitherScale=1
DoomPenguin9 commented 2 months ago

I think the CVAR that's probably responsible for it looking so grainy is the ray count one. If you look at the default scalability settings for UE5.0, the game is actually running at low settings for VSMs. In any kind of tracing of rays, a lower count is going to result in a noisier resolve.

What the game runs at:

[ShadowQuality@Cine]
r.Shadow.Virtual.MaxPhysicalPages=1024
r.Shadow.Virtual.RadiusThreshold=0.1
r.Shadow.Virtual.DynamicRes.MaxResolutionLodBias=2
r.Shadow.Virtual.DynamicRes.MaxPagePoolAllocation=0.85
r.Shadow.Virtual.DynamicRes.VisibleCountExtraAllocation=0
r.Shadow.Virtual.ResolutionLodBiasDirectional=-1.5
r.Shadow.Virtual.ResolutionLodBiasLocal=0.0
r.Shadow.Virtual.SMRT.RayCountDirectional=6
r.Shadow.Virtual.SMRT.SamplesPerRayDirectional=1
r.Shadow.Virtual.SMRT.RayCountLocal=1
r.Shadow.Virtual.SMRT.SamplesPerRayLocal=1
r.Shadow.Virtual.SMRT.SamplesPerRayLocal=0
r.Shadow.Virtual.SMRT.DirectionalSampleColumn=1
r.Shadow.Virtual.SMRT.RayLengthScaleDirectional=3.2
r.Shadow.Virtual.SMRT.TexelDitherScale=15.5
r.Shadow.Virtual.SMRT.DitherByDistance=1
r.Shadow.Virtual.SMRT.Contrast=16
r.Shadow.Virtual.Cache.MaxMaterialPositionInvalidationRange=5000
r.Shadow.Virtual.Cache.MaxInvalidationScreenSize=0.04
r.Shadow.Virtual.Cache.MaxFrameSeperateInvalidation=-1
r.Shadow.Virtual.NonNanite.IncludeInCoarsePages=0

UE5.0 default Scalability.ini

[ShadowQuality@3] 
r.Shadow.Virtual.MaxPhysicalPages=4096
r.Shadow.Virtual.ResolutionLodBiasDirectional=-1.5
r.Shadow.Virtual.ResolutionLodBiasLocal=0.0
r.Shadow.Virtual.SMRT.RayCountDirectional=8
r.Shadow.Virtual.SMRT.SamplesPerRayDirectional=4
r.Shadow.Virtual.SMRT.RayCountLocal=8
r.Shadow.Virtual.SMRT.SamplesPerRayLocal=4
r.Shadow.Virtual.NaniteShadowLODScaleBias=0

[ShadowQuality@Cine]
r.Shadow.Virtual.MaxPhysicalPages=8192
r.Shadow.Virtual.ResolutionLodBiasDirectional=-1.5
r.Shadow.Virtual.ResolutionLodBiasLocal=0.0
r.Shadow.Virtual.SMRT.RayCountDirectional=16
r.Shadow.Virtual.SMRT.SamplesPerRayDirectional=8
r.Shadow.Virtual.SMRT.RayCountLocal=16
r.Shadow.Virtual.SMRT.SamplesPerRayLocal=8
r.Shadow.Virtual.NaniteShadowLODScaleBias=0

Edit: Ah you're right, the texel dither scale option does make a large difference. 1 appears to be the UE5.0 default so I think what would make the most sense is to apply the high setting CVARs when VSMs are enabled.

Where did you get the scalability settings for this game? I wanted to play around with ray counts but

c:\users\whatever your username is\appdata\local\b1\saved\config\windows\Scalability.ini

is empty.

DoomPenguin9 commented 2 months ago

Custom cvars seem to also not work. If I try to set r.Shadow.Virtual.SMRT.RayCountDirectional=16 nothing happens. Also, if I try to run it in the console while in game, it says it's unrecognised.

I am also unable to set r.Shadow.Virtual.SMRT.TexelDitherScale=1 on any shadow quality setting other than cinematic but the new high quality cvars you set are making my performance tank brutally on an rx 7900 XTX. Can you make them optional, please? 'r.Shadow.Virtual.SMRT.TexelDitherScale=1' was enough of an improvement on its own.

Sepherato commented 2 months ago

Hi together, hi @Lyall,

In Advance: thank you for your hard work! It is SO appreciated since it really makes the game a better experience. Kudos to that 🥇

What I wanted to ask is the following, similiar to questions "DoomPenguin9" asked/mentioned:

Now we can use the VSM, great, looking very cool. But I can't manage to get other settings working together with these shadow maps. `r.Shadow.Virtual.SMRT.TexelDitherScale = 14.5 r.Shadow.Virtual.SMRT.DitherByDistance = 1

Those parameters literally do nothing when adding to either a) the WukongTweak.ini or b) the Enginge.ini No matter if "read only" or not. When I add these parameters above in the Game Console itself, they work.

Why do I want to add those parameters above? Because the DitherScale = 1 is, while super sharp, also super unnatural, since Shadows aren't that crisp from a tree 4 meters above the Player.

Is it possible to add a kind of toggle in your WukongTweak like: "VSM enable = 1" Soft Shadows = 0, Normal Shadows = 1, Crisp Shadows = 2" Something like that. Would be easy as pie to use then.


Comparison for the parameters to judge for yourself: I also included Riva for the performance (for the relation to each factors. I have a 4080/5800x3D, don't think that's the "standard rig", so those frames are not that relevant ...) Shadow Quality has to be Cinema, by the way. Just writing it in case it isn't clear for other readers. Look at the shadows on the rocks for example, and in the distance. Wouldn't be that sharp in real life.

0 = Soft Shadows: r.Shadow.Virtual.SMRT.TexelDitherScale = 1 r.Shadow.Virtual.SMRT.DitherByDistance = 0 Soft Shadows

1 = Normal Shadows: r.Shadow.Virtual.SMRT.TexelDitherScale = 14.5 r.Shadow.Virtual.SMRT.DitherByDistance = 1 Normal Shadows

2 = Crisp Shadows (the current WukongTweak.ini): r.Shadow.Virtual.SMRT.TexelDitherScale = 1 r.Shadow.Virtual.SMRT.DitherByDistance = 1 Crisp Shadows

Looking forward to what you think of this approach 👍

Regards!

phonyprince commented 2 months ago

The default shadows settings provided by the mod achieve the best visual balance imo. Adding this insane sharpness to shadows make them look like FarCry 2 ones. That's just visually uncomfortable. I think the used engine version lacks some sort of shadows denoiser which would normally solve the "grainy" issue. Just like the vegetation pop-ins. Limitation of the older engine.