UE5.4 (and 5.4.1) shadows are broken in VR (VR Template, default settings)

Thanks for posting those things @VitLiskutin & @BreakMaker
It may not fix the problem for me, but there is some comfort in knowing I am not the only one still having these issues :wink:

When I said my current solution is to turn off shadow casting for the lights, I wasn’t making a joke;
It allows you to get on and create/test levels in VR without getting a massive headache…
in the hope that an update is coming which will remove this problem before you actually need to ship your project.

The reason why I am not holding my breath for a resolution however, is that the problem in some form or another has existed from the start of UE5.0 at least. (Because its probably a lumen thing?)

Yup, having the same Issue.
Looks like a Virtual Shadow Maps problem… the template defaults to “normal” Shadow Maps? or VSM? because I cannot change the shadow method (greyed out in project settings in the VR Template)

Shaders aren’t built by c++ they are compiled and stored in your DDC so you’ll want to delete that cache if your using source. You’ll see your ddc settings at the top right of the editor. If your on launcher your using the default DDC and your shaders should recognize they need to recompile. Keep in mind this fix works in editor when using VR preview and packaged for openxr/steamvr (pcvr) but I’ve yet to test natively on quest with Vulkan and multi view

You can’t use vsm in forward rendering as it’s a deferred rendering shadow method only. You’ll need to adjust this in your ini or swap back to deferred to adjust it … legacy shadow maps (csm) is the default mode for forward shading/rendering. Also you can disable instanced stereo and fix the shadows as a work around as well without replacing the shader I provided.

1 Like

So, I changed the DDC path in the editor settings (it was, ahem, pointing to somewhere it shouldn’t have been anyway) and then I restarted the editor…

Splash screen tells me its ‘recompiling shaders’… 9000 or so of them.
I’m getting kinda excited now, got a good feeling about it…

Shaders take a while to compile,. editor finally fires up, test level opens…
I run the VR preview, and…

Still flickering shadows, different in each eye.
:sob:
Sadness.

Bear in mind that what I changed was the local project DDC override path, just in case anyone wants to tell me that changing it wouldnt have caused the specific shaders in question to recompile?
(As mentioned, it certainly caused MANY shaders to be compiled)

So do you have instanced stereo checked? Are you testing in PIE VR Preview or is this shadow issue only happening when you actually deploy and test on the quest 3?

the shader code specifically looks like this. From this vantage it appears that the instance stereo flag or the multi_view flag can both determine the compile outcome if your in mobile shading.

This kind of feels wrong because in my mind it should be
if ((MOBILE_MULTI_VIEW && SHADING_PATH_MOBILE) || INSTANCED_STEREO)
since instanced stereo is a desktop feature and never mobile.

But anyways disabling instanced stereo clears the issue even before the shader patch or at least it did for me. I’m just wondering if you have mobile multiview or instanced stereo enabled.

i have the same problem as this example , the problems seems to be in the virtual shadow map— when i switch to shadow map – this weird flickering disepears

Having the same problem unfortunately. Tried all the tricks, disable instanced stereo, using unos Shaders, disablen this and that. Still weird flicker shadows only in the left eye!

Can somebody with the problems try to use the following:

r.Shadow.Virtual.OnePassProjection=0

It’s from the following thread:

1 Like

I had the same issue from 5.3 to 5.4.2

r.Shadow.Virtual.OnePassProjection=0 … WORKS!!!

Fully tested on shipped exe
You can keep Virtual Shadow Maps

Thank you!

One note after testing it. It comes probably with a high performance cost. If you want to see it use stat gpu and turn the shadow setting on/off.

Below are the files you’ll need DefaultDeviceProfiles.ini in your config and AndroidScalability.ini in config/android inside of your Project/config folder

DefaultDeviceProfiles.ini (1.1 KB)
AndroidScalability.ini (819 Bytes)

Shaders:
Shaders.zip (2.7 MB)

Shader unzipped contents should be placed here.

IMPORTANT:
Mobile Multi should only be enabled for mobile builds
Instanced Stereo shouldn’t be enabled for mobile builds and should only be enabled on desktop builds
these flags appear to negatively impact quest2/3 standalone if both enabled.

Update on Detecting the Quest 3 properly: (thanks! @Starkium )
To fix the problem, you need to add a MatchProfile in your BaseDeviceProfiles.ini located in (Your Engine Loc)\Engine\Config.

  1. Open BaseDeviceProfiles.ini.
  2. Find the existing MatchProfile for Meta_Quest_3.
  3. After the existing entry, paste the following:

+MatchProfile=(Profile=“Meta_Quest_3”,Match=((SourceType=SRC_DeviceMake,CompareType=CMP_Equal,MatchString=“Oculus”), (SourceType=SRC_GPUFamily,CompareType=CMP_Equal,MatchString=“Adreno ™ 740”)))

2 Likes

This issue was fixed in 5.4.3 which is now available in the Launcher

Return to default Shader Instructions:
For all who applied the custom shaders.zip to your launcher install and wish to return to defaults.
Delete your shaders folder and verify your files to re-install the 5.4.3 hotfix shaders
you can use the recalculate shaders all command just to be sure and also clear your deriveddatacache in your project folder and also in AppData\Local\UnrealEngine\Common\DerivedDataCache

UE5.4.3 Vanilla Launcher:
However @VictorLerp I’m having issues after updating to UE5.4.3 with instanced stereo. Are you sure the issue is actually resolved?

I actually pulled the CL that was listed as the fix and copied UE5.4.3 shaders into a repo to do a branch comparison and it “feels” like it just didn’t make it into UE5.4.3 as there are tons of diffs and missing conditionals.
Comparing main…CL-33421853-Copy · uno1982/Shaders (github.com)

I’ve completely uninstalled UE5.4.3, deleted my DDC and re-installed from scratch and below are my findings. I’ve yet to test mobile yet but once I do I’ll also update the below with those findings for mobile multi view on vs off.

Forward Rendering + instanced stereo (shadows broken in left eye)
Forward Rendering - instanced stereo (shadows working normally)
Forward Rendering can only use CSM

Deferred Rendering (VSM) + instanced stereo (shadows working normally)
Deferred Rendering (VSM) - instanced stereo (shadows working normally)
Deferred Rendering (CSM) + instanced stereo (Shadows broken in left eye)
Deferred Rendering (CSM) - instanced stereo (Shadows working normally)

Summary:
VSM seems to have been fixed while CSM remains broken in the left eye if instanced stereo is enabled.

If you need dynamic shadows working in UE5.4.3 for CSM (Shadow Maps) or forward rendering the Shaders.zip I provided for UE5.4.2 still work. If you rather not manually patch just disable instanced stereo until the next hotfix or release.

I don’t think so bud… I’ve outlined details above.

Thanks :slight_smile: