Object shadows with ARKit

I’ve been able to successfully compile and run the “ARSample” project from the Unreal Engine Github repository. I’m using the full production release of UE 4.17. I noticed that the 3D objects in the demo don’t cast shadows onto the “real” environment image. Yet, I’ve seen other AR demos (in other engines and even in Unreal using Ádám Horváth’s “AR Toolkit plugin”) cast convincing shadows. My question is, how might I go about implementing shadows in the context of ARKit?

I found a solution! A directional light can be set to “Cast modulated shadows”. One unique thing about modulated shadows is that they will show up even on surfaces that have unlit materials applied. And since unlit materials are how the ARKit camera feed is displayed in the scene, you can cast shadows onto that camera feed.

For full details on the basics of using ARKit - including a demonstration of how to get shadowing and global illumination effects - see this video tutorial I’ve posted: Getting Started With ARKit In Unreal Engine 4 - YouTube

Thanks for sharing!

Krxtopher, I tried this but I get no shadows on unlit materials (android or ios). (Yes mobilehdr was enabled as well as modulated shadows).

Nevermind. Modulated shadows work. The problem was my directional light wasn’t stationary.

Hi! Did you were able to do the shadows using 4.18?

I haven’t been able to get it working in 4.18 at all - tried the method outlined in Krxtopher’s video but the material no longer seems to be included in 4.18 (due to change in implementation).

Also tried the YCbCrToRGB material posted here, to no avail (I get a translucent white ground plane with no shadows cast on it at all): ARKit 4.18 preview 1 - official IOS 11 and XCode 9 - camera feed red? - Mobile Development - Unreal Engine Forums

Anyone have any hints?

I use the method from this forum-thread. But I’ve not tested it in a mobile setting yet: Shadow catcher, possible ? Oo - Rendering - Unreal Engine Forums

Thanks Seba - I’ll take a look at it today and report back!

Any luck with any of it? I’d love to be able to get dynamic shadows working with unreal and ARKit.

I have gotten my original modulated shadows solution to work on 4.18 but it requires a slightly different approach to the camera pass-through material creation. I plan to post an updated video tutorial in the next couple weeks.

Really looking forward to it! :smiley:

Try adding ARKitCameraMaterial_Mesh to a floor mesh and setup modulated shadows as Krxtopher mentioned above, then everything should work.

[link text][2]

Is that working in 4.18.3?

I believe haowang is referring to a material called “ARKitCameraMaterial”. In order to find that material, you just need to change the view settings of the content browser to enable “Show Plugin Content”. Then you’ll find that material under thet “AppleARKit Content” folder. I haven’t tried this myself, but I did confirm that this material exists in 4.18.2.

Yes, this is done in 4.18

The zip file I uploaded contains a modified version of that material, basically just use the screen coordinate as the UV. It needs further tweaking as on devices not running a 16:9 aspect ratio, not the entire camera texture is used, so the UV space needs to be clipped, similar to how the engine does it in the arkit overlay code - although I still think the implementation in 4.18.3 is buggy because it doesn’t handle all the devices and orientations correctly.

Hi all,

I’ve got Modulated Shadows set up for my AR scene and they work but they are very black, is there anything I can do about this?

If you’re using the modulated shadow approach, the shadow color can be tweaked on the light itself.

I was wondering if you have found a solution to this. I’ve been trying to translate the UV clipping done in the overlay code but I’m still getting stretched images. This is with 4.19.

EDIT: I got it to work, at least on landscape on anPro. See my answer here ARKit Passthrough Camera material scaled differently than blank space - XR Development - Epic Developer Community Forums