浏览代码

Adding ChannelBlend node

/main
Eduardo Chaves 8 年前
当前提交
292567c4
共有 5 个文件被更改,包括 61 次插入3 次删除
  1. 2
      MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
  2. 2
      MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs
  3. 2
      MaterialGraphProject/Assets/Eduardo/HeightToNormalNode.cs
  4. 46
      MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs
  5. 12
      MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs.meta

2
MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
文件差异内容过多而无法显示
查看文件

2
MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs


private string GetOutputDeclaration()
{
string outDeclaration = "";
foreach (ISlot outSlot in GetOutputSlots<ISlot>())
foreach (MaterialSlot outSlot in GetOutputSlots<MaterialSlot>())
{
outDeclaration += "\n " + precision + GetSlotTypeName(outSlot.id) + " " + GetVariableNameForSlot(outSlot.id) + ";\n";
}

2
MaterialGraphProject/Assets/Eduardo/HeightToNormalNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("HeightToNormal")]
[Title("Utility/Heightmap To Normalmap")]
public class HeightToNormalNode : FunctionNInNOut, IGeneratesFunction
{

46
MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs


using UnityEngine.Graphing;
using System.Linq;
using System.Collections;
namespace UnityEngine.MaterialGraph
{
[Title("ChannelBlend")]
public class ChannelBlend : FunctionNInNOut, IGeneratesFunction
{
public ChannelBlend()
{
name = "ChannelBlend";
AddSlot("Mask", "mask", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("RColor", "rCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("GColor", "gCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BColor", "bCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("AColor", "aCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BGColor", "bgCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BlendedColor", "blendCol", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
}
protected override string GetFunctionName()
{
return "unity_ChannelBlend";
}
public override bool hasPreview
{
get { return true; }
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.AddShaderChunk("float4 background = step(max(mask.r,max(mask.g,mask.b)), 0.001) * bgCol;", false);
outputString.AddShaderChunk("blendCol = mask.r * rCol + mask.g * gCol + mask.b * bCol + mask.a * aCol + background;", false);
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs.meta


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