Accessing VPB Materials
For VPB materials, use Pixyz custom materials. To create custom shaders, use material properties.
Before you can import assets with VPB materials, you must perform these tasks:
- Enable custom material setup functionality.
- Create a custom material setup, that is, map information between imported materials and Unity materials.
- Add this setup to default import settings.
Materials are converted using this class: Pixyz.ImportSDK.MaterialConversions. The ConvertCustomMaterial function is called to convert custom materials.
Enable custom material setup functionality
Follow these steps:
- From the API, enable the ImportRealisticMaterials preference:
Plugin4UnityProduct.API.Core.SetModuleProperty("IO", "ImportRealisticMaterials", "True")
- Modify the Menu.cs file as follows. This file is located in this folder: packages/Pixyz Commons/Editor/UI.
- Add the Conversion namespace:
using UnityEngine.PixyzCommons.Conversion;
- Remove the comment characters (//) for the CreateCustomMaterialSetupAsset function:
//[MenuItem("Pixyz/Create Custom Material Setup", false, 9)]
//[MenuItem("Assets/Create/Pixyz/Custom Material Setup", priority = 1)]
//private static void CreateCustomMaterialSetupAsset()
//{
// EditorExtensions.CreateAsset<CustomMaterialSetup>("CustomMaterialSetup", true);
//}
This example shows the first lines of the file after modification:
using System.Text;
using UnityEditor.PixyzCommons.Extensions;
using UnityEngine;
using UnityEngine.PixyzCommons.Conversion;
using UnityEngine.PixyzCommons.Licensing;
namespace UnityEditor.PixyzCommons.UI
{
internal static class Menus
{
[MenuItem("Pixyz/Create Custom Material Setup", false, 9)]
[MenuItem("Assets/Create/Pixyz/Custom Material Setup", priority = 1)]
private static void CreateCustomMaterialSetupAsset()
{
EditorExtensions.CreateAsset<CustomMaterialSetup>("CustomMaterialSetup", true);
}
Create a custom material setup
Before you can import custom materials, you must map information between imported materials and Unity materials. Follow these steps:
- From the Pixyz menu, choose Create Custom Material Setup.
- Map material names:
- On the Inspector pane, click the Plus sign (+) in the Custom Material Setup section.
- Enter the name of the imported material, for example UMetallicPaintMaterial, then click Validate.
- Enter the name of the Unity material, for example Shader Graphs/CarPaint.
- Map property names:
- Expand the Properties section and click Add property binding.
- Enter the property name of the imported material, for example flakeColor, then click Validate.
- In the Keyword field, enter the property name of the Unity material, for example ColorCF7B3627.
Select a custom material setup for import
To use a custom material setup for import, follow these steps:
- In your project assets, expand Pixyz > Editor and select Default Import Settings.
- On the Inspector pane, switch to the debug mode. To do this, click the More Items (⋮) button and select Debug. Read more.
- In the list of import settings, click the Plus sign (+) next to the Custom Material Setup field and select a custom material setup.
This illustration shows an Aviera model that has been imported using the Pixyz Plugin: