浏览代码

Revert Master node changes

- Will put in separate PR
- Remove new blend modes
- Remove culling dropdown
/main
Matt Dean 7 年前
当前提交
ccf55db8
共有 2 个文件被更改,包括 14 次插入50 次删除
  1. 33
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightWeightPBRSubShader.cs
  2. 31
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/MasterNodes/PBRMasterNode.cs

33
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightWeightPBRSubShader.cs


switch (masterNode.alphaMode)
{
case PBRMasterNode.AlphaMode.Transparent:
case PBRMasterNode.AlphaMode.Fade:
case PBRMasterNode.AlphaMode.Additive:
case PBRMasterNode.AlphaMode.Multiply:
case PBRMasterNode.AlphaMode.AlphaBlend:
case PBRMasterNode.AlphaMode.AdditiveBlend:
defines.AddShaderChunk("#define _AlphaOut 1", true);
break;
}

case PBRMasterNode.AlphaMode.Opaque:
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One;
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.Zero;
materialOptions.cullMode = SurfaceMaterialOptions.CullMode.Back;
case PBRMasterNode.AlphaMode.Transparent:
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.One;
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.OneMinusSrcAlpha;
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual;
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off;
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent;
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent;
break;
case PBRMasterNode.AlphaMode.Fade:
case PBRMasterNode.AlphaMode.AlphaBlend:
materialOptions.cullMode = SurfaceMaterialOptions.CullMode.Back;
case PBRMasterNode.AlphaMode.Additive:
case PBRMasterNode.AlphaMode.AdditiveBlend:
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual;
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off;
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent;
materialOptions.renderType = SurfaceMaterialOptions.RenderType.Transparent;
break;
case PBRMasterNode.AlphaMode.Multiply:
materialOptions.srcBlend = SurfaceMaterialOptions.BlendMode.DstColor;
materialOptions.dstBlend = SurfaceMaterialOptions.BlendMode.Zero;
materialOptions.cullMode = SurfaceMaterialOptions.CullMode.Back;
materialOptions.zTest = SurfaceMaterialOptions.ZTest.LEqual;
materialOptions.zWrite = SurfaceMaterialOptions.ZWrite.Off;
materialOptions.renderQueue = SurfaceMaterialOptions.RenderQueue.Transparent;

materialOptions.cullMode = masterNode.cullMode;
var tagsVisitor = new ShaderGenerator();
materialOptions.GetTags(tagsVisitor);

return new[] { subShader.GetShaderString(0) };
}
}
}
}

31
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/MasterNodes/PBRMasterNode.cs


public enum AlphaMode
{
Opaque,
Transparent,
Fade,
Additive,
Multiply
AlphaBlend,
AdditiveBlend
[EnumControl("Model")]
[EnumControl("")]
public Model model
{
get { return m_Model; }

[SerializeField]
private AlphaMode m_AlphaMode;
[EnumControl("Blend")]
[EnumControl("")]
public AlphaMode alphaMode
{
get { return m_AlphaMode; }

}
}
[SerializeField]
private SurfaceMaterialOptions.CullMode m_CullMode;
[EnumControl("Culling")]
public SurfaceMaterialOptions.CullMode cullMode
{
get { return m_CullMode; }
set
{
if (m_CullMode == value)
return;
m_CullMode = value;
Dirty(ModificationScope.Graph);
}
}
public PBRMasterNode()
{
UpdateNodeAfterDeserialization();

AddSlot(new Vector1MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, 0.5f, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, 1f, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, 1f, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(AlphaThresholdSlotId, GraphUtil.ConvertCamelCase(AlphaClipThresholdSlotName, true), AlphaClipThresholdSlotName, SlotType.Input, 0f, ShaderStage.Fragment));
AddSlot(new Vector1MaterialSlot(AlphaThresholdSlotId, AlphaClipThresholdSlotName, AlphaClipThresholdSlotName, SlotType.Input, 0f, ShaderStage.Fragment));
// clear out slot names that do not match the slots
// we support

return finalShader.GetShaderString(0);
}
}
}
}
正在加载...
取消
保存