浏览代码

Master node improvements part 1

- Add two sided option
- Add multiply blend mode
- Rename blend modes
- Add master node parameter labels
/main
Matt Dean 7 年前
当前提交
b3551b81
共有 6 个文件被更改,包括 55 次插入13 次删除
  1. 2
      com.unity.shadergraph/Editor/Data/LightweightPipeline/LightWeightPBRSubShader.cs
  2. 2
      com.unity.shadergraph/Editor/Data/LightweightPipeline/LightWeightUnlitSubShader.cs
  3. 5
      com.unity.shadergraph/Editor/Data/MasterNodes/AlphaMode.cs
  4. 20
      com.unity.shadergraph/Editor/Data/MasterNodes/PBRMasterNode.cs
  5. 18
      com.unity.shadergraph/Editor/Data/MasterNodes/UnlitMasterNode.cs
  6. 21
      com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs

2
com.unity.shadergraph/Editor/Data/LightweightPipeline/LightWeightPBRSubShader.cs


subShader.Indent();
subShader.AddShaderChunk("Tags{ \"RenderPipeline\" = \"LightweightPipeline\"}", true);
var materialOptions = ShaderGenerator.GetMaterialOptionsFromAlphaMode(masterNode.alphaMode);
var materialOptions = ShaderGenerator.GetMaterialOptions(masterNode.alphaMode, masterNode.twoSided.isOn);
var tagsVisitor = new ShaderGenerator();
materialOptions.GetTags(tagsVisitor);
subShader.AddShaderChunk(tagsVisitor.GetShaderString(0), true);

2
com.unity.shadergraph/Editor/Data/LightweightPipeline/LightWeightUnlitSubShader.cs


subShader.Indent();
subShader.AddShaderChunk("Tags{ \"RenderType\" = \"Opaque\" \"RenderPipeline\" = \"LightweightPipeline\"}", true);
var materialOptions = ShaderGenerator.GetMaterialOptionsFromAlphaMode(masterNode.alphaMode);
var materialOptions = ShaderGenerator.GetMaterialOptions(masterNode.alphaMode, masterNode.twoSided.isOn);
var tagsVisitor = new ShaderGenerator();
materialOptions.GetTags(tagsVisitor);
subShader.AddShaderChunk(tagsVisitor.GetShaderString(0), true);

5
com.unity.shadergraph/Editor/Data/MasterNodes/AlphaMode.cs


public enum AlphaMode
{
Opaque,
AlphaBlend,
AdditiveBlend
Fade,
Additive,
Multiply
}
}

20
com.unity.shadergraph/Editor/Data/MasterNodes/PBRMasterNode.cs


[SerializeField]
private Model m_Model = Model.Metallic;
[EnumControl("")]
[EnumControl("Workflow")]
public Model model
{
get { return m_Model; }

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

return;
m_AlphaMode = value;
Dirty(ModificationScope.Graph);
}
}
[SerializeField]
private bool m_TwoSided;
[ToggleControl("Two Sided")]
public Toggle twoSided
{
get { return new Toggle(m_TwoSided); }
set
{
if (m_TwoSided == value.isOn)
return;
m_TwoSided = value.isOn;
Dirty(ModificationScope.Graph);
}
}

18
com.unity.shadergraph/Editor/Data/MasterNodes/UnlitMasterNode.cs


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

return;
m_AlphaMode = value;
Dirty(ModificationScope.Graph);
}
}
[SerializeField]
private bool m_TwoSided;
[ToggleControl("Two Sided")]
public Toggle twoSided
{
get { return new Toggle(m_TwoSided); }
set
{
if (m_TwoSided == value.isOn)
return;
m_TwoSided = value.isOn;
Dirty(ModificationScope.Graph);
}
}

21
com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs


return res;
}
public static SurfaceMaterialOptions GetMaterialOptionsFromAlphaMode(AlphaMode alphaMode)
public static SurfaceMaterialOptions GetMaterialOptions(AlphaMode alphaMode, bool twoSided)
{
var materialOptions = new SurfaceMaterialOptions();
switch (alphaMode)

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

正在加载...
取消
保存