浏览代码

Adding more output variations to voronoi noise

/main
Eduardo Chaves 8 年前
当前提交
8938908f
共有 3 个文件被更改,包括 20 次插入28 次删除
  1. 2
      MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
  2. 4
      MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat
  3. 42
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/VoronoiNoise.cs

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

4
MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat


m_Texture: {fileID: 2800000, guid: 6ff1e57e8df9d2948bb6d703d02af730, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_ec519094_93da_4612_af61_2f8bcdc6589e_Uniform:
m_Texture: {fileID: 2800000, guid: 6ff1e57e8df9d2948bb6d703d02af730, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

42
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/VoronoiNoise.cs


namespace UnityEngine.MaterialGraph
{
[Title("Procedural/Voronoi Noise")]
public class VoronoiNoiseNode : Function2Input, IGeneratesFunction
public class VoronoiNoiseNode : FunctionNInNOut, IGeneratesFunction
AddSlot("UV", "uv", Graphing.SlotType.Input, SlotValueType.Vector2, Vector4.zero);
AddSlot("AngleOffset", "angleOffset", Graphing.SlotType.Input, SlotValueType.Vector1, new Vector4(2.0f,0,0,0));
AddSlot("Cellular", "n1", Graphing.SlotType.Output, SlotValueType.Vector1, Vector4.zero);
AddSlot("Tile", "n2", Graphing.SlotType.Output, SlotValueType.Vector1, Vector4.zero);
AddSlot("1 - Cellular", "n3", Graphing.SlotType.Output, SlotValueType.Vector1, Vector4.zero);
}
protected override string GetFunctionName()

protected override string GetInputSlot1Name()
{
return "UV";
}
protected override MaterialSlot GetInputSlot1()
{
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector2, Vector2.zero);
}
protected override string GetInputSlot2Name()
{
return "AngleOffset";
}
protected override MaterialSlot GetInputSlot2()
public override bool hasPreview
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, UnityEngine.Graphing.SlotType.Input, SlotValueType.Vector1, Vector2.zero);
}
protected override MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, UnityEngine.Graphing.SlotType.Output, SlotValueType.Vector3, Vector3.zero);
get
{
return true;
}
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)

outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk(GetFunctionPrototype("uv", "angleOffset"), false);
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();

outputString.AddShaderChunk("float3 res = float3(8.0, 0.0, 0.0);", false);
outputString.AddShaderChunk("for(int y=-1; y<=1; y++)", false);
outputString.AddShaderChunk("{", false);

outputString.Indent();
outputString.AddShaderChunk("res = float3(d, offset.x, offset.y);", false);
outputString.AddShaderChunk("n1 = res.x;", false);
outputString.AddShaderChunk("n2 = res.y;", false);
outputString.AddShaderChunk("n3 = 1.0 - res.x;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);

outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("return res;", false);
outputString.Deindent();

正在加载...
取消
保存