Articles
Textures and Materials
The Dynamic Environment Texture

The Dynamic Environment Texture

In Spark AR Studio, you can apply the dynamic environment texture to light an object under the same conditions as the real-world scene the virtual object is placed in. The object will be lit differently depending on how the user’s location is lit, making your effect more immersive and realistic.

You’ll combine the dynamic environment texture with a physically-based material applied to an object. The object must also be placed under either a plane or target tracker in the Scene panel.

How the dynamic environment texture works

Below, we've added the dynamic environment texture to the material applied to the flower pot object on the left. The plant looks more realistically integrated in its surroundings. The image on the right uses the default Spark AR environment texture and looks too brightly lit for the enviroment it's placed in.

Next, we'll show you how to apply the dynamic environment texture to an object.

Add an environment light and tracker

First add an environment light and a tracker to your project:

  1. In the Scene panel, click Add object.
  2. Add an environment light and a tracker, for example, a plane tracker.

Scene panel with environment light and plane tracker added

Extract the dynamic environment texture

Next, extract the dynamic environment texture from the environment light:

  1. In the Assets panel, select the environment light.
  2. In the Inspector, under Texture Extraction and to the right of Texture, click the plus sign.

Environment light selected and Texture Extraction highlighted in Inspector

Create a physically-based material and add dynamic environment texture

Next you’ll create a physically-based material to combine with the environment texture.

  1. Create a physically-based material and edit the settings in the Inspector to achieve the desired appearance for your object.
  2. With the material still selected, In the Inspector, to the right of Environment, select the box.
  3. To the right of Texture, select dynamicEnvironmentTexture0 from the dropdown.

The dynamic environment texture is now applied to the physically-based material.

Material selected in Assets panel and dynamic environment texture applied in the Inspector

Apply the material to an object

All that’s left to do is apply your material to your object.

  1. Make sure your object is under a tracker in the Scene panel.
  2. In the Scene panel, expand the object, to reveal the mesh.
  3. With the mesh selected, in the Inspector, apply the physically-based material to your object.

 Physically-based material applied to sphere object, in the Inspector

The environment texture is applied to your object but you won’t see the result in the Viewport or Simulator. This is because the dynamic environment texture uses information from the user’s device about their surroundings to light the object accordingly. To see how your object looks, you’ll need to preview your effect on your device.

Was this article helpful?