浏览代码

Fixed groups, now they stay in the same state as they were when you go back to the material.

/main
Jean-François F Fortin 7 年前
当前提交
2d4b30ed
共有 4 个文件被更改,包括 85 次插入44 次删除
  1. 37
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/StackLit/BaseMaterialUI.cs
  2. 26
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/StackLit/StackLitUI.cs
  3. 64
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.shader
  4. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitData.hlsl

37
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/StackLit/BaseMaterialUI.cs


public string m_Title = string.Empty;
private readonly BaseProperty[] m_ChildProperties;
public bool Foldout = false;
private readonly Property m_Show;
public GroupProperty(BaseMaterialGUI parent, BaseProperty[] childProperties, Func<object, bool> isVisible = null)
: this(parent, string.Empty, childProperties, isVisible)
public GroupProperty(BaseMaterialGUI parent, string groupName, BaseProperty[] childProperties, Func<object, bool> isVisible = null)
: this(parent, groupName, string.Empty, childProperties, isVisible)
public GroupProperty(BaseMaterialGUI parent, string groupTitle, BaseProperty[] childProperties, Func<object, bool> isVisible = null)
public GroupProperty(BaseMaterialGUI parent, string groupName, string groupTitle, BaseProperty[] childProperties, Func<object, bool> isVisible = null)
m_Show = new Property(parent, groupName + "Show", "", false);
m_Title = groupTitle;
m_ChildProperties = childProperties;
}

m_Show.OnFindProperty(props);
foreach (var c in m_ChildProperties)
{
c.OnFindProperty(props);

{
if (!string.IsNullOrEmpty(m_Title))
{
Foldout = EditorGUILayout.Foldout(Foldout, m_Title);
m_Show.BoolValue = EditorGUILayout.Foldout(m_Show.BoolValue, m_Title);
else
else if (m_Show.IsValid)
Foldout = true;
m_Show.BoolValue = true;
if (Foldout)
if (!m_Show.IsValid || m_Show.BoolValue)
{
EditorGUI.indentLevel++;

public bool BoolValue
{
get { return Math.Abs(m_MaterialProperty.floatValue) > 0.0f; }
get { return m_MaterialProperty == null || Math.Abs(m_MaterialProperty.floatValue) > 0.0f; }
set { m_MaterialProperty.floatValue = value ? 1.0f : 0.0f; }
}

Triplanar,
}
public Property m_Show;
public TextureOneLineProperty m_TextureProperty;
public ComboProperty m_UvSetProperty;

public Property m_RemapProperty;
public Property m_InvertRemapProperty;
public bool Foldout = false;
public TextureProperty(BaseMaterialGUI parent, string propertyName, string constantPropertyName, string guiText, bool isMandatory = true, bool isNormalMap = false)
: this(parent, propertyName, constantPropertyName, guiText, string.Empty, isMandatory, isNormalMap)

public TextureProperty(BaseMaterialGUI parent, string propertyName, string constantPropertyName, string guiText, string toolTip, bool isMandatory = true, bool isNormalMap = false)
: base(parent, propertyName, guiText, toolTip, isMandatory)
{
m_Show = new Property(parent, propertyName + "Show", "", isMandatory);
m_TextureProperty = new TextureOneLineProperty(parent, propertyName, constantPropertyName, guiText, toolTip, isMandatory);
m_UvSetProperty = new ComboProperty(parent, propertyName + "UV", "UV Mapping", Enum.GetNames(typeof(UVMapping)), false);

{
base.OnFindProperty(props);
m_Show.OnFindProperty(props);
m_TextureProperty.OnFindProperty(props);
m_UvSetProperty.OnFindProperty(props);
m_LocalOrWorldProperty.OnFindProperty(props);

public override void OnGUI()
{
if (m_TextureProperty.IsValid
&& (IsVisible == null || IsVisible(this)))
&& (IsVisible == null || IsVisible(this))
&& m_Show.IsValid)
Foldout = EditorGUILayout.Foldout(Foldout, PropertyText);
if (Foldout)
m_Show.BoolValue = EditorGUILayout.Foldout(m_Show.BoolValue, PropertyText);
if (m_Show.BoolValue)
{
EditorGUI.indentLevel++;

26
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/StackLit/StackLitUI.cs


public StackLitGUI()
{
_baseMaterialProperties = new GroupProperty(this, new BaseProperty[]
_baseMaterialProperties = new GroupProperty(this, "_BaseMaterial", new BaseProperty[]
_materialProperties = new GroupProperty(this, new BaseProperty[]
_materialProperties = new GroupProperty(this, "_Material", new BaseProperty[]
new GroupProperty(this, "Standard", new BaseProperty[]
new GroupProperty(this, "_Standard", "Standard", new BaseProperty[]
{
new TextureProperty(this, k_BaseColorMap, k_BaseColor, "Base Color + Opacity", "Albedo (RGB) and Opacity (A)", false),
new TextureProperty(this, k_MetallicMap, k_Metallic, "Metallic", "Metallic", false),

//new TextureProperty(this, k_BaseColorMap, k_BaseColor, "Dielectric IoR", "Index of Refraction for Dielectric", false),
}),
new GroupProperty(this, "Emissive", new BaseProperty[]
new GroupProperty(this, "_Emissive", "Emissive", new BaseProperty[]
{
new TextureProperty(this, k_EmissiveColorMap, k_EmissiveColor, "Emissive Color", "Emissive", false),
new Property(this, k_EmissiveIntensity, "Emissive Intensity", "Emissive", false),

//new GroupProperty(this, "Coat", new BaseProperty[]
//new GroupProperty(this, "_Coat", "Coat", new BaseProperty[]
//{
// new TextureProperty(this, k_BaseColorMap, k_BaseColor, "SmoothnessCoat", "smoothnessCoat", false),
// new TextureProperty(this, k_BaseColorMap, k_BaseColor, "Index Of Refraction", "iorCoat", false),

new GroupProperty(this, "Sub-Surface Scattering", new BaseProperty[]
new GroupProperty(this, "_SSS", "Sub-Surface Scattering", new BaseProperty[]
new TextureProperty(this, k_SubsurfaceMaskName, "Subsurface mask map (R)", "Determines the strength of the subsurface scattering effect.", false),
new TextureProperty(this, k_SubsurfaceMaskMap, k_SubsurfaceMaskName, "Subsurface mask map (R)", "Determines the strength of the subsurface scattering effect.", false),
new GroupProperty(this, "Second Specular Lobe", new BaseProperty[]
new GroupProperty(this, "_Lobe2", "Second Specular Lobe", new BaseProperty[]
//new GroupProperty(this, "Anisotropy", new BaseProperty[]
//new GroupProperty(this, "_Anisotropy", "Anisotropy", new BaseProperty[]
//{
// new TextureProperty(this, k_BaseColorMap, k_BaseColor, "Anisotropy Strength", "anisotropy strength", false),
// new TextureProperty(this, k_BaseColorMap, k_BaseColor, "Rotation", "rotation", false),

new GroupProperty(this, "Transmission", new BaseProperty[]
new GroupProperty(this, "_Transmission", "Transmission", new BaseProperty[]
new TextureProperty(this, k_ThicknessName, "Thickness", "If subsurface scattering is enabled, low values allow some light to be transmitted through the object.", false),
new TextureProperty(this, k_ThicknessMapName, k_ThicknessName, "Thickness", "If subsurface scattering is enabled, low values allow some light to be transmitted through the object.", false),
//new GroupProperty(this, "Iridescence", new BaseProperty[]
//new GroupProperty(this, "_Iridescence", "Iridescence", new BaseProperty[]
//new GroupProperty(this, "Glint", new BaseProperty[]
//new GroupProperty(this, "_Glint", "Glint", new BaseProperty[]
//{
// new TextureProperty(this, k_BaseColorMap, k_BaseColor, "Density", "Density:", false),
// new TextureProperty(this, k_BaseColorMap, k_BaseColor, "Tint", "Tint", false),

64
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.shader


// Reminder. Color here are in linear but the UI (color picker) do the conversion sRGB to linear
// Be careful, do not change the name here to _Color. It will conflict with the "fake" parameters (see end of properties) required for GI.
_BaseColor("BaseColor", Color) = (1,1,1,1)
_BaseColorMap("BaseColorMap", 2D) = "white" {}
_BaseColorMapUV("BaseColorMapUV", Float) = 0.0
_BaseColorMap("BaseColor Map", 2D) = "white" {}
[HideInInspector] _BaseColorMapShow("BaseColor Map Show", Float) = 0
_BaseColorMapUV("BaseColor Map UV", Float) = 0.0
_MetallicMap("MetallicMap", 2D) = "black" {}
_MetallicMapUV("MetallicMapUV", Float) = 0.0
_MetallicMapChannel("MetallicMapChannel", Vector) = (1, 0, 0, 0)
_MetallicRemap("Metallic Remap", Vector) = (0, 1, 0, 0)
[ToggleUI] _MetallicRemapInverted("Invert Metallic Remap", Float) = 0.0
_SmoothnessAMap("BaseColorMap", 2D) = "white" {}
_SmoothnessAMapUV("SmoothnessAMapUV", Float) = 0.0
_MetallicMap("Metallic Map", 2D) = "black" {}
[HideInInspector] _MetallicMapShow("Metallic Map Show", Float) = 0
_MetallicMapUV("Metallic Map UV", Float) = 0.0
_MetallicMapChannel("Metallic Map Channel", Vector) = (1, 0, 0, 0)
_MetallicRemap("Metallic Remap", Vector) = (0, 1, 0, 0)
[ToggleUI] _MetallicRemapInverted("Invert Metallic Remap", Float) = 0.0
_SmoothnessAMap("SmoothnessA Map", 2D) = "white" {}
[HideInInspector] _SmoothnessAMapShow("SmoothnessA Map Show", Float) = 0
_SmoothnessAMapUV("SmoothnessA Map UV", Float) = 0.0
_SmoothnessBMap("SmoothnessBMap", 2D) = "white" {}
_SmoothnessBMapUV("SmoothnessBMapUV", Float) = 0.0
_SmoothnessBMap("SmoothnessB Map", 2D) = "white" {}
[HideInInspector] _SmoothnessBMapShow("SmoothnessB Map Show", Float) = 0
_SmoothnessBMapUV("SmoothnessB Map UV", Float) = 0.0
_SmoothnessBMapChannel("SmoothnessB Map Channel", Vector) = (1, 0, 0, 0)
_SmoothnessBRemap("SmoothnessB Remap", Vector) = (0, 1, 0, 0)
[ToggleUI] _SmoothnessBRemapInverted("Invert SmoothnessB Remap", Float) = 0.0

[HideInInspector] _NormalMapShow("NormalMap Show", Float) = 0.0
_NormalMapUV("NormalMapUV", Float) = 0.0
_NormalScale("_NormalScale", Range(0.0, 2.0)) = 1

_EmissiveColor("EmissiveColor", Color) = (1, 1, 1)
_EmissiveColorMap("EmissiveColorMap", 2D) = "white" {}
_EmissiveColorMapUV("EmissiveColorMap", Range(0.0, 1.0)) = 0
_EmissiveIntensity("EmissiveIntensity", Float) = 0
_EmissiveColor("Emissive Color", Color) = (1, 1, 1)
_EmissiveColorMap("Emissive Color Map", 2D) = "white" {}
[HideInInspector] _EmissiveColorMapShow("Emissive Color Map Show", Float) = 0.0
_EmissiveColorMapUV("Emissive Color Map UV", Range(0.0, 1.0)) = 0
_EmissiveIntensity("Emissive Intensity", Float) = 0
_SubsurfaceMask("Subsurface Mask", Range(0.0, 1.0)) = 1.0
_SubsurfaceMaskMap("Subsurface Mask MAp", 2D) = "black" {}
[HideInInspector] _SubsurfaceMaskMapShow("Subsurface Mask Map Show", Float) = 0
_SubsurfaceMaskMapUV("Subsurface Mask Map UV", Float) = 0.0
_SubsurfaceMaskMapChannel("Subsurface Mask Map Channel", Vector) = (1, 0, 0, 0)
_SubsurfaceMaskRemap("Subsurface Mask Remap", Vector) = (0, 1, 0, 0)
[ToggleUI] _SubsurfaceMaskRemapInverted("Invert Subsurface Mask Remap", Float) = 0.0
_Thickness("Thickness", Range(0.0, 1.0)) = 1.0
_ThicknessMap("Thickness MAp", 2D) = "black" {}
[HideInInspector] _ThicknessMapShow("Thickness Show", Float) = 0
_ThicknessMapUV("Thickness Map UV", Float) = 0.0
_ThicknessMapChannel("Thickness Map Channel", Vector) = (1, 0, 0, 0)
_ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0)
[ToggleUI] _ThicknessRemapInverted("Invert Thickness Remap", Float) = 0.0
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
[ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0

[ToggleUI] _DoubleSidedEnable("Double sided enable", Float) = 0.0
[Enum(Flip, 0, Mirror, 1, None, 2)] _DoubleSidedNormalMode("Double sided normal mode", Float) = 1 // This is for the editor only, see BaseLitUI.cs: _DoubleSidedConstants will be set based on the mode.
[HideInInspector] _DoubleSidedConstants("_DoubleSidedConstants", Vector) = (1, 1, -1, 0)
// Sections show values.
[HideInInspector] _StandardShow("_StandardShow", Float) = 0.0
[HideInInspector] _EmissiveShow("_EmissiveShow", Float) = 0.0
[HideInInspector] _CoatShow("_CoatShow", Float) = 0.0
[HideInInspector] _SSSShow("_SSSShow", Float) = 0.0
[HideInInspector] _Lobe2Show("_Lobe2Show", Float) = 0.0
[HideInInspector] _AnisotropyShow("_AnisotropyShow", Float) = 0.0
[HideInInspector] _TransmissionShow("_TransmissionShow", Float) = 0.0
[HideInInspector] _IridescenceShow("_IridescenceShow", Float) = 0.0
[HideInInspector] _GlintShow("_GlintShow", Float) = 0.0
// Caution: C# code in BaseLitUI.cs call LightmapEmissionFlagsProperty() which assume that there is an existing "_EmissionColor"
// value that exist to identify if the GI emission need to be enabled.

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitData.hlsl


// Note we don't use the _NORMALMAP_IDX mechanism of the Lit shader, since we don't have "layers", we can
// directly use the shader_feature keyword:
#ifdef _NORMALMAP
normalTS = SAMPLE_UVMAPPING_NORMALMAP(_NormalMap, SAMPLER_NORMALMAP_ID, layerTexCoord.base, _NormalScale);
normalTS = SAMPLE_UVMAPPING_NORMALMAP(_NormalMap, SAMPLER_NORMALMAP_ID, layerTexCoord.base, _NormalScale);
#else
normalTS = float3(0.0, 0.0, 1.0);
#endif

正在加载...
取消
保存