Flat Materials

Flat materials don't respond to lighting and display color and texture values absolutely.

You might use this material if there's lighting and shadow present in your texture file already or if you're creating a material for a 2D object.

When you create a material for a 2D object, a flat material will be created by default.

It's a good idea to use flat materials where you can, because they're more performant than the standard material.

Learn about:

Creating a flat material

To create a flat material:

  • Select a material in the Assets panel.
  • Set the Shader Type to Flat in the Inspector.

You'll see a flat white material covering your object:

Adding colors and textures

Add colors and textures under Diffuse in the Inspector:

  1. Click the box next to Color to choose a color from the palette.
  2. Click the dropdown next to Texture to add a texture.

Below, we've added a texture underneath the Diffuse property. The texture itself has some subtle shading, giving a sense of depth:

You can also add an environment texture by checking the box under Environment, and choosing one of the options from the menu. This will add a realistic lighting effect to your material.

Editing opacity

Like all materials in Spark AR Studio, there are a selection of render options for the flat material.

Below, we've created a rectangle and set the Size to Fill Width and Fill Height. This makes the rectangle the same size as its parent, the canvas. The Mode of the canvas is set to Screen Space, so its size will always match the screen of the device.

We've created a flat material for the rectangle, and adjusted its Opacity. As a result, there's a transparent colored vignette across the scene. You could combine this technique with segmentation, to add different colors to the foreground and background.

Flat material - properties

Diffuse

Edit the Color option to add a color from the palette to your material.

Click the dropdown next to Texture to choose the texture file you want to add from the menu, or import a new one.

Environment

Check this box to add an environment texture to your material. Choose a texture from the dropdown menu.

Alpha

Use this option to mask the alpha channel. Use Invert to switch which part of the texture is masked.

Render Options

Blend Mode

Sets the blend mode of the material.

  • Add
  • Alpha
  • Subtract
  • Multiply
  • Replace
  • Screen

Cull Mode

Back - Discard pieces of the mesh that are facing away from the viewer. Most effects use this mode to improve performance.

Front - Discard pieces of the mesh that are facing the viewer.

Opacity

Sets the transparency of the material on an individual map level.

Double-sided

Displays both sides of a face normal.

Advanced Render Options

Use the Write to Depth Buffer and Use Depth Test checkboxes to control certain order parameters for the object the material is applied to.

Both boxes checked

Enable read and write depth buffer. This means that closer objects will obscure far objects.

Write to Depth Buffer box checked

Disable read depth and enable write depth. These objects will always draw over any other object. They will obscure father objects that are drawn after unless these objects have either the Write to Depth Buffer or both boxes checked.

Use Depth Test checked

Enable read depth and disable write depth. These objects will be obscured by nearer objects that have already been drawn that have either the Write to Depth Buffer or both boxes checked.

These objects can be obscured by any objects drawn afterwards, whether they’re nearer or further away.

Uncheck both boxes

Disable read and write depth. These draw on top of any objects of any type already drawn, and in turn will be overdrawn by any later rendered objects, regardless of whether they are nearer or further away.

Used By

Check which object this material is applied to.