# Automating Shader Setup

Using Blender, you can automate the import of certain texture maps and most shader settings by saving them directly into the FBX file. This setup works on a per-material-slot basis.

After the initial setup, this can significantly reduce import time, especially if you plan to upload the asset multiple times, places or if it requires a lot of configuration.

This is completely optional. All materials and settings can still be adjusted manually when importing or editing the asset in-game.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-6e8539517f9851ed8b2173369c4418ff4fed00b9%2Fmatpropsettinginfo.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

## Import Texture Maps Guide

Some PBR texture maps can be automatically imported if they are set up correctly in Blender. Currently, only a limited number of maps support auto-import; any others must be assigned manually during the import process.

### Supported Auto-Import Maps

The following texture maps can be automatically imported:

* Albedo
* Normal
* Roughness
* Metalness
* Emissive Map

### How Auto-Import Works

To enable auto-import, connect your texture files to the correct inputs on the **Principled BSDF** shader in Blender. When the material is imported, Sansar will automatically assign these textures to their corresponding map slots, if they are supported by the shader.

You can use the **Node Wrangler** Blender add-on to set this up automatically when proper texture naming is used. Alternatively, you can connect the textures manually by following this guide.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-6255daf48ac3d88f110e801d966f7e25c5fdcf05%2Fmatblendernodesetup.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

1. In blender, make sure you have at least one material slot assigned to your model, additional materials will need setting up also in the same way. Click on the Shading tab at the top (you can open additional windows)

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-da73123a34c1270049b9f8226ebcedc9b68b013a%2Fmatsetup1.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

2. In the Shading window, you will need a principled BSDF, this should be added by default but if not you can add one.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-5325d806ff74845c9ea328ad7c69c46e59a76b70%2Fmatblendernodesetup1.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

3. In the shader node window add a `Image Texture` node for each map and a `Normal Map` node.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-47a58ffe2b1a1d10340aaff98a8c1a62ed1c5758%2Fmatblendernodesetup2.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

4. With your nodes added, now add your maps to each node, naming doesn't matter as it uses the BSDF connection to determine the maps use.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-f4a718434cf60bc5c0d10ff882d19cef6828ca3d%2Fmatblendernodesetup3.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

5. Once your maps are added, connect the nodes to the BSDF by clicking and dragging the sockets to each slot, make sure to include the `Normal Map` node.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-e4681568b65bfdfe28e9b5655947a38081b1795b%2Fmatblendernodesetup4.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

6. When you export your model, the texture file paths will be embedded into the FBX so Sansar can locate and import them automatically.

Your texture maps must be saved somewhere on your computer. During export, choose one of the following options:

* **Match** – Use this if the textures are already saved in the correct location.
* **Copy** – Use this if the textures are packed inside the Blender file and need to be extracted during export.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-6bc0c704a59c519bd4f935de1920cdbb99e92a17%2Fmatblendernodesetup5.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

## Import Settings Guide

### Assigning The Shader

This section covers assigning the selected shader associated with the material slot.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-4cc3a4799ea682199743df58b8f96ec0756ed29e%2Fmatshaderprop1.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

1. In Blender, open the material Properties Panel

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-4ba3ac98072f001606f9d0bfedf0e1621a9b0c31%2Fmatprop1.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

2. Choose the material slot you want to set up. Each slot is configured individually, so you’ll need to set up each one you want to control. Any options you leave unchanged will fall back to Sansar’s defaults, and can still be modified during import.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-f6bb696083116f4a8579164d3001ec3125e3f370%2Fmatprop2.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

3. In the **Custom Properties** Tab of the material select **New** and then open the **Edit Property** panel by pressing the cog icon.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-5beb52106b16281a14db8790655084d0d27e6217%2Fmatprop3.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

4. Change the type to **String** and change the Property name to be **Sansar\_MaterialType** then click OK make sure to include the capitals.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-50163c77ea97d536d9aaf0dda3b98fd616c80bb5%2Fmatprop4.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

5. Now enter the **System Name** (not the **Display Name**) of the shader you want to assign to this material slot. This should be typed into the input field on the main Properties panel, not in the previous setup window.

If you try to input an unrecognized name or a **Display Name** the import will fail with a error.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-56e3a24ceb2ebdd27a02802d69fd9cfddca25911%2Fmatshaderproperror.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

Example input: **OpaqueSingleLayer** for the **Standard** Shader.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-eb878d3b89f12e8f6f23b9f739d46f1d6837617e%2Fmatprop5.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

The following is a list of the shader's **Display Name** and its **System Name**.

<details>

<summary>Click to reveal Shader names</summary>

Property Name: **Sansar\_MaterialType**

| Display Name                                                | System Name                                           |
| ----------------------------------------------------------- | ----------------------------------------------------- |
| Standard                                                    | OpaqueSingleLayer                                     |
| Standard + Environment                                      | OpaqueEnvironmentSingleLayer                          |
| Standard Two Sided                                          | TwoSidedOpaqueSingleLayer                             |
| Standard + Alpha Mask                                       | OpaqueMaskSingleLayer                                 |
| Standard + Environment + Alpha Mask                         | OpaqueEnvironmentMaskSingleLayer                      |
| Standard Two Sided + Alpha Mask                             | TwoSidedOpaqueMaskSingleLayer                         |
| Standard + Emissive                                         | OpaqueEmissiveSingleLayer                             |
| Standard Two Sided + Emissive                               | TwoSidedOpaqueEmissiveSingleLayer                     |
| Billboard                                                   | Billboard                                             |
| Standard + Detail                                           | OpaqueSingleLayerDetail                               |
| Standard Two Sided + Detail                                 | TwoSidedOpaqueSingleLayerDetail                       |
| Standard + Detail + Alpha Mask                              | OpaqueMaskSingleLayerDetail                           |
| Standard Two Sided + Detail + Alpha Mask                    | TwoSidedOpaqueMaskSingleLayerDetail                   |
| Subsurface + Detail                                         | OpaqueSubsurfaceSingleLayerDetail                     |
| Subsurface + Detail + Alpha Mask                            | OpaqueMaskSubsurfaceSingleLayerDetail                 |
| Standard + Detail + Emissive                                | OpaqueEmissiveSingleLayerDetail                       |
| Standard Two Sided + Detail + Emissive                      | TwoSidedOpaqueEmissiveSingleLayerDetail               |
| Four Layer Non-Specular                                     | OpaqueDiffuseMultiLayer                               |
| Standard Three Layer + Detail                               | OpaqueTripleLayerDetail                               |
| Emissive + UV Animation                                     | Emissive                                              |
| Emissive Two Sided + UV Animation                           | TwoSidedEmissive                                      |
| Transmissive + Emissive                                     | TransmissiveEmissive                                  |
| Standard + Emissive + Stereographic                         | StereographicOpaqueEmissiveSingleLayer                |
| Standard + UV Animation                                     | ScrollingOpaqueSingleLayer                            |
| Standard Two Sided + UV Animation                           | TwoSidedScrollingOpaqueSingleLayer                    |
| Standard + Emissive + UV Animation                          | ScrollingOpaqueEmissiveSingleLayer                    |
| Standard Two Sided + Emissive + UV Animation                | TwoSidedScrollingOpaqueEmissiveSingleLayer            |
| Standard + Alpha Mask + UV Animation                        | ScrollingOpaqueMaskSingleLayer                        |
| Standard Two Sided + Alpha Mask + UV Animation              | TwoSidedScrollingOpaqueMaskSingleLayer                |
| Index: Standard + UV Animation                              | IndexScrollingOpaqueSingleLayer                       |
| Index: Standard Two Sided + UV Animation                    | TwoSidedIndexScrollingOpaqueSingleLayer               |
| Media: Media Surface                                        | VideoScreen                                           |
| Media: Media Surface + Stereographic                        | StereographicVideoScreen                              |
| Media: Media Surface + ChromaKey                            | ChromaKeyVideoScreen                                  |
| Media: Displacement Media + UV Animation                    | MediaScrollingOpaqueEmissiveSingleLayer               |
| Media: Two Sided Displacement Media + UV Animation          | TwoSidedMediaScrollingOpaqueEmissiveSingleLayer       |
| Transparent                                                 | Transparent                                           |
| Transparent + Multibump                                     | TransparentMultibump                                  |
| Diffractive: Transparent + Multibump                        | TransparentMultibumpDiffract                          |
| Diffractive: Transparent + Multibump + Environment          | TransparentMultibumpEnvironmentDiffract               |
| Diffractive: Standard + Alpha Mask                          | OpaqueDiffractionMaskSingleLayer                      |
| Diffractive: Standard Two Sided + Alpha Mask                | TwoSidedOpaqueDiffractionMaskSingleLayer              |
| Diffractive: Standard + Alpha Mask + UV Animation           | ScrollingOpaqueDiffractionMaskSingleLayer             |
| Diffractive: Standard Two Sided + Alpha Mask + UV Animation | TwoSidedScrollingOpaqueDiffractionMaskSingleLayer     |
| Fresnel: Standard + Emissive                                | OpaqueEmissiveFresnelSingleLayer                      |
| Fresnel: Standard Two Sided + Emissive                      | TwoSidedOpaqueEmissiveFresnelSingleLayer              |
| Pixelize: Billboard                                         | BillboardPixelize                                     |
| Pixelize: Billboard + Alpha Mask + UV Animation             | ScrollingOpaqueMaskPixelSingleLayer                   |
| Pixelize: Standard + Emissive                               | OpaqueEmissivePixelizeSingleLayer                     |
| Pixelize: Standard Two Sided + Emissive                     | TwoSidedOpaqueEmissivePixelizeSingleLayer             |
| Pixelize: Standard + Alpha Mask                             | OpaquePixelizeMaskSingleLayer                         |
| Pixelize: Standard Two Sided + Alpha Mask                   | TwoSidedOpaquePixelizeMaskSingleLayer                 |
| Pixelize: Standard + Emissive + UV Animation                | ScrollingOpaqueEmissivePixelizeSingleLayer            |
| Pixelize: Standard Two Sided + Emissive + UV Animation      | TwoSidedScrollingOpaqueEmissivePixelizeSingleLayer    |
| Screenspace: Standard + Emissive                            | ScreenspaceOpaqueEmissiveSingleLayer                  |
| Screenspace: Two Sided Standard + Emissive                  | TwoSidedScreenspaceOpaqueEmissiveSingleLayer          |
| Screenspace: Standard + Emissive + UV Animation             | ScrollingScreenspaceOpaqueEmissiveSingleLayer         |
| Screenspace: Standard Two Sided + Emissive + UV Animation   | TwoSidedScrollingScreenspaceOpaqueEmissiveSingleLayer |
| No Shadow: Standard                                         | OpaqueSingleLayerNoShadow                             |
| No Shadow: Standard + Emissive                              | OpaqueEmissiveSingleLayerNoShadow                     |
| No Shadow: Standard + Alpha Mask                            | OpaqueMaskSingleLayerNoShadow                         |
| No Shadow: Standard Two Sided + Alpha Mask                  | TwoSidedOpaqueMaskSingleLayerNoShadow                 |
| Audio Reactive: Emissive + UV Animation                     | AudioEmissive                                         |
| VAT: Standard                                               | OpaqueVATSingleLayer                                  |
| VAT: Standard + Alpha Mask                                  | OpaqueMaskVATSingleLayer                              |
| VAT: Standard + Emissive                                    | OpaqueEmissiveVATSingleLayer                          |

</details>

6. Finally when you export your object make sure to use .FBX and tick the **Custom Properties** box.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-7346e921faed973c6a5a0eeeb56487fd3ecb6c23%2Fmatprop6.png?alt=media" alt="" width="175"><figcaption></figcaption></figure>

Now when you import to sansar the material slots shader will automatically be assigned to your defined shader.

***

### Assigning Shader Settings

This section explains how to assign shader settings such as sliders, toggle boxes, and input fields.

These settings use one of the following data types: **Float**, **Integer**, or **Bool**.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-21097095c3d20f6a90f0f8feaacfb2bd366571cf%2Fmatshaderprop3.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

Each shader has its own set of available settings. You must first assign the shader you want to use before configuring any settings. If you add a setting that is not supported by the selected shader, it will be ignored.

#### **NOTE: Follow the guide above to assign your shader before continuing.**

***

1. **Choose the material slot** you want to configure.\
   Each material slot is set up individually, so you must repeat this process for every slot you want to control. Any settings you do not configure will fall back to Sansar’s default values and can still be adjusted during import.

   Make sure your shader is assigned first—you should see it listed in the material’s **Custom Properties**.

   <figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-0d2dce5dfb23508424cee09272b08309bd189bde%2Fmatpropset2.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>
2. In the material’s **Custom Properties** tab, click **New** to create a property, you can add multiple. Then open the **Edit Property** panel by clicking the cog icon next to the new property.

   <figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-aea2f54e26e943808d35a42e3188dcf8087a2ad8%2Fmatpropset3.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>
3. Using the [Shader Lookup Table](https://docs.sansar.com/latest/creating-in-sansar/shaders-and-materials/shader-lookup-table), find the shader and property you want to configure.\
   Take note of the property’s **System Name**, **Type**, and **Range**.

   <figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-14a524aca8c62fca6020d28b971a480ea5aecce8%2Fmatlookup.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>
4. Choose the property **Type** that matches the shader setting you want to control.

   <figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-6767d61125de8c00c892ac398a92d1a6b6646e1e%2Fmatpropset4.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

***

### Table Key

* **Float – Float**\
  A single number value. Can include decimal values (for example: `1.5`, `0.025`).
* **Float3 – Float Array**\
  A group of numbers used together. Any `Float` followed by a number indicates how many values are required.\
  **Example:** `1.0, 0.5, 0.0`\
  Some settings expect additional values even if they are not actively used—leave these extra values set to `0`.
* **Integer – Integer**\
  A whole number only. While floats may be accepted, the shader will only use whole numbers (for example: `1`, `10`).
* **Bool – Boolean**\
  A simple on/off setting.

***

5. Set the property’s **System Name**, include capitals, along with any **Minimum** and **Maximum** values based on the shader’s **Range**.\
   You only need to define the limits you plan to use, but it is best practice to match the full supported range.

   You do **not** need to set the **Default Value** here, this is done in the main properties panel instead.

   Once done click OK

   <figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-e4a213102ca977dd26fec5a1a41602e80d38152a%2Fmatpropset6.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

   6. In the main panel you can now add your number values to the fields.

   <figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-3356733bd29bee7a3825d2d48267a0391f385fa5%2Fmatpropset7.png?alt=media" alt="" width="475"><figcaption></figcaption></figure>

   You can add as many properties as you need, you do not need to add them if you do not need to control on import as they will just be defaulted if no property is given.

   The order these appear in blender is not importent, just make sure you always have your shader defined.

   7. Finally when you export as .FBX make sure to enable the **Custom Properties** box.

<figure><img src="https://1251409636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFXiTZShM8YWMV94n1eV%2Fuploads%2Fgit-blob-7346e921faed973c6a5a0eeeb56487fd3ecb6c23%2Fmatprop6.png?alt=media" alt="" width="175"><figcaption></figcaption></figure>

Now when you import to sansar the material slots shader will automatically be assigned to your defined shader and any sliders settings or bools will be setup!

## Settings Lookup Table

A full table of the shaders settings names ranges and types is available here [Shader Lookup Table](https://docs.sansar.com/latest/creating-in-sansar/shaders-and-materials/shader-lookup-table)

## Troubleshooting

Settings not working:

* Make sure to check for capitals or extra spaces.
* You are using the system names, and the correct type.
* Your shader was defined.
