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”)))

3 Likes

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

1 Like

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)

5.4.3_Shaders.zip (2.7 MB)
You can use the above shader patch if you need instanced stereo in forward rendering or mobile multi view and do not need the VSM deferred rendering fix. If your on deferred with Virtual Shadow maps please do not use these shaders as they will create an artifact regression. I’ve also updated the github with the branch containing the fix. Comparing CL-33421853-Copy…5.4-Point-Light-Fix · uno1982/Shaders (github.com)

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

2 Likes

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

Thanks :slight_smile:

Still broken in 5.4.3. If you change the lights to movable, the shadow bug in one eye comes back.

I’ve provided a fix above if your using forward rendering and understand how to copy a folder over your existing. Also take note on how to restore default shaders just in case you want to revert.

Cheers,

Just blown away on how difficult to have simple movable shadow on a built package is…

This is just overwhelming and non sense

I have the downloaded the Movement sample

GitHub - oculus-samples/Unreal-Movement: Body, Eye and Face Tracking code sample.

and it has movable shadows.

I have copied all the .ini settings and everything else to my project, but shadows only work in the “movement” maps

I just give up

Thanks @Uno1982 for posting such detailed tutorial and for the files! …still too difficult

1 Like

Still having this issue on Unreal 5.4.3, Very disappointed to see how little care there has been for this game breaking issue

Edit: Having this issue when using Unreal’s Lights or UDS (Ultra Dynamic Sky)

Yeah it’s a bit complex because unreal is a bit complex. It has 2 rendering pipelines and also within those pipelines additional shaders for instanced stereo and mobile multi-view which sometimes get jumbled up with the local path (android preview mode) which is yet another emulated shader path.

You now have Virtual Shadow Maps in Deferred as well as “Shadow Maps” or Cascade shadow maps (which nobody really test because VSM is now default) and also forward rendering isn’t used for anything other than mobile and VR (Quest) development so even there it just usually gets stomped over by shader code that works against deferred rendering.

If the bugs weren’t present then you also have to deal with configuration and device profiler.
The shadow issues your seeing could be due to android scalability settings as well as profile issues for the Quest 2/3 which I’ve tried to outline here.

I’m sorry your going through this but I hope you’ll manage to overcome them :slight_smile:

1 Like