您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
101 行
4.1 KiB
101 行
4.1 KiB
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Experimental.Rendering;
|
|
|
|
namespace UnityEditor.Experimental.Rendering.HDPipeline
|
|
{
|
|
class StackLitGUI : BaseUnlitGUI
|
|
{
|
|
protected static class Styles
|
|
{
|
|
public static string InputsText = "Inputs";
|
|
|
|
public static GUIContent baseColorText = new GUIContent("Base Color + Opacity", "Albedo (RGB) and Opacity (A)");
|
|
|
|
public static GUIContent emissiveText = new GUIContent("Emissive Color", "Emissive");
|
|
public static GUIContent emissiveIntensityText = new GUIContent("Emissive Intensity", "Emissive");
|
|
public static GUIContent albedoAffectEmissiveText = new GUIContent("Albedo Affect Emissive", "Specifies whether or not the emissive color is multiplied by the albedo.");
|
|
|
|
}
|
|
|
|
|
|
protected MaterialProperty baseColor = null;
|
|
protected const string kBaseColor = "_BaseColor";
|
|
protected MaterialProperty baseColorMap = null;
|
|
protected const string kBaseColorMap = "_BaseColorMap";
|
|
|
|
protected MaterialProperty emissiveColor = null;
|
|
protected const string kEmissiveColor = "_EmissiveColor";
|
|
protected MaterialProperty emissiveColorMap = null;
|
|
protected const string kEmissiveColorMap = "_EmissiveColorMap";
|
|
protected MaterialProperty emissiveIntensity = null;
|
|
protected const string kEmissiveIntensity = "_EmissiveIntensity";
|
|
protected MaterialProperty albedoAffectEmissive = null;
|
|
protected const string kAlbedoAffectEmissive = "_AlbedoAffectEmissive";
|
|
|
|
|
|
override protected void FindMaterialProperties(MaterialProperty[] props)
|
|
{
|
|
baseColor = FindProperty(kBaseColor, props);
|
|
baseColorMap = FindProperty(kBaseColorMap, props);
|
|
|
|
emissiveColor = FindProperty(kEmissiveColor, props);
|
|
emissiveColorMap = FindProperty(kEmissiveColorMap, props);
|
|
emissiveIntensity = FindProperty(kEmissiveIntensity, props);
|
|
albedoAffectEmissive = FindProperty(kAlbedoAffectEmissive, props);
|
|
}
|
|
|
|
protected override void MaterialPropertiesGUI(Material material)
|
|
{
|
|
EditorGUILayout.LabelField(Styles.InputsText, EditorStyles.boldLabel);
|
|
|
|
m_MaterialEditor.TexturePropertySingleLine(Styles.baseColorText, baseColorMap, baseColor);
|
|
m_MaterialEditor.TextureScaleOffsetProperty(baseColorMap);
|
|
|
|
m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveText, emissiveColorMap, emissiveColor);
|
|
m_MaterialEditor.TextureScaleOffsetProperty(emissiveColorMap);
|
|
m_MaterialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText);
|
|
m_MaterialEditor.ShaderProperty(albedoAffectEmissive, Styles.albedoAffectEmissiveText);
|
|
|
|
var surfaceTypeValue = (SurfaceType)surfaceType.floatValue;
|
|
if (surfaceTypeValue == SurfaceType.Transparent)
|
|
{
|
|
EditorGUILayout.Space();
|
|
EditorGUILayout.LabelField(StylesBaseUnlit.TransparencyInputsText, EditorStyles.boldLabel);
|
|
++EditorGUI.indentLevel;
|
|
|
|
DoDistortionInputsGUI();
|
|
|
|
--EditorGUI.indentLevel;
|
|
}
|
|
}
|
|
|
|
protected override void MaterialPropertiesAdvanceGUI(Material material)
|
|
{
|
|
}
|
|
|
|
protected override void VertexAnimationPropertiesGUI()
|
|
{
|
|
|
|
}
|
|
|
|
protected override bool ShouldEmissionBeEnabled(Material mat)
|
|
{
|
|
return mat.GetFloat(kEmissiveIntensity) > 0.0f;
|
|
}
|
|
|
|
protected override void SetupMaterialKeywordsAndPassInternal(Material material)
|
|
{
|
|
SetupMaterialKeywordsAndPass(material);
|
|
}
|
|
|
|
// All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if code change
|
|
static public void SetupMaterialKeywordsAndPass(Material material)
|
|
{
|
|
SetupBaseUnlitKeywords(material);
|
|
SetupBaseUnlitMaterialPass(material);
|
|
|
|
CoreUtils.SetKeyword(material, "_EMISSIVE_COLOR_MAP", material.GetTexture(kEmissiveColorMap));
|
|
}
|
|
}
|
|
} // namespace UnityEditor
|