浏览代码

-Added foldouts.

-Added channel variables to textures.
/main
Jean-François F Fortin 7 年前
当前提交
f5a4da8f
共有 4 个文件被更改,包括 58 次插入35 次删除
  1. 77
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/StackLit/BaseMaterialUI.cs
  2. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.shader
  3. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitData.hlsl
  4. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitProperties.hlsl

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


private readonly BaseProperty[] m_ChildProperties;
public bool Foldout = false;
public GroupProperty(BaseMaterialGUI parent, BaseProperty[] childProperties, Func<object, bool> isVisible = null)
: this(parent, string.Empty, childProperties, isVisible)
{

{
if (!string.IsNullOrEmpty(m_Title))
{
EditorGUILayout.LabelField(m_Title, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
Foldout = EditorGUILayout.Foldout(Foldout, m_Title);
foreach (var c in m_ChildProperties)
else
c.OnGUI();
Foldout = true;
if (!string.IsNullOrEmpty(m_Title))
if (Foldout)
EditorGUI.indentLevel++;
foreach (var c in m_ChildProperties)
{
c.OnGUI();
}
EditorGUI.indentLevel--;
}
}

A,
}
public enum UVSet
public enum UVMapping
{
UV0,
UV1,

public TextureOneLineProperty m_TextureProperty;
public ComboProperty m_ChannelProperty;
public ComboProperty m_UvSetProperty;
public Property m_LocalOrWorldProperty;
public ComboProperty m_UvSetProperty;
public Property m_LocalOrWorldProperty;
public Property m_ChannelProperty;
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)

{
m_TextureProperty = new TextureOneLineProperty(parent, propertyName, constantPropertyName, guiText, toolTip, isMandatory);
m_ChannelProperty = new ComboProperty(parent, propertyName + "Channel", "Channel", Enum.GetNames(typeof(Channel)), false);
m_UvSetProperty = new ComboProperty(parent, propertyName + "UV", "UV Mapping", Enum.GetNames(typeof(UVMapping)), false);
m_LocalOrWorldProperty = new Property(parent, propertyName + "LocalOrWorld", "Local Space", "Whether Planar or Triplanar is using Local or World space.", false);
m_UvSetProperty = new ComboProperty(parent, propertyName + "UV", "UV Set", Enum.GetNames(typeof(UVSet)), false);
m_LocalOrWorldProperty = new Property(parent, propertyName + "LocalOrWorld", "Local Space", "Whether Planar or Triplanar is using Local or World space.", false);
m_ChannelProperty = new Property(parent, propertyName + "Channel", "Channel", false);
m_RemapProperty = new Property(parent, constantPropertyName + "Remap", "Remapping", "Defines the range to remap/scale the values in texture", false);
m_InvertRemapProperty = new Property(parent, constantPropertyName + "RemapInverted", "Invert Remapping", "Whether the mapping values are inverted.", false);

base.OnFindProperty(props);
m_TextureProperty.OnFindProperty(props);
m_TilingProperty.OnFindProperty(props);
m_TilingProperty.OnFindProperty(props);
m_ChannelProperty.OnFindProperty(props);
m_RemapProperty.OnFindProperty(props);
m_InvertRemapProperty.OnFindProperty(props);
}

if (m_TextureProperty.IsValid
&& (IsVisible == null || IsVisible(this)))
{
m_TextureProperty.OnGUI();
if (m_TextureProperty.TextureValue != null)
Foldout = EditorGUILayout.Foldout(Foldout, PropertyText);
if (Foldout)
m_TilingProperty.OnGUI();
m_UvSetProperty.OnGUI();
m_LocalOrWorldProperty.OnGUI();
m_TextureProperty.OnGUI();
if (m_RemapProperty.IsValid)
if (m_TextureProperty.TextureValue != null)
// Display the remap of texture values.
Vector2 remap = m_RemapProperty.VectorValue;
EditorGUI.BeginChangeCheck();
EditorGUILayout.MinMaxSlider(m_RemapProperty.PropertyText, ref remap.x, ref remap.y, 0.0f, 1.0f);
if (EditorGUI.EndChangeCheck())
m_UvSetProperty.OnGUI();
m_LocalOrWorldProperty.OnGUI();
m_TilingProperty.OnGUI();
m_ChannelProperty.OnGUI();
m_LocalOrWorldProperty.OnGUI();
if (m_RemapProperty.IsValid)
m_RemapProperty.VectorValue = remap;
}
// Display the remap of texture values.
Vector2 remap = m_RemapProperty.VectorValue;
EditorGUI.BeginChangeCheck();
EditorGUILayout.MinMaxSlider(m_RemapProperty.PropertyText, ref remap.x, ref remap.y,
0.0f, 1.0f);
if (EditorGUI.EndChangeCheck())
{
m_RemapProperty.VectorValue = remap;
}
m_InvertRemapProperty.OnGUI();
m_InvertRemapProperty.OnGUI();
}
}
EditorGUI.indentLevel--;

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


_BaseColorMapUV("BaseColorMapUV", Float) = 0.0
_Metallic("Metallic", Range(0.0, 1.0)) = 0
_MetallicMap("MetallicMap", 2D) = "white" {}
_MetallicMap("MetallicMap", 2D) = "black" {}
_MetallicMapChannel("MetallicMapChannel", Vector) = (1, 0, 0, 0)
_MetallicRemap("Metallic Remap", Vector) = (0, 1, 0, 0)
[ToggleUI] _MetallicRemapInverted("Invert Metallic Remap", Float) = 0.0

_SmoothnessARemap("SmoothnessA Remap", Vector) = (0, 1, 0, 0)
_SmoothnessAMapChannel("SmoothnessA Map Channel", Vector) = (1, 0, 0, 0)
_SmoothnessARemap("SmoothnessA Remap", Vector) = (0, 1, 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
_LobeMix("Lobe Mix", Range(0.0, 1.0)) = 0

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


//TODO: bentNormalTS
#if defined(_SMOOTHNESSMASKMAPA)
surfaceData.perceptualSmoothnessA = SAMPLE_UVMAPPING_TEXTURE2D(_SmoothnessAMap, sampler_SmoothnessAMap, layerTexCoord.base).a;
surfaceData.perceptualSmoothnessA = dot(SAMPLE_UVMAPPING_TEXTURE2D(_SmoothnessAMap, sampler_SmoothnessAMap, layerTexCoord.base), _MetallicMapChannel, _SmoothnessAMapChannel);
surfaceData.perceptualSmoothnessA = lerp(_SmoothnessARemap.x, _SmoothnessARemap.y, surfaceData.perceptualSmoothnessA);
#else
surfaceData.perceptualSmoothnessA = _SmoothnessA;

surfaceData.perceptualSmoothnessB = SAMPLE_UVMAPPING_TEXTURE2D(_SmoothnessAMaB, sampler_SmoothnessBMap, layerTexCoord.base).a;
surfaceData.perceptualSmoothnessB = dot(SAMPLE_UVMAPPING_TEXTURE2D(_SmoothnessAMaB, sampler_SmoothnessBMap, layerTexCoord.base), _SmoothnessBMapChannel);
surfaceData.perceptualSmoothnessB = lerp(_SmoothnessBRemap.x, _SmoothnessBRemap.y, surfaceData.perceptualSmoothnessB);
#else
surfaceData.perceptualSmoothnessB = _SmoothnessB;

// TODO: Ambient occlusion, detail mask.
#ifdef _METALLICMAP
surfaceData.metallic = SAMPLE_UVMAPPING_TEXTURE2D(_MetallicMap, sampler_MetallicMap, layerTexCoord.base).r;
surfaceData.metallic = dot(SAMPLE_UVMAPPING_TEXTURE2D(_MetallicMap, sampler_MetallicMap, layerTexCoord.base), _MetallicMapChannel);
#else
surfaceData.metallic = 1.0;
#endif

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitProperties.hlsl


float _Metallic;
float _MetallicMapUV;
float4 _MetallicMapChannel;
float4 _SmoothnessAMapChannel;
float4 _SmoothnessBMapChannel;
float4 _SmoothnessBRemap;
float _LobeMix;

正在加载...
取消
保存