# Shadows & Lighting

Add Shadows & Ligthing to Any Scene



# About this Sample

This sample showcases how to add shadows to a scene to create a more realistic environment. It also highlights various lighting settings that can significantly impact the appearance of the scene. To start working with this sample, you need to install Resight Engine.

# Follow these steps after setting up Resight Engine:

  1. Go to the 'Samples' folder / 'Shadows & Lighting' Sample folder
  2. Locate the scene named 'Shadows & Lighting' and open it

# Shadows & Lighting Scene

The AR setup is complete and features an AR Session to oversee the AR experience, as well as an AR Session Origin, which contains the Main Camera, The AR Plane Manager, and the AR Raycast Manager. The scene is also equipped with Resight Engine.

# Resight Engine Settings

  1. Go to the 'Resight' game object in the open scene
  2. Find the 'LibResight' component
  3. Enter your developer key (provided by Resight) and a namespace

    • A namespace can be any string (without spaces), for example: Default / Production / Test-1
    • A namespace is a unique data store under your developer account
    • Mapping data and snapped objects are not shared between different namespaces

# Lighting

  1. Find the Directional Light object in the Hierarchy.

  2. Light settings:

     - Change intensity to 0.35
     - Change Bias to 0.02
     - Change Normal Bias to 0.02
     - Change Near Plane to 0.2
    

# Shadows

  1. Go to Edit / Project Settings -> "Quality" tab

  2. Select the quality level for the iOS build (the line that has a green checkmark under the iOS column)

    - Shadow Resolution: Medium or High
    - Shadow Projection: Close Fit
    - Shadow Distance: 10
    - Shadow Cascades: Two Cascades
    

# Mesh Manager

  1. Go to the 'Resight' game object in the open scene
  2. Find the 'Mesh Manager' component

# Physics:

You have the option to disable the collider. This can be useful when you don't want objects to collide with the mesh. Add an occlusion manager to your scene by simply dragging the AR Camera under the AR Session Origin. This will enable the camera to recognize and occlude real-world objects, allowing virtual objects to appear more realistic and natural within the scene.

# Rendering:

Select a pre-made shader/material for your mesh. This can save you time and effort as you can choose from a range of pre-existing options rather than creating your own from scratch.

To enable shadow rendering, select "Shadows" as the desired rendering option.

  • Add your own custom shader/material.

# Game Manager

The MeshPlacement script utilizes Physics's Raycast functions to facilitate the real-world placement of objects. If desired, you have the option to personalize the scene by substituting the default objects with your own Prefabs.

  1. Find the Game Manager object in the Hierarchy
  2. Drag and drop your own Prefab to Placed Prefab:

    This scene utilizes the movement scripts to facilitate effortless manipulation and removal of objects in collaboration with our live mesh.

    The scene comes with pre-made materials, 3D models, and Prefabs that are ready for your use without any restrictions. Enjoy! 🙃