浏览代码

Repeating Dot Procedural Node

/main
bfogerty 8 年前
当前提交
6ff47f50
共有 2 个文件被更改,包括 68 次插入0 次删除
  1. 56
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/RepeatingDotNode.cs
  2. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/RepeatingDotNode.cs.meta

56
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/RepeatingDotNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Repeating Dot")]
public class RepeatingDotNode : Function2Input, IGeneratesFunction
{
public RepeatingDotNode()
{
name = "RepeatingDot";
}
protected override string GetFunctionName()
{
return "unity_repreatingdot_" + precision;
}
protected override string GetInputSlot1Name()
{
return "UV";
}
protected override string GetInputSlot2Name()
{
return "Count";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
}
protected override MaterialSlot GetInputSlot2()
{
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector1, Vector2.zero);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("uv", "count"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk("uv *= 2.0 - 1.0;", false);
outputString.AddShaderChunk("uv = fmod(uv * count, 1.0) * 2.0 - 1.0;", false);
outputString.AddShaderChunk("return length(uv);", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/RepeatingDotNode.cs.meta


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