05. AR Reflection and Shadow
This section describes how to create planar reflection and shadow for objects visible in Augmented Reality, (i.e. rendered in the Foreground pass).
⚠️ This section assumes that the level is already lit with dynamic lights, objects are in the Foreground pass and casting shadows.
The objects casting shadows should be set as Stationary or Movable.
For more information about lighting in Unreal Engine, please refer to unreal documentation - Lighting Tools and Plugins:
Setup
- Create an “AR Shadows and Reflection Plane” object, its purpose is to receive the reflection and shadow. Search for “AR Shadows and Reflection Plane” and drag and drop the object in the level.
- Adjust the height (Z axis) of the “AR Shadows and Reflection Plane” in order to match the real floor’s height. The Target Displayer might be helpful to locate where the real floor is.
The following step should be done for each Cesium Camera where the effect is visible:
- Select the Cesium Camera (create one if it is not already done) and bind the ARPlane object via the Details Panel at the section Video Output Key:
This will automatically add the “AR Shadows and Reflection Plane” object to the list of Foreground objects.
📝 In order to visualize the final result, check the Cesium Camera Output in the VSAR Config panel or the Video Output.
📝 In order to pre-visualize the shadows and reflections also in the Viewport for debugging purposes, select the ProjectionMesh component from the AR Shadows and Reflection Plane, and disable the option “Visible In Scene Capture Only”. This option is enabled by default to hide the AR Shadows and Reflection Plane texture in the Viewport, since this effect is designed to work specifically from the point of view of the Cesium Camera.
Parameters
ARPlane object has the following parameters to alter the rendering.
- Enable Shadow: Enable/Disable shadow, default value is Enabled.
- Enable Reflection: Enable/Disable reflection, default value is Enabled.
- Shadow Opacity: Affects the shadow opacity, 1 is fully opaque and 0 is fully transparent, default value is 1.
- Reflection Opacity: Affects the reflection opacity, 1 is fully opaque and 0 is fully transparent, default value is 0.5.
- Reflection Blur Amount: Amount of blur applied to the reflection, default is 0.2.
- Reflection Blur Distance: Distance from the base reflection, increasing this value will result in the blurred reflection to be more spread out, default is 0.02.
- Reflection Texture Resolution: Resolution in pixels of the texture being generated into the Shadows and Reflections Plane, default is 1920 x 1080.
- Enable Clip Plane: Make the Reflection Plane act as Clip Plane that hides the reflections when the reflected objects are positioned below the plane, default is Enabled.
- Enable Plane Projection in Editor: Preview the shadows and reflections in the Viewport from Cesium Camera POV, for debugging purposes, default is Disabled.
The "Visible In Scene Capture Only" setting must be turned off in the ProjectionMesh component to visualize the change in the projection.
Troubleshooting
The shadow is not visible or disappears after building the lighting.
Verify that the following parameters are correctly set:
- The level is lit and the light is casting shadows.
- Objects casting shadows are set as Stationary or Movable.
- Shadow opacity is different from 0.
- The object is in the Foreground objects list.