Shaders appearing black on Metal devices (4.13 preview 1)

In 4.13 preview 1, most of the shaders in my project appear randomly black on iPhone 6S Plus. This worked fine on 4.11 and earlier, on all devices.

The ones that show black are different each startup (one time the fences will display normally but rocks are black, then next launch they will be black but rocks will display normally).

Everything appears normal on iPad 3 and iPhone 4S - so I’m guessing this is metal-device-specific but I haven’t been able to test this on another metal device yet.

Things I have tried:

  • Deleting all intermediate & saved
    data + DirectDataCache (both 4.13 and
    common DDC)
  • Unchecking the “Use
    forward rendering on Metal” checkbox
  • Resaving all maps

The project is blueprint-only. All shaders are unlit (and HDR is turned off).

I’ll attempt to reproduce this in a blank map/project next but if you can think of any other things to check, please let me know (happy to provide my project for debugging, regardless - it’s small and blueprint-only).

First two shots show the problem (same build launched twice for different results), and third is how it looks on iPad 3.

I thought maybe it was corrupt map files but spawned objects also have the problem (the plants, in the screenshots).

Any other places that cached data could be hiding, aside from these places? (which I’ve tried deleting):

  • Project\Intermediate
  • Project\Saved
  • %USERPROFILE%\AppData\Local\UnrealEngine

I also tried r.invalidatecachedshaders.

I had a quick go at trying to reproduce in a fresh 4.13 install / project but all I managed to do was create a crash.

Unfortunately I upgraded to Preview 2 to see if the problem was fixed, but preview 2 is unable to even launch on iOS (and I can’t get preview 1 any more to continue testing fixes this bug). One further thing I’d like to try when I can is rolling back Common.usf, as there seems to be a lot of metal-related changes in there between 4.11/4.13.

OK so it turns out it was happening on 4.12.5 as well (same as 4.13 - different objects would be black each time I restarted the app on the device, sometimes none were) - I ended up nuking everything from my machine, that is:

  • Project\Intermediate & Project\Saved
  • The installed engine itself
  • %USERPROFILE%\AppData\Local\UnrealEngine
  • C:\ProgramData\Epic ← this is the only one I hadn’t tried before

Re-downloaded 4.12.5, did a full cook and so far it seems to be OK. So it seems like the stuff in ProgramData was the most likely cause.

Haven’t tried 4.13 again but am a little jaded from the whole process now so I might skip it!

OK, turns out my previous answer was not the solution. I ended up having to upgrade to 4.13 for various reasons, so I had to figure this out properly - deleting all the cached/intermediate data etc mentioned in my other answer didn’t fix the problem on 4.13.

After changing various project settings, force-recompiling blueprints and making materials a constant color only, it turns out it was this project setting: “Game discards unused material quality levels”, under Rendering

105798-discardmaterialquality.png

If I uncheck that, the materials are no longer black… if I turn it back on, they go black again (even if the materials in question no longer have a Quality Switch hooked up). For some reason this causes problems on Metal devices only in 4.13 (I’m not doing any runtime switching of quality levels, so no idea why).