浏览代码

- Integrate AlphaCutOff with MaterialGraph

- Move LitGraphUI to a specific cs file
/scriptablerenderloop-materialgraph
Paul Demeulenaere 8 年前
当前提交
21cd551b
共有 5 个文件被更改,包括 57 次插入31 次删除
  1. 5
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  2. 37
      Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Editor/LitUI.cs
  3. 4
      Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Lit.template
  4. 30
      Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Editor/LitGraphUI.cs
  5. 12
      Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Editor/LitGraphUI.cs.meta

5
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


ZERO_INITIALIZE(BuiltinData, builtinData);
${PixelShaderInitialize}
${PixelShaderBody}
/* this clip could be integrated earlier for optimisation */
#ifdef _ALPHATEST_ON
clip(builtinData.opacity - _AlphaCutoff);
#endif
}
struct Attributes

37
Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Editor/LitUI.cs


namespace UnityEditor
{
class BaseLitGUI : ShaderGUI
public class BaseLitGUI : ShaderGUI
public enum DetailMapMode
{
DetailWithNormal,
DetailWithAOHeight,
}
public enum DetailMapMode
{
DetailWithNormal,
DetailWithAOHeight,
}
public static string OptionText = "Options";
public static string SurfaceTypeText = "Surface Type";
public static string BlendModeText = "Blend Mode";

private const string kAlphaCutoffEnabled = "_AlphaCutoffEnable";
private const string kDoubleSidedMode = "_DoubleSidedMode";
protected static string[] reservedProperties = new string[] { kSurfaceType, kBlendMode, kAlphaCutoff, kAlphaCutoffEnabled, kDoubleSidedMode };
}
class LitGraphUI : BaseLitGUI
{
private MaterialProperty[] genericProperties = new MaterialProperty[] { };
public override void FindInputProperties(MaterialProperty[] props)
{
genericProperties = props.Where(p => (p.flags & MaterialProperty.PropFlags.HideInInspector) == 0 & !reservedProperties.Contains(p.name)).ToArray();
}
protected override void ShaderInputOptionsGUI()
{
EditorGUI.indentLevel++;
foreach(var prop in genericProperties)
{
if ((prop.type & MaterialProperty.PropType.Texture) != 0)
{
m_MaterialEditor.TexturePropertySingleLine(new GUIContent(prop.name), prop);
}
else
{
m_MaterialEditor.ShaderProperty(prop, prop.name);
}
}
EditorGUI.indentLevel--;
}
}
class LitGUI : BaseLitGUI

4
Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Lit.template


#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _ _DOUBLESIDED_LIGHTING_FLIP _DOUBLESIDED_LIGHTING_MIRROR
//-------------------------------------------------------------------------------------
// Include

// Set of users variables
${ShaderFunctions}
${ShaderPropertyUsages}
float _AlphaCutoff;
ENDHLSL

30
Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Editor/LitGraphUI.cs


using System;
using System.Linq;
namespace UnityEditor
{
class LitGraphUI : BaseLitGUI
{
private MaterialProperty[] genericProperties = new MaterialProperty[] { };
public override void FindInputProperties(MaterialProperty[] props)
{
genericProperties = props.Where(p => (p.flags & MaterialProperty.PropFlags.HideInInspector) == 0 & !reservedProperties.Contains(p.name)).ToArray();
}
protected override void ShaderInputOptionsGUI()
{
EditorGUI.indentLevel++;
foreach (var prop in genericProperties)
{
if ((prop.type & MaterialProperty.PropType.Texture) != 0)
{
m_MaterialEditor.TexturePropertySingleLine(new GUIContent(prop.name), prop);
}
else
{
m_MaterialEditor.ShaderProperty(prop, prop.name);
}
}
EditorGUI.indentLevel--;
}
}
}

12
Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Editor/LitGraphUI.cs.meta


fileFormatVersion: 2
guid: 18e7ba08e94e1a641ac000d5f9e7c988
timeCreated: 1479806473
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存